foreman_rh_cloud 12.2.16 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/foreman_rh_cloud/locale/fr/foreman_rh_cloud.js +24 -78
- data/app/assets/javascripts/foreman_rh_cloud/locale/ja/foreman_rh_cloud.js +24 -78
- data/app/assets/javascripts/foreman_rh_cloud/locale/ka/foreman_rh_cloud.js +23 -77
- data/app/assets/javascripts/foreman_rh_cloud/locale/ko/foreman_rh_cloud.js +23 -77
- data/app/assets/javascripts/foreman_rh_cloud/locale/zh_CN/foreman_rh_cloud.js +23 -77
- data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +3 -5
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +1 -1
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +1 -1
- data/app/controllers/insights_cloud/ui_requests_controller.rb +3 -2
- data/app/models/concerns/rh_cloud_host.rb +0 -14
- data/app/models/foreman_rh_cloud/ping.rb +1 -2
- data/app/models/insights_hit.rb +1 -1
- data/app/services/foreman_rh_cloud/cert_auth.rb +3 -13
- data/app/services/foreman_rh_cloud/gateway_request.rb +26 -0
- data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +1 -3
- data/app/services/foreman_rh_cloud/tags_auth.rb +4 -15
- data/app/views/api/v2/advisor_engine/host_details.json.rabl +3 -1
- data/app/views/api/v2/hosts/insights/base.rabl +2 -3
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +8 -13
- data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +26 -4
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +96 -0
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +2 -2
- data/lib/foreman_inventory_upload/generators/slice.rb +3 -3
- data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +49 -0
- data/lib/foreman_inventory_upload.rb +6 -6
- data/lib/foreman_rh_cloud/engine.rb +15 -34
- data/lib/foreman_rh_cloud/plugin.rb +13 -20
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +3 -3
- data/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +3 -3
- data/lib/inventory_sync/async/inventory_hosts_sync.rb +2 -0
- data/lib/tasks/rh_cloud_inventory.rake +31 -14
- data/locale/foreman_rh_cloud.pot +157 -261
- data/locale/fr/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/fr/foreman_rh_cloud.po +26 -79
- data/locale/ja/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ja/foreman_rh_cloud.po +26 -79
- data/locale/ka/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ka/foreman_rh_cloud.po +24 -77
- data/locale/ko/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ko/foreman_rh_cloud.po +25 -78
- data/locale/zh_CN/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/zh_CN/foreman_rh_cloud.po +25 -78
- data/package.json +1 -1
- data/test/controllers/accounts_controller_test.rb +1 -1
- data/test/controllers/insights_cloud/api/advisor_engine_controller_test.rb +1 -28
- data/test/controllers/insights_cloud/ui_requests_controller_test.rb +0 -26
- data/test/controllers/uploads_controller_test.rb +1 -1
- data/test/factories/insights_factories.rb +0 -29
- data/test/jobs/cloud_connector_announce_task_test.rb +2 -3
- data/test/jobs/connector_playbook_execution_reporter_task_test.rb +20 -32
- data/test/jobs/exponential_backoff_test.rb +8 -9
- data/test/jobs/insights_client_status_aging_test.rb +2 -3
- data/test/jobs/insights_full_sync_test.rb +7 -13
- data/test/jobs/insights_resolutions_sync_test.rb +5 -9
- data/test/jobs/insights_rules_sync_test.rb +3 -5
- data/test/jobs/inventory_full_sync_test.rb +5 -9
- data/test/jobs/inventory_hosts_sync_test.rb +6 -11
- data/test/jobs/inventory_scheduled_sync_test.rb +6 -10
- data/test/jobs/inventory_self_host_sync_test.rb +1 -1
- data/test/jobs/remove_insights_hosts_job_test.rb +15 -14
- data/test/jobs/upload_report_job_test.rb +36 -0
- data/test/unit/fact_helpers_test.rb +0 -47
- data/test/unit/services/foreman_rh_cloud/tags_auth_test.rb +0 -14
- data/test/unit/slice_generator_test.rb +0 -57
- data/webpack/ForemanColumnExtensions/index.js +0 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +17 -24
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +8 -178
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +36 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +1 -3
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +51 -69
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +1 -1
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +1 -1
- data/webpack/ForemanRhCloudFills.js +2 -6
- data/webpack/ForemanRhCloudHelpers.js +0 -4
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +3 -3
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +9 -3
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +4 -24
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +112 -0
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js +2 -2
- data/webpack/InsightsCloudSync/Components/ToolbarDropdown.js +3 -3
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +3 -3
- data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +0 -10
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -1
- data/webpack/InsightsHostDetailsTab/InsightsTab.scss +0 -4
- data/webpack/InsightsHostDetailsTab/InsightsTotalRiskChart.js +23 -59
- data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +19 -6
- data/webpack/InsightsVulnerabilityHostIndexExtensions/CVECountCell.js +2 -8
- data/webpack/InsightsVulnerabilityHostIndexExtensions/__tests__/CVECountCell.test.js +4 -105
- data/webpack/__mocks__/foremanReact/common/hooks/API/APIHooks.js +3 -0
- data/webpack/__tests__/ForemanRhCloudHelpers.test.js +1 -16
- data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +0 -6
- data/webpack/common/Hooks/ConfigHooks.js +16 -3
- metadata +12 -31
- data/app/controllers/concerns/foreman_rh_cloud/registration_manager_extensions.rb +0 -39
- data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +0 -30
- data/lib/foreman_inventory_upload/async/generate_host_report.rb +0 -20
- data/lib/foreman_inventory_upload/async/host_inventory_report_job.rb +0 -39
- data/lib/foreman_inventory_upload/async/single_host_report_job.rb +0 -20
- data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +0 -200
- data/test/jobs/create_missing_insights_facets_test.rb +0 -151
- data/test/jobs/generate_host_report_test.rb +0 -100
- data/test/jobs/generate_report_job_test.rb +0 -146
- data/test/jobs/host_inventory_report_job_test.rb +0 -244
- data/test/jobs/queue_for_upload_job_test.rb +0 -54
- data/test/jobs/single_host_report_job_test.rb +0 -155
- data/test/jobs/upload_report_direct_job_test.rb +0 -399
- data/test/unit/foreman_rh_cloud_iop_metadata_test.rb +0 -200
- data/test/unit/lib/foreman_rh_cloud/registration_manager_extensions_test.rb +0 -154
- data/test/unit/rh_cloud_host_test.rb +0 -191
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTotalRiskChart.test.js +0 -194
|
@@ -1,183 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { screen } from '@testing-library/react';
|
|
3
|
-
import { rtlHelpers } from 'foremanReact/common/rtlTestHelpers';
|
|
4
|
-
import PageHeader from '../PageHeader';
|
|
5
|
-
|
|
6
|
-
// Create a variable to control IoP mode in tests
|
|
7
|
-
let mockIopMode = false;
|
|
8
|
-
|
|
9
|
-
// Mock ForemanContext
|
|
10
|
-
jest.mock('foremanReact/Root/Context/ForemanContext', () => ({
|
|
11
|
-
useForemanContext: () => ({
|
|
12
|
-
metadata: {
|
|
13
|
-
foreman_rh_cloud: {
|
|
14
|
-
iop: mockIopMode,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
UI: {},
|
|
18
|
-
}),
|
|
19
|
-
}));
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
20
2
|
|
|
21
|
-
|
|
22
|
-
// This prevents child component complexity from affecting our tests
|
|
23
|
-
jest.mock('../components/SettingsWarning', () => () => (
|
|
24
|
-
<div data-testid="settings-warning">SettingsWarning</div>
|
|
25
|
-
));
|
|
26
|
-
jest.mock('../PageTitle', () => () => (
|
|
27
|
-
<div data-testid="page-title">PageTitle</div>
|
|
28
|
-
));
|
|
29
|
-
jest.mock('../../InventorySettings', () => () => (
|
|
30
|
-
<div data-testid="inventory-settings">InventorySettings</div>
|
|
31
|
-
));
|
|
32
|
-
jest.mock('../components/PageDescription', () => () => (
|
|
33
|
-
<div data-testid="page-description">PageDescription</div>
|
|
34
|
-
));
|
|
35
|
-
jest.mock('../../InventoryFilter', () => () => (
|
|
36
|
-
<div data-testid="inventory-filter">InventoryFilter</div>
|
|
37
|
-
));
|
|
38
|
-
jest.mock('../components/ToolbarButtons', () => () => (
|
|
39
|
-
<div data-testid="toolbar-buttons">ToolbarButtons</div>
|
|
40
|
-
));
|
|
3
|
+
import PageHeader from '../PageHeader';
|
|
41
4
|
|
|
42
|
-
const
|
|
5
|
+
const fixtures = {
|
|
6
|
+
'render without Props': {},
|
|
7
|
+
/** fixtures, props for the component */
|
|
8
|
+
};
|
|
43
9
|
|
|
44
10
|
describe('PageHeader', () => {
|
|
45
|
-
describe('
|
|
46
|
-
|
|
47
|
-
mockIopMode = false; // Ensure IoP mode is disabled for this test
|
|
48
|
-
|
|
49
|
-
renderWithStore(<PageHeader />, {
|
|
50
|
-
API: {
|
|
51
|
-
INVENTORY_SETTINGS: {
|
|
52
|
-
response: { subscriptionConnectionEnabled: true },
|
|
53
|
-
},
|
|
54
|
-
ADVISOR_ENGINE_CONFIG: {
|
|
55
|
-
response: { use_iop_mode: false },
|
|
56
|
-
status: 'RESOLVED',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// All components should be present when not in IoP mode
|
|
62
|
-
expect(screen.getByTestId('settings-warning')).toBeTruthy();
|
|
63
|
-
expect(screen.getByTestId('page-title')).toBeTruthy();
|
|
64
|
-
expect(screen.getByTestId('inventory-settings')).toBeTruthy();
|
|
65
|
-
expect(screen.getByTestId('page-description')).toBeTruthy();
|
|
66
|
-
expect(screen.getByTestId('inventory-filter')).toBeTruthy();
|
|
67
|
-
expect(screen.getByTestId('toolbar-buttons')).toBeTruthy();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('hides inventory settings and description when in IoP mode', () => {
|
|
71
|
-
mockIopMode = true; // Enable IoP mode for this test
|
|
72
|
-
|
|
73
|
-
renderWithStore(<PageHeader />, {
|
|
74
|
-
API: {
|
|
75
|
-
INVENTORY_SETTINGS: {
|
|
76
|
-
response: { subscriptionConnectionEnabled: true },
|
|
77
|
-
},
|
|
78
|
-
ADVISOR_ENGINE_CONFIG: {
|
|
79
|
-
response: { use_iop_mode: true },
|
|
80
|
-
status: 'RESOLVED',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Core components should still be present
|
|
86
|
-
expect(screen.getByTestId('settings-warning')).toBeTruthy();
|
|
87
|
-
expect(screen.getByTestId('page-title')).toBeTruthy();
|
|
88
|
-
expect(screen.getByTestId('inventory-filter')).toBeTruthy();
|
|
89
|
-
expect(screen.getByTestId('toolbar-buttons')).toBeTruthy();
|
|
90
|
-
|
|
91
|
-
// These components should be hidden in IoP mode
|
|
92
|
-
expect(screen.queryByTestId('inventory-settings')).toBeNull();
|
|
93
|
-
expect(screen.queryByTestId('page-description')).toBeNull();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('renders with correct CSS class', () => {
|
|
97
|
-
mockIopMode = false; // Ensure IoP mode is disabled for this test
|
|
98
|
-
|
|
99
|
-
const { container } = renderWithStore(<PageHeader />, {
|
|
100
|
-
API: {
|
|
101
|
-
INVENTORY_SETTINGS: {
|
|
102
|
-
response: { subscriptionConnectionEnabled: true },
|
|
103
|
-
},
|
|
104
|
-
ADVISOR_ENGINE_CONFIG: {
|
|
105
|
-
response: { use_iop_mode: false },
|
|
106
|
-
status: 'RESOLVED',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
expect(container.querySelector('.inventory-upload-header')).toBeTruthy();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
test('renders grid layout with correct structure', () => {
|
|
115
|
-
mockIopMode = false; // Ensure IoP mode is disabled for this test
|
|
116
|
-
|
|
117
|
-
const { container } = renderWithStore(<PageHeader />, {
|
|
118
|
-
API: {
|
|
119
|
-
INVENTORY_SETTINGS: {
|
|
120
|
-
response: { subscriptionConnectionEnabled: true },
|
|
121
|
-
},
|
|
122
|
-
ADVISOR_ENGINE_CONFIG: {
|
|
123
|
-
response: { use_iop_mode: false },
|
|
124
|
-
status: 'RESOLVED',
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const gridRow = container.querySelector('.row');
|
|
130
|
-
expect(gridRow).toBeTruthy();
|
|
131
|
-
|
|
132
|
-
const filterColumn = container.querySelector('.col-xs-4');
|
|
133
|
-
expect(filterColumn).toBeTruthy();
|
|
134
|
-
|
|
135
|
-
const toolbarColumn = container.querySelector('.col-xs-7');
|
|
136
|
-
expect(toolbarColumn).toBeTruthy();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test('renders description section only when not in IoP mode', () => {
|
|
140
|
-
mockIopMode = false; // Ensure IoP mode is disabled for this test
|
|
141
|
-
|
|
142
|
-
const { container } = renderWithStore(<PageHeader />, {
|
|
143
|
-
API: {
|
|
144
|
-
INVENTORY_SETTINGS: {
|
|
145
|
-
response: { subscriptionConnectionEnabled: true },
|
|
146
|
-
},
|
|
147
|
-
ADVISOR_ENGINE_CONFIG: {
|
|
148
|
-
response: { use_iop_mode: false },
|
|
149
|
-
status: 'RESOLVED',
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// Description section should be present when not in IoP mode
|
|
155
|
-
const descriptionSection = container.querySelector(
|
|
156
|
-
'.inventory-upload-header-description'
|
|
157
|
-
);
|
|
158
|
-
expect(descriptionSection).toBeTruthy();
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test('does not render description section when in IoP mode', () => {
|
|
162
|
-
mockIopMode = true; // Enable IoP mode for this test
|
|
163
|
-
|
|
164
|
-
const { container } = renderWithStore(<PageHeader />, {
|
|
165
|
-
API: {
|
|
166
|
-
INVENTORY_SETTINGS: {
|
|
167
|
-
response: { subscriptionConnectionEnabled: true },
|
|
168
|
-
},
|
|
169
|
-
ADVISOR_ENGINE_CONFIG: {
|
|
170
|
-
response: { use_iop_mode: true },
|
|
171
|
-
status: 'RESOLVED',
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
// Description section should not be present in IoP mode
|
|
177
|
-
const descriptionSection = container.querySelector(
|
|
178
|
-
'.inventory-upload-header-description'
|
|
179
|
-
);
|
|
180
|
-
expect(descriptionSection).toBeNull();
|
|
181
|
-
});
|
|
182
|
-
});
|
|
11
|
+
describe('rendering', () =>
|
|
12
|
+
testComponentSnapshotsWithFixtures(PageHeader, fixtures));
|
|
183
13
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`PageHeader rendering render without Props 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="inventory-upload-header"
|
|
6
|
+
>
|
|
7
|
+
<ConnectedSettingsWarning />
|
|
8
|
+
<PageTitle />
|
|
9
|
+
<div
|
|
10
|
+
className="inventory-upload-header-description"
|
|
11
|
+
>
|
|
12
|
+
<ConnectedInventorySettings />
|
|
13
|
+
<PageDescription />
|
|
14
|
+
</div>
|
|
15
|
+
<Row
|
|
16
|
+
bsClass="row"
|
|
17
|
+
componentClass="div"
|
|
18
|
+
>
|
|
19
|
+
<Col
|
|
20
|
+
bsClass="col"
|
|
21
|
+
componentClass="div"
|
|
22
|
+
xs={4}
|
|
23
|
+
>
|
|
24
|
+
<Connect(InventoryFilter) />
|
|
25
|
+
</Col>
|
|
26
|
+
<Col
|
|
27
|
+
bsClass="col"
|
|
28
|
+
componentClass="div"
|
|
29
|
+
xs={7}
|
|
30
|
+
xsOffset={1}
|
|
31
|
+
>
|
|
32
|
+
<ToolbarButtons />
|
|
33
|
+
</Col>
|
|
34
|
+
</Row>
|
|
35
|
+
</div>
|
|
36
|
+
`;
|
|
@@ -32,7 +32,7 @@ exports[`PageTitle rendering render without Props 1`] = `
|
|
|
32
32
|
Actions history
|
|
33
33
|
</DropdownItem>,
|
|
34
34
|
<DropdownItem
|
|
35
|
-
href="/links/manual/?root_url=https%3A%2F%
|
|
35
|
+
href="/links/manual/?root_url=https%3A%2F%2Faccess.redhat.com%2Fdocumentation%2Fen-us%2Fred_hat_insights%2F2023%2Fhtml%2Fred_hat_insights_remediations_guide%2Fhost-communication-with-insights_red-hat-insights-remediation-guide%23uploading-satellite-host-inventory-to-insights_configuring-satellite-cloud-connector"
|
|
36
36
|
ouiaId="inventory-documentation-button"
|
|
37
37
|
rel="noopener noreferrer"
|
|
38
38
|
target="_blank"
|
|
@@ -4,13 +4,11 @@ import SyncButton from '../SyncButton';
|
|
|
4
4
|
import CloudConnectorButton from '../CloudConnectorButton';
|
|
5
5
|
import './toolbarButtons.scss';
|
|
6
6
|
import { selectSubscriptionConnectionEnabled } from '../../../InventorySettings/InventorySettingsSelectors';
|
|
7
|
-
import { useIopConfig } from '../../../../../common/Hooks/ConfigHooks';
|
|
8
7
|
|
|
9
8
|
const ToolbarButtons = () => {
|
|
10
9
|
const subscriptionConnectionEnabled = useSelector(
|
|
11
10
|
selectSubscriptionConnectionEnabled
|
|
12
11
|
);
|
|
13
|
-
const isIop = useIopConfig();
|
|
14
12
|
|
|
15
13
|
if (!subscriptionConnectionEnabled) {
|
|
16
14
|
return null;
|
|
@@ -18,7 +16,7 @@ const ToolbarButtons = () => {
|
|
|
18
16
|
|
|
19
17
|
return (
|
|
20
18
|
<div className="inventory_toolbar_buttons">
|
|
21
|
-
|
|
19
|
+
<CloudConnectorButton />
|
|
22
20
|
<SyncButton />
|
|
23
21
|
</div>
|
|
24
22
|
);
|
|
@@ -1,78 +1,60 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { Provider } from 'react-redux';
|
|
3
|
+
import configureMockStore from 'redux-mock-store';
|
|
4
|
+
import thunk from 'redux-thunk';
|
|
5
|
+
import { screen, render } from '@testing-library/react';
|
|
4
6
|
import ToolbarButtons from '../ToolbarButtons';
|
|
5
|
-
import { useIopConfig } from '../../../../../../common/Hooks/ConfigHooks';
|
|
6
|
-
import { selectSubscriptionConnectionEnabled } from '../../../../InventorySettings/InventorySettingsSelectors';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
26
|
-
jest.mock(
|
|
27
|
-
'../../CloudConnectorButton',
|
|
28
|
-
() =>
|
|
29
|
-
function MockCloudConnectorButton() {
|
|
30
|
-
return (
|
|
31
|
-
<div data-testid="cloud-connector-button">
|
|
32
|
-
Configure cloud connector
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const { renderWithStore } = rtlHelpers;
|
|
8
|
+
const middlewares = [thunk];
|
|
9
|
+
const mockStore = configureMockStore(middlewares);
|
|
10
|
+
|
|
11
|
+
const renderOptions = {
|
|
12
|
+
API: {
|
|
13
|
+
INVENTORY_SETTINGS: {
|
|
14
|
+
response: { subscriptionConnectionEnabled: true },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
ForemanRhCloud: {
|
|
18
|
+
inventoryUpload: {
|
|
19
|
+
accountsList: {
|
|
20
|
+
CloudConnectorStatus: {},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
39
25
|
|
|
40
26
|
describe('ToolbarButtons', () => {
|
|
41
|
-
test('
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
27
|
+
test('when subscription connection is enabled', () => {
|
|
28
|
+
const store = mockStore(renderOptions);
|
|
29
|
+
|
|
30
|
+
render(
|
|
31
|
+
<Provider store={store}>
|
|
32
|
+
<ToolbarButtons />
|
|
33
|
+
</Provider>
|
|
34
|
+
);
|
|
35
|
+
expect(screen.queryAllByText('Configure cloud connector')).toHaveLength(1);
|
|
36
|
+
expect(screen.queryAllByText('Sync all inventory status')).toHaveLength(1);
|
|
49
37
|
});
|
|
50
38
|
|
|
51
|
-
test('
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
useIopConfig.mockReturnValue(false);
|
|
72
|
-
selectSubscriptionConnectionEnabled.mockReturnValue(true);
|
|
73
|
-
|
|
74
|
-
const { container } = renderWithStore(<ToolbarButtons />);
|
|
75
|
-
|
|
76
|
-
expect(container.querySelector('.inventory_toolbar_buttons')).toBeTruthy();
|
|
39
|
+
test('when subscription connection is not enabled', () => {
|
|
40
|
+
const localSetting = {
|
|
41
|
+
API: {
|
|
42
|
+
INVENTORY_SETTINGS: {
|
|
43
|
+
response: { subscriptionConnectionEnabled: false },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const store = mockStore({
|
|
48
|
+
...renderOptions,
|
|
49
|
+
...localSetting,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
render(
|
|
53
|
+
<Provider store={store}>
|
|
54
|
+
<ToolbarButtons />
|
|
55
|
+
</Provider>
|
|
56
|
+
);
|
|
57
|
+
expect(screen.queryAllByText('Configure cloud connector')).toHaveLength(0);
|
|
58
|
+
expect(screen.queryAllByText('Sync all inventory status')).toHaveLength(0);
|
|
77
59
|
});
|
|
78
60
|
});
|
|
@@ -7,7 +7,7 @@ export const inventoryUrl = path =>
|
|
|
7
7
|
export const getInventoryDocsUrl = () =>
|
|
8
8
|
foremanUrl(
|
|
9
9
|
`/links/manual/?root_url=${URI.encode(
|
|
10
|
-
'https://
|
|
10
|
+
'https://access.redhat.com/documentation/en-us/red_hat_insights/2023/html/red_hat_insights_remediations_guide/host-communication-with-insights_red-hat-insights-remediation-guide#uploading-satellite-host-inventory-to-insights_configuring-satellite-cloud-connector'
|
|
11
11
|
)}`
|
|
12
12
|
);
|
|
13
13
|
|
data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`ForemanInventoryUpload helpers should return inventory Url 1`] = `"/foreman_inventory_upload/test_path"`;
|
|
4
4
|
|
|
5
|
-
exports[`ForemanInventoryUpload helpers should return inventory docs url 1`] = `"/links/manual/?root_url=https%3A%2F%
|
|
5
|
+
exports[`ForemanInventoryUpload helpers should return inventory docs url 1`] = `"/links/manual/?root_url=https%3A%2F%2Faccess.redhat.com%2Fdocumentation%2Fen-us%2Fred_hat_insights%2F2023%2Fhtml%2Fred_hat_insights_remediations_guide%2Fhost-communication-with-insights_red-hat-insights-remediation-guide%23uploading-satellite-host-inventory-to-insights_configuring-satellite-cloud-connector"`;
|
|
@@ -4,11 +4,7 @@ import { translate as __ } from 'foremanReact/common/I18n';
|
|
|
4
4
|
import InventoryAutoUploadSwitcher from './ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload';
|
|
5
5
|
import NewHostDetailsTab from './InsightsHostDetailsTab/NewHostDetailsTab';
|
|
6
6
|
import { InsightsTotalRiskChartWrapper } from './InsightsHostDetailsTab/InsightsTotalRiskChartWrapper';
|
|
7
|
-
import {
|
|
8
|
-
isNotRhelHost,
|
|
9
|
-
vulnerabilityDisabled,
|
|
10
|
-
hasNoInsightsFacet,
|
|
11
|
-
} from './ForemanRhCloudHelpers';
|
|
7
|
+
import { isNotRhelHost, vulnerabilityDisabled } from './ForemanRhCloudHelpers';
|
|
12
8
|
import CVEsHostDetailsTabWrapper from './CVEsHostDetailsTab/CVEsHostDetailsTab';
|
|
13
9
|
|
|
14
10
|
const fills = [
|
|
@@ -24,7 +20,7 @@ const fills = [
|
|
|
24
20
|
component: props => <NewHostDetailsTab {...props} />,
|
|
25
21
|
weight: 400,
|
|
26
22
|
metadata: {
|
|
27
|
-
hideTab:
|
|
23
|
+
hideTab: isNotRhelHost,
|
|
28
24
|
title: __('Recommendations'),
|
|
29
25
|
},
|
|
30
26
|
},
|
|
@@ -14,7 +14,3 @@ export const isNotRhelHost = ({ hostDetails }) =>
|
|
|
14
14
|
|
|
15
15
|
export const vulnerabilityDisabled = ({ hostDetails }) =>
|
|
16
16
|
isNotRhelHost({ hostDetails }) || !hostDetails?.vulnerability?.enabled;
|
|
17
|
-
|
|
18
|
-
export const hasNoInsightsFacet = ({ response, hostDetails }) =>
|
|
19
|
-
// eslint-disable-next-line camelcase
|
|
20
|
-
!(response?.insights_attributes || hostDetails?.insights_attributes);
|
|
@@ -3,19 +3,19 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { translate as __ } from 'foremanReact/common/I18n';
|
|
4
4
|
import SwitcherPF4 from '../../../common/Switcher/SwitcherPF4';
|
|
5
5
|
import './insightsSettings.scss';
|
|
6
|
-
import {
|
|
6
|
+
import { useAdvisorEngineConfig } from '../../../common/Hooks/ConfigHooks';
|
|
7
7
|
|
|
8
8
|
const InsightsSettings = ({
|
|
9
9
|
insightsSyncEnabled,
|
|
10
10
|
getInsightsSyncSettings,
|
|
11
11
|
setInsightsSyncEnabled,
|
|
12
12
|
}) => {
|
|
13
|
-
const
|
|
13
|
+
const isLocalAdvisorEngine = useAdvisorEngineConfig();
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
getInsightsSyncSettings();
|
|
16
16
|
}, [getInsightsSyncSettings]);
|
|
17
17
|
|
|
18
|
-
if (
|
|
18
|
+
if (isLocalAdvisorEngine) return null;
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
21
|
<div className="insights_settings">
|
|
@@ -16,7 +16,7 @@ import TableEmptyState from '../../../common/table/EmptyState';
|
|
|
16
16
|
import { modifySelectedRows, getSortColumnIndex } from './InsightsTableHelpers';
|
|
17
17
|
import Pagination from './Pagination';
|
|
18
18
|
import './table.scss';
|
|
19
|
-
import {
|
|
19
|
+
import { useAdvisorEngineConfig } from '../../../common/Hooks/ConfigHooks';
|
|
20
20
|
|
|
21
21
|
const InsightsTable = ({
|
|
22
22
|
page,
|
|
@@ -48,11 +48,17 @@ const InsightsTable = ({
|
|
|
48
48
|
fetchInsights({ page, perPage, query, sortBy, sortOrder });
|
|
49
49
|
}, [hostname]);
|
|
50
50
|
|
|
51
|
-
const
|
|
51
|
+
const isLocalAdvisorEngine = useAdvisorEngineConfig();
|
|
52
52
|
|
|
53
53
|
useEffect(() => {
|
|
54
54
|
setRows(
|
|
55
|
-
modifySelectedRows(
|
|
55
|
+
modifySelectedRows(
|
|
56
|
+
hits,
|
|
57
|
+
selectedIds,
|
|
58
|
+
showSelectAllAlert,
|
|
59
|
+
hideHost,
|
|
60
|
+
isLocalAdvisorEngine
|
|
61
|
+
)
|
|
56
62
|
);
|
|
57
63
|
|
|
58
64
|
if (hideHost) setColumns(getColumnsWithoutHostname());
|
|
@@ -1,33 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
2
|
+
|
|
3
3
|
import InsightsTable from '../InsightsTable';
|
|
4
4
|
import { tableProps } from './fixtures';
|
|
5
5
|
|
|
6
|
-
jest.mock('foremanReact/Root/Context/ForemanContext', () => ({
|
|
7
|
-
useForemanContext: () => ({
|
|
8
|
-
metadata: {
|
|
9
|
-
foreman_rh_cloud: {
|
|
10
|
-
iop: true,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
}),
|
|
14
|
-
useForemanSettings: () => ({
|
|
15
|
-
perPage: 20,
|
|
16
|
-
}),
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
const { renderWithStore } = rtlHelpers;
|
|
20
|
-
|
|
21
6
|
const fixtures = {
|
|
22
7
|
'render with Props': tableProps,
|
|
23
8
|
};
|
|
24
9
|
|
|
25
10
|
describe('InsightsTable', () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('renders without crashing', () => {
|
|
31
|
-
renderWithStore(<InsightsTable {...tableProps} />);
|
|
32
|
-
});
|
|
11
|
+
describe('rendering', () =>
|
|
12
|
+
testComponentSnapshotsWithFixtures(InsightsTable, fixtures));
|
|
33
13
|
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`InsightsTable rendering render with Props 1`] = `
|
|
4
|
+
<Fragment>
|
|
5
|
+
<SelectAllAlert
|
|
6
|
+
clearAllSelection={[Function]}
|
|
7
|
+
isAllSelected={false}
|
|
8
|
+
selectAll={[Function]}
|
|
9
|
+
selectedIds={Object {}}
|
|
10
|
+
showSelectAllAlert={false}
|
|
11
|
+
/>
|
|
12
|
+
<Table
|
|
13
|
+
actionsMenuAppendTo="inline"
|
|
14
|
+
aria-label="Recommendations Table"
|
|
15
|
+
borders={true}
|
|
16
|
+
canCollapseAll={false}
|
|
17
|
+
canSelectAll={false}
|
|
18
|
+
canSortFavorites={true}
|
|
19
|
+
cells={
|
|
20
|
+
Array [
|
|
21
|
+
Object {
|
|
22
|
+
"id": "hostname",
|
|
23
|
+
"sortKey": "hostname",
|
|
24
|
+
"title": "Hostname",
|
|
25
|
+
"transforms": Array [
|
|
26
|
+
[Function],
|
|
27
|
+
[Function],
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
Object {
|
|
31
|
+
"id": "recommendation",
|
|
32
|
+
"sortKey": "title",
|
|
33
|
+
"title": "Recommendation",
|
|
34
|
+
"transforms": Array [
|
|
35
|
+
[Function],
|
|
36
|
+
[Function],
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
Object {
|
|
40
|
+
"cellTransforms": Array [
|
|
41
|
+
[Function],
|
|
42
|
+
],
|
|
43
|
+
"id": "total risk",
|
|
44
|
+
"sortKey": "total_risk",
|
|
45
|
+
"title": "Total risk",
|
|
46
|
+
"transforms": Array [
|
|
47
|
+
[Function],
|
|
48
|
+
[Function],
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
Object {
|
|
52
|
+
"cellTransforms": Array [
|
|
53
|
+
[Function],
|
|
54
|
+
],
|
|
55
|
+
"id": "remediate",
|
|
56
|
+
"title": "Remediate",
|
|
57
|
+
"transforms": Array [
|
|
58
|
+
[Function],
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
Object {
|
|
62
|
+
"cellTransforms": Array [
|
|
63
|
+
[Function],
|
|
64
|
+
],
|
|
65
|
+
"id": "actions",
|
|
66
|
+
"title": "",
|
|
67
|
+
"transforms": Array [
|
|
68
|
+
[Function],
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
className="rh-cloud-recommendations-table"
|
|
74
|
+
collapseAllAriaLabel=""
|
|
75
|
+
contentId="expanded-content"
|
|
76
|
+
dropdownDirection="down"
|
|
77
|
+
dropdownPosition="right"
|
|
78
|
+
expandId="expandable-toggle"
|
|
79
|
+
gridBreakPoint="grid-md"
|
|
80
|
+
isHeaderSelectDisabled={false}
|
|
81
|
+
isNested={false}
|
|
82
|
+
isStickyHeader={false}
|
|
83
|
+
isTreeTable={false}
|
|
84
|
+
onSelect={[Function]}
|
|
85
|
+
onSort={[Function]}
|
|
86
|
+
ouiaId="rh-cloud-recommendations-table"
|
|
87
|
+
ouiaSafe={true}
|
|
88
|
+
role="grid"
|
|
89
|
+
rowLabeledBy="simple-node"
|
|
90
|
+
rows={Array []}
|
|
91
|
+
selectVariant="checkbox"
|
|
92
|
+
sortBy={
|
|
93
|
+
Object {
|
|
94
|
+
"direction": "desc",
|
|
95
|
+
"index": 3,
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
variant="compact"
|
|
99
|
+
>
|
|
100
|
+
<TableHeader />
|
|
101
|
+
<TableBody />
|
|
102
|
+
</Table>
|
|
103
|
+
<TableEmptyState
|
|
104
|
+
error={null}
|
|
105
|
+
rowsLength={0}
|
|
106
|
+
status="RESOLVED"
|
|
107
|
+
/>
|
|
108
|
+
<Pagination
|
|
109
|
+
variant="bottom"
|
|
110
|
+
/>
|
|
111
|
+
</Fragment>
|
|
112
|
+
`;
|
|
@@ -16,7 +16,7 @@ import { modifyRows } from './RemediationHelpers';
|
|
|
16
16
|
import ModalFooter from './RemediationModalFooter';
|
|
17
17
|
import TableEmptyState from '../../../common/table/EmptyState';
|
|
18
18
|
import './RemediationModal.scss';
|
|
19
|
-
import {
|
|
19
|
+
import { useAdvisorEngineConfig } from '../../../common/Hooks/ConfigHooks';
|
|
20
20
|
|
|
21
21
|
/* eslint-disable spellcheck/spell-checker */
|
|
22
22
|
|
|
@@ -82,7 +82,7 @@ const RemediationModal = ({
|
|
|
82
82
|
const [rows, setRows] = React.useState([]);
|
|
83
83
|
const toggleModal = () => setOpen(prevValue => !prevValue);
|
|
84
84
|
|
|
85
|
-
const isIop =
|
|
85
|
+
const isIop = useAdvisorEngineConfig();
|
|
86
86
|
useEffect(() => {
|
|
87
87
|
// only fetch for Hosted. IoP provides via props.
|
|
88
88
|
if (!isIop && open)
|