foreman_rh_cloud 12.2.13 → 12.2.15
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/controllers/concerns/foreman_rh_cloud/registration_manager_extensions.rb +2 -2
- data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +3 -0
- 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 +2 -3
- data/app/models/concerns/rh_cloud_host.rb +14 -0
- data/app/models/foreman_rh_cloud/ping.rb +2 -1
- data/app/services/foreman_rh_cloud/tags_auth.rb +13 -3
- data/app/views/api/v2/advisor_engine/host_details.json.rabl +1 -3
- data/app/views/api/v2/hosts/insights/base.rabl +3 -2
- data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +1 -23
- data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +200 -0
- data/lib/foreman_inventory_upload.rb +0 -4
- data/lib/foreman_rh_cloud/plugin.rb +11 -4
- 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 +0 -2
- 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 +28 -1
- data/test/controllers/insights_cloud/ui_requests_controller_test.rb +26 -0
- data/test/controllers/uploads_controller_test.rb +1 -1
- data/test/factories/insights_factories.rb +29 -0
- data/test/jobs/queue_for_upload_job_test.rb +1 -12
- data/test/jobs/upload_report_direct_job_test.rb +399 -0
- data/test/unit/foreman_rh_cloud_iop_metadata_test.rb +200 -0
- data/test/unit/lib/foreman_rh_cloud/registration_manager_extensions_test.rb +4 -42
- data/test/unit/rh_cloud_host_test.rb +191 -0
- data/test/unit/services/foreman_rh_cloud/tags_auth_test.rb +14 -0
- data/webpack/ForemanColumnExtensions/index.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +24 -17
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +178 -8
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +3 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +69 -51
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +1 -1
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +3 -3
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +3 -9
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +24 -4
- 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 +10 -0
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -1
- data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +5 -5
- data/webpack/InsightsVulnerabilityHostIndexExtensions/CVECountCell.js +2 -2
- data/webpack/InsightsVulnerabilityHostIndexExtensions/__tests__/CVECountCell.test.js +77 -22
- data/webpack/common/Hooks/ConfigHooks.js +3 -16
- metadata +9 -9
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +0 -97
- data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +0 -55
- data/test/jobs/upload_report_job_test.rb +0 -38
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +0 -36
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +0 -112
- data/webpack/__mocks__/foremanReact/common/hooks/API/APIHooks.js +0 -3
|
@@ -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 { useIopConfig } from '../../../common/Hooks/ConfigHooks';
|
|
20
20
|
|
|
21
21
|
const InsightsTable = ({
|
|
22
22
|
page,
|
|
@@ -48,17 +48,11 @@ const InsightsTable = ({
|
|
|
48
48
|
fetchInsights({ page, perPage, query, sortBy, sortOrder });
|
|
49
49
|
}, [hostname]);
|
|
50
50
|
|
|
51
|
-
const
|
|
51
|
+
const isIop = useIopConfig();
|
|
52
52
|
|
|
53
53
|
useEffect(() => {
|
|
54
54
|
setRows(
|
|
55
|
-
modifySelectedRows(
|
|
56
|
-
hits,
|
|
57
|
-
selectedIds,
|
|
58
|
-
showSelectAllAlert,
|
|
59
|
-
hideHost,
|
|
60
|
-
isLocalAdvisorEngine
|
|
61
|
-
)
|
|
55
|
+
modifySelectedRows(hits, selectedIds, showSelectAllAlert, hideHost, isIop)
|
|
62
56
|
);
|
|
63
57
|
|
|
64
58
|
if (hideHost) setColumns(getColumnsWithoutHostname());
|
|
@@ -1,13 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { rtlHelpers } from 'foremanReact/common/rtlTestHelpers';
|
|
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
|
+
|
|
6
21
|
const fixtures = {
|
|
7
22
|
'render with Props': tableProps,
|
|
8
23
|
};
|
|
9
24
|
|
|
10
25
|
describe('InsightsTable', () => {
|
|
11
|
-
|
|
12
|
-
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
jest.clearAllMocks();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders without crashing', () => {
|
|
31
|
+
renderWithStore(<InsightsTable {...tableProps} />);
|
|
32
|
+
});
|
|
13
33
|
});
|
|
@@ -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 { useIopConfig } 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 = useIopConfig();
|
|
86
86
|
useEffect(() => {
|
|
87
87
|
// only fetch for Hosted. IoP provides via props.
|
|
88
88
|
if (!isIop && open)
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
} from '@patternfly/react-core/deprecated';
|
|
9
9
|
import { ExternalLinkAltIcon } from '@patternfly/react-icons';
|
|
10
10
|
import { redHatAdvisorSystems } from '../InsightsCloudSyncHelpers';
|
|
11
|
-
import {
|
|
11
|
+
import { useIopConfig } from '../../common/Hooks/ConfigHooks';
|
|
12
12
|
|
|
13
13
|
const ToolbarDropdown = ({ onRecommendationSync }) => {
|
|
14
14
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
15
|
+
const isIop = useIopConfig();
|
|
16
|
+
if (isIop) {
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
19
|
const dropdownItems = [
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import PageLayout from 'foremanReact/routes/common/PageLayout/PageLayout';
|
|
4
4
|
import { ScalprumComponent, ScalprumProvider } from '@scalprum/react-core';
|
|
5
5
|
import InsightsTable from './Components/InsightsTable';
|
|
6
|
-
import {
|
|
6
|
+
import { useIopConfig } from '../common/Hooks/ConfigHooks';
|
|
7
7
|
import { foremanUrl } from '../ForemanRhCloudHelpers';
|
|
8
8
|
import RemediationModal from './Components/RemediationModal';
|
|
9
9
|
import {
|
|
@@ -85,9 +85,9 @@ const IopRecommendationsPageWrapped = props => (
|
|
|
85
85
|
);
|
|
86
86
|
|
|
87
87
|
const RecommendationsPage = props => {
|
|
88
|
-
const
|
|
88
|
+
const isIop = useIopConfig();
|
|
89
89
|
|
|
90
|
-
return
|
|
90
|
+
return isIop ? (
|
|
91
91
|
<IopRecommendationsPageWrapped {...props} />
|
|
92
92
|
) : (
|
|
93
93
|
<InsightsCloudSync {...props} />
|
|
@@ -2,6 +2,16 @@ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
|
2
2
|
import { noop } from 'foremanReact/common/helpers';
|
|
3
3
|
import InsightsCloudSync from './InsightsCloudSync';
|
|
4
4
|
|
|
5
|
+
jest.mock('foremanReact/Root/Context/ForemanContext', () => ({
|
|
6
|
+
useForemanContext: () => ({
|
|
7
|
+
metadata: {
|
|
8
|
+
foreman_rh_cloud: {
|
|
9
|
+
iop: true,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
}),
|
|
13
|
+
}));
|
|
14
|
+
|
|
5
15
|
const fixtures = {
|
|
6
16
|
render: {
|
|
7
17
|
status: 'RESOLVED',
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
selectHits,
|
|
22
22
|
} from '../InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors';
|
|
23
23
|
import { redHatAdvisorSystems } from '../InsightsCloudSync/InsightsCloudSyncHelpers';
|
|
24
|
-
import {
|
|
24
|
+
import { useIopConfig } from '../common/Hooks/ConfigHooks';
|
|
25
25
|
import { generateRuleUrl } from '../InsightsCloudSync/InsightsCloudSync';
|
|
26
26
|
import { providerOptions } from '../common/ScalprumModule/ScalprumContext';
|
|
27
27
|
|
|
@@ -30,7 +30,7 @@ const NewHostDetailsTab = ({ hostName, router }) => {
|
|
|
30
30
|
const dispatch = useDispatch();
|
|
31
31
|
const query = useSelector(selectSearch);
|
|
32
32
|
const hits = useSelector(selectHits);
|
|
33
|
-
const
|
|
33
|
+
const isIop = useIopConfig();
|
|
34
34
|
|
|
35
35
|
useEffect(() => () => router.replace({ search: null }), [router]);
|
|
36
36
|
|
|
@@ -46,7 +46,7 @@ const NewHostDetailsTab = ({ hostName, router }) => {
|
|
|
46
46
|
</DropdownItem>,
|
|
47
47
|
];
|
|
48
48
|
|
|
49
|
-
if (hits.length && !
|
|
49
|
+
if (hits.length && !isIop) {
|
|
50
50
|
const { host_uuid: uuid } = hits[0];
|
|
51
51
|
dropdownItems.push(
|
|
52
52
|
<DropdownItem key="insights-advisor-link" ouiaId="insights-advisor-link">
|
|
@@ -131,9 +131,9 @@ const IopInsightsTabWrapped = props => (
|
|
|
131
131
|
);
|
|
132
132
|
|
|
133
133
|
const InsightsTab = props => {
|
|
134
|
-
const
|
|
134
|
+
const isIop = useIopConfig();
|
|
135
135
|
|
|
136
|
-
return
|
|
136
|
+
return isIop ? (
|
|
137
137
|
<IopInsightsTabWrapped {...props} />
|
|
138
138
|
) : (
|
|
139
139
|
<NewHostDetailsTab {...props} />
|
|
@@ -4,13 +4,13 @@ import { UnknownIcon } from '@patternfly/react-icons';
|
|
|
4
4
|
import { Link } from 'react-router-dom';
|
|
5
5
|
import { useAPI } from 'foremanReact/common/hooks/API/APIHooks';
|
|
6
6
|
import { insightsCloudUrl } from '../InsightsCloudSync/InsightsCloudSyncHelpers';
|
|
7
|
-
import {
|
|
7
|
+
import { useIopConfig } from '../common/Hooks/ConfigHooks';
|
|
8
8
|
|
|
9
9
|
const vulnerabilityApiPath = path =>
|
|
10
10
|
insightsCloudUrl(`api/vulnerability/v1/${path}`);
|
|
11
11
|
|
|
12
12
|
export const CVECountCell = ({ hostDetails }) => {
|
|
13
|
-
const isIopEnabled =
|
|
13
|
+
const isIopEnabled = useIopConfig();
|
|
14
14
|
|
|
15
15
|
// eslint-disable-next-line camelcase
|
|
16
16
|
const uuid = hostDetails?.subscription_facet_attributes?.uuid;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { screen } from '@testing-library/react';
|
|
3
|
+
import { rtlHelpers } from 'foremanReact/common/rtlTestHelpers';
|
|
3
4
|
import { API } from 'foremanReact/redux/API';
|
|
4
5
|
import { CVECountCell } from '../CVECountCell';
|
|
5
|
-
import * as ConfigHooks from '../../common/Hooks/ConfigHooks';
|
|
6
6
|
|
|
7
7
|
jest.mock('foremanReact/redux/API');
|
|
8
8
|
jest.mock('../../common/Hooks/ConfigHooks');
|
|
9
9
|
|
|
10
|
+
const { renderWithStore } = rtlHelpers;
|
|
11
|
+
|
|
10
12
|
API.get.mockImplementation(async () => ({
|
|
11
13
|
data: [
|
|
12
14
|
{
|
|
@@ -18,17 +20,13 @@ API.get.mockImplementation(async () => ({
|
|
|
18
20
|
}));
|
|
19
21
|
|
|
20
22
|
const hostDetailsMock = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
name: 'test-host.example.com',
|
|
24
|
+
subscription_facet_attributes: {
|
|
25
|
+
uuid: 'test-uuid-123',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
26
28
|
|
|
27
29
|
describe('CVECountCell', () => {
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
ConfigHooks.useAdvisorEngineConfig.mockReturnValue(true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
30
|
afterEach(() => {
|
|
33
31
|
jest.clearAllMocks();
|
|
34
32
|
});
|
|
@@ -40,35 +38,92 @@ describe('CVECountCell', () => {
|
|
|
40
38
|
uuid: null, // no subscription
|
|
41
39
|
},
|
|
42
40
|
};
|
|
43
|
-
|
|
41
|
+
renderWithStore(<CVECountCell hostDetails={hostDetailsMockIoP} />, {
|
|
42
|
+
router: {
|
|
43
|
+
location: {
|
|
44
|
+
pathname: '/',
|
|
45
|
+
search: '',
|
|
46
|
+
hash: '',
|
|
47
|
+
query: {},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
API: {
|
|
51
|
+
ADVISOR_ENGINE_CONFIG: {
|
|
52
|
+
response: { use_iop_mode: true },
|
|
53
|
+
status: 'RESOLVED',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
44
57
|
expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
|
|
45
58
|
});
|
|
46
59
|
|
|
47
60
|
it('renders UnknownIcon when IoP is not enabled', () => {
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
renderWithStore(<CVECountCell hostDetails={hostDetailsMock} />, {
|
|
62
|
+
router: {
|
|
63
|
+
location: {
|
|
64
|
+
pathname: '/',
|
|
65
|
+
search: '',
|
|
66
|
+
hash: '',
|
|
67
|
+
query: {},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
API: {
|
|
71
|
+
ADVISOR_ENGINE_CONFIG: {
|
|
72
|
+
response: { use_iop_mode: false },
|
|
73
|
+
status: 'RESOLVED',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
});
|
|
50
77
|
expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
|
|
51
|
-
expect(ConfigHooks.useAdvisorEngineConfig).toHaveBeenCalled();
|
|
52
78
|
});
|
|
53
79
|
|
|
54
80
|
it('renders UnknownIcon when IoP is enabled but CVE API call fails', () => {
|
|
55
|
-
// Mock successful IoP config
|
|
56
|
-
ConfigHooks.useAdvisorEngineConfig.mockReturnValue(true);
|
|
57
81
|
// Mock CVE API failure - override the global mock for this test
|
|
58
82
|
API.get.mockImplementationOnce(async () => {
|
|
59
83
|
throw new Error('CVE API call failed');
|
|
60
84
|
});
|
|
61
85
|
|
|
62
|
-
|
|
86
|
+
renderWithStore(<CVECountCell hostDetails={hostDetailsMock} />, {
|
|
87
|
+
router: {
|
|
88
|
+
location: {
|
|
89
|
+
pathname: '/',
|
|
90
|
+
search: '',
|
|
91
|
+
hash: '',
|
|
92
|
+
query: {},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
API: {
|
|
96
|
+
ADVISOR_ENGINE_CONFIG: {
|
|
97
|
+
response: { use_iop_mode: true },
|
|
98
|
+
status: 'RESOLVED',
|
|
99
|
+
},
|
|
100
|
+
// Mock the API failure state for the CVE endpoint
|
|
101
|
+
[`HOST_CVE_COUNT_${hostDetailsMock.subscription_facet_attributes.uuid}`]: {
|
|
102
|
+
status: 'ERROR',
|
|
103
|
+
error: 'CVE API call failed',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
});
|
|
63
107
|
// Should render UnknownIcon when CVE API fails
|
|
64
108
|
expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
|
|
65
|
-
expect(ConfigHooks.useAdvisorEngineConfig).toHaveBeenCalled();
|
|
66
109
|
});
|
|
67
110
|
|
|
68
111
|
it('renders UnknownIcon when IoP is undefined (API call pending)', () => {
|
|
69
|
-
|
|
70
|
-
|
|
112
|
+
renderWithStore(<CVECountCell hostDetails={hostDetailsMock} />, {
|
|
113
|
+
router: {
|
|
114
|
+
location: {
|
|
115
|
+
pathname: '/',
|
|
116
|
+
search: '',
|
|
117
|
+
hash: '',
|
|
118
|
+
query: {},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
API: {
|
|
122
|
+
ADVISOR_ENGINE_CONFIG: {
|
|
123
|
+
status: 'PENDING',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
});
|
|
71
127
|
expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
|
|
72
|
-
expect(ConfigHooks.useAdvisorEngineConfig).toHaveBeenCalled();
|
|
73
128
|
});
|
|
74
129
|
});
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
ADVISOR_ENGINE_CONFIG_KEY,
|
|
4
|
-
ADVISOR_ENGINE_CONFIG_PATH,
|
|
5
|
-
} from '../../InsightsCloudSync/Components/InsightsTable/InsightsTableConstants';
|
|
6
|
-
|
|
7
|
-
export const useAdvisorEngineConfig = () => {
|
|
8
|
-
const { response: advisorEngineConfig } = useAPI(
|
|
9
|
-
'get',
|
|
10
|
-
ADVISOR_ENGINE_CONFIG_PATH,
|
|
11
|
-
{
|
|
12
|
-
key: ADVISOR_ENGINE_CONFIG_KEY,
|
|
13
|
-
}
|
|
14
|
-
);
|
|
1
|
+
import { useForemanContext } from 'foremanReact/Root/Context/ForemanContext';
|
|
15
2
|
|
|
3
|
+
export const useIopConfig = () =>
|
|
16
4
|
// eslint-disable-next-line camelcase
|
|
17
|
-
|
|
18
|
-
};
|
|
5
|
+
useForemanContext().metadata?.foreman_rh_cloud?.iop;
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman_rh_cloud
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 12.2.
|
|
4
|
+
version: 12.2.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Foreman Red Hat Cloud team
|
|
@@ -196,7 +196,7 @@ files:
|
|
|
196
196
|
- lib/foreman_inventory_upload/async/remove_insights_hosts_job.rb
|
|
197
197
|
- lib/foreman_inventory_upload/async/shell_process.rb
|
|
198
198
|
- lib/foreman_inventory_upload/async/single_host_report_job.rb
|
|
199
|
-
- lib/foreman_inventory_upload/async/
|
|
199
|
+
- lib/foreman_inventory_upload/async/upload_report_direct_job.rb
|
|
200
200
|
- lib/foreman_inventory_upload/generators/archived_report.rb
|
|
201
201
|
- lib/foreman_inventory_upload/generators/fact_helpers.rb
|
|
202
202
|
- lib/foreman_inventory_upload/generators/json_stream.rb
|
|
@@ -205,7 +205,6 @@ files:
|
|
|
205
205
|
- lib/foreman_inventory_upload/generators/slice.rb
|
|
206
206
|
- lib/foreman_inventory_upload/generators/tags.rb
|
|
207
207
|
- lib/foreman_inventory_upload/notifications/manifest_import_success_notification_override.rb
|
|
208
|
-
- lib/foreman_inventory_upload/scripts/uploader.sh.erb
|
|
209
208
|
- lib/foreman_rh_cloud.rb
|
|
210
209
|
- lib/foreman_rh_cloud/async/exponential_backoff.rb
|
|
211
210
|
- lib/foreman_rh_cloud/engine.rb
|
|
@@ -278,16 +277,18 @@ files:
|
|
|
278
277
|
- test/jobs/queue_for_upload_job_test.rb
|
|
279
278
|
- test/jobs/remove_insights_hosts_job_test.rb
|
|
280
279
|
- test/jobs/single_host_report_job_test.rb
|
|
281
|
-
- test/jobs/
|
|
280
|
+
- test/jobs/upload_report_direct_job_test.rb
|
|
282
281
|
- test/models/insights_client_report_status_test.rb
|
|
283
282
|
- test/test_plugin_helper.rb
|
|
284
283
|
- test/unit/archived_report_generator_test.rb
|
|
285
284
|
- test/unit/fact_helpers_test.rb
|
|
285
|
+
- test/unit/foreman_rh_cloud_iop_metadata_test.rb
|
|
286
286
|
- test/unit/foreman_rh_cloud_self_host_test.rb
|
|
287
287
|
- test/unit/insights_facet_test.rb
|
|
288
288
|
- test/unit/lib/foreman_rh_cloud/registration_manager_extensions_test.rb
|
|
289
289
|
- test/unit/metadata_generator_test.rb
|
|
290
290
|
- test/unit/playbook_progress_generator_test.rb
|
|
291
|
+
- test/unit/rh_cloud_host_test.rb
|
|
291
292
|
- test/unit/rh_cloud_http_proxy_test.rb
|
|
292
293
|
- test/unit/rh_cloud_permissions_test.rb
|
|
293
294
|
- test/unit/services/foreman_rh_cloud/branch_info_test.rb
|
|
@@ -441,7 +442,6 @@ files:
|
|
|
441
442
|
- webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js
|
|
442
443
|
- webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js
|
|
443
444
|
- webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageTitle.test.js
|
|
444
|
-
- webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap
|
|
445
445
|
- webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap
|
|
446
446
|
- webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorActions.js
|
|
447
447
|
- webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
|
|
@@ -586,7 +586,6 @@ files:
|
|
|
586
586
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js
|
|
587
587
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
|
|
588
588
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableSelectors.test.js
|
|
589
|
-
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap
|
|
590
589
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap
|
|
591
590
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap
|
|
592
591
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js
|
|
@@ -646,7 +645,6 @@ files:
|
|
|
646
645
|
- webpack/__mocks__/foremanReact/common/I18n.js
|
|
647
646
|
- webpack/__mocks__/foremanReact/common/MountingService.js
|
|
648
647
|
- webpack/__mocks__/foremanReact/common/helpers.js
|
|
649
|
-
- webpack/__mocks__/foremanReact/common/hooks/API/APIHooks.js
|
|
650
648
|
- webpack/__mocks__/foremanReact/components/ConfirmModal/index.js
|
|
651
649
|
- webpack/__mocks__/foremanReact/components/Head.js
|
|
652
650
|
- webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js
|
|
@@ -703,7 +701,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
703
701
|
- !ruby/object:Gem::Version
|
|
704
702
|
version: '0'
|
|
705
703
|
requirements: []
|
|
706
|
-
rubygems_version:
|
|
704
|
+
rubygems_version: 4.0.3
|
|
707
705
|
specification_version: 4
|
|
708
706
|
summary: Summary of ForemanRhCloud.
|
|
709
707
|
test_files:
|
|
@@ -738,16 +736,18 @@ test_files:
|
|
|
738
736
|
- test/jobs/queue_for_upload_job_test.rb
|
|
739
737
|
- test/jobs/remove_insights_hosts_job_test.rb
|
|
740
738
|
- test/jobs/single_host_report_job_test.rb
|
|
741
|
-
- test/jobs/
|
|
739
|
+
- test/jobs/upload_report_direct_job_test.rb
|
|
742
740
|
- test/models/insights_client_report_status_test.rb
|
|
743
741
|
- test/test_plugin_helper.rb
|
|
744
742
|
- test/unit/archived_report_generator_test.rb
|
|
745
743
|
- test/unit/fact_helpers_test.rb
|
|
744
|
+
- test/unit/foreman_rh_cloud_iop_metadata_test.rb
|
|
746
745
|
- test/unit/foreman_rh_cloud_self_host_test.rb
|
|
747
746
|
- test/unit/insights_facet_test.rb
|
|
748
747
|
- test/unit/lib/foreman_rh_cloud/registration_manager_extensions_test.rb
|
|
749
748
|
- test/unit/metadata_generator_test.rb
|
|
750
749
|
- test/unit/playbook_progress_generator_test.rb
|
|
750
|
+
- test/unit/rh_cloud_host_test.rb
|
|
751
751
|
- test/unit/rh_cloud_http_proxy_test.rb
|
|
752
752
|
- test/unit/rh_cloud_permissions_test.rb
|
|
753
753
|
- test/unit/services/foreman_rh_cloud/branch_info_test.rb
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
require 'tempfile'
|
|
2
|
-
|
|
3
|
-
module ForemanInventoryUpload
|
|
4
|
-
module Async
|
|
5
|
-
class UploadReportJob < ShellProcess
|
|
6
|
-
def self.output_label(label)
|
|
7
|
-
"upload_for_#{label}"
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def plan(filename, organization_id)
|
|
11
|
-
label = UploadReportJob.output_label(organization_id)
|
|
12
|
-
super(label, filename: filename, organization_id: organization_id)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def try_execute
|
|
16
|
-
if content_disconnected?
|
|
17
|
-
progress_output do |progress_output|
|
|
18
|
-
progress_output.write_line("Report was not moved and upload was canceled because connection to Insights is not enabled. Report location: #{filename}.")
|
|
19
|
-
progress_output.status = "Task aborted, exit 1"
|
|
20
|
-
done!
|
|
21
|
-
end
|
|
22
|
-
return
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
unless organization.owner_details&.fetch('upstreamConsumer')&.fetch('idCert')
|
|
26
|
-
logger.info("Skipping organization '#{organization}', no candlepin certificate defined.")
|
|
27
|
-
progress_output do |progress_output|
|
|
28
|
-
progress_output.write_line("Skipping organization #{organization}, no candlepin certificate defined.")
|
|
29
|
-
progress_output.status = "Task aborted, exit 1"
|
|
30
|
-
done!
|
|
31
|
-
end
|
|
32
|
-
return
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
Tempfile.create([organization.name, '.pem']) do |cer_file|
|
|
36
|
-
cer_file.write(certificate[:cert])
|
|
37
|
-
cer_file.write(certificate[:key])
|
|
38
|
-
cer_file.flush
|
|
39
|
-
@cer_path = cer_file.path
|
|
40
|
-
super
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def command
|
|
45
|
-
['/bin/bash', File.join(File.dirname(filename), ForemanInventoryUpload.upload_script_file)]
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def env
|
|
49
|
-
env_vars = super.merge(
|
|
50
|
-
'FILES' => filename,
|
|
51
|
-
'CER_PATH' => @cer_path,
|
|
52
|
-
'ORG_ID' => organization.label
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
http_proxy_string = ForemanRhCloud.http_proxy_string
|
|
56
|
-
if http_proxy_string
|
|
57
|
-
env_vars['http_proxy'] = http_proxy_string
|
|
58
|
-
env_vars['https_proxy'] = http_proxy_string
|
|
59
|
-
end
|
|
60
|
-
env_vars
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def certificate
|
|
64
|
-
ForemanRhCloud.with_iop_smart_proxy? ? foreman_certificate : manifest_certificate
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def manifest_certificate
|
|
68
|
-
@manifest_certificate ||= begin
|
|
69
|
-
candlepin_id_certificate = organization.owner_details['upstreamConsumer']['idCert']
|
|
70
|
-
{
|
|
71
|
-
cert: candlepin_id_certificate['cert'],
|
|
72
|
-
key: candlepin_id_certificate['key'],
|
|
73
|
-
}
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def foreman_certificate
|
|
78
|
-
@foreman_certificate ||= {
|
|
79
|
-
cert: File.read(Setting[:ssl_certificate]),
|
|
80
|
-
key: File.read(Setting[:ssl_priv_key]),
|
|
81
|
-
}
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def filename
|
|
85
|
-
input[:filename]
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def organization
|
|
89
|
-
@organization ||= Organization.find(input[:organization_id])
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def content_disconnected?
|
|
93
|
-
!Setting[:subscription_connection_enabled]
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#! /bin/bash
|
|
2
|
-
|
|
3
|
-
DEST=<%= @upload_url %>
|
|
4
|
-
RH_USERNAME=<%= @rh_username %>
|
|
5
|
-
|
|
6
|
-
if [ -z "$FILES" ]
|
|
7
|
-
then
|
|
8
|
-
FILES=./*.tar.gz
|
|
9
|
-
fi
|
|
10
|
-
|
|
11
|
-
if [ -n "$CER_PATH" ]
|
|
12
|
-
then
|
|
13
|
-
AUTH_KEY="--cert"
|
|
14
|
-
AUTH_VAL="$CER_PATH"
|
|
15
|
-
else
|
|
16
|
-
if [ -z "$RH_USERNAME" ]
|
|
17
|
-
then
|
|
18
|
-
IFS= read -rp "Enter username: " RH_USERNAME
|
|
19
|
-
fi
|
|
20
|
-
|
|
21
|
-
if [ -z "$RH_PASSWORD" ]
|
|
22
|
-
then
|
|
23
|
-
IFS= read -rsp "Enter password: " RH_PASSWORD
|
|
24
|
-
fi
|
|
25
|
-
|
|
26
|
-
AUTH_KEY="-u"
|
|
27
|
-
AUTH_VAL="\"$RH_USERNAME\":\"$RH_PASSWORD\""
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
ORG_HEADER=()
|
|
31
|
-
if [ -n "$ORG_ID" ]
|
|
32
|
-
then
|
|
33
|
-
ORG_HEADER=("-H" "X-Org-Id: $ORG_ID")
|
|
34
|
-
fi
|
|
35
|
-
|
|
36
|
-
# /tmp/a b/x.pem
|
|
37
|
-
# curl --cert /tmp/a\ b/x.pem
|
|
38
|
-
|
|
39
|
-
SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE:-0}")")
|
|
40
|
-
DONE_DIR="$SCRIPT_DIR/done/"
|
|
41
|
-
mkdir -p $DONE_DIR
|
|
42
|
-
|
|
43
|
-
for f in $FILES
|
|
44
|
-
do
|
|
45
|
-
curl -k -vvv -# --fail -F "file=@$f;type=application/vnd.redhat.qpc.tar+tgz" $DEST "$AUTH_KEY" "$AUTH_VAL" "${ORG_HEADER[@]}"
|
|
46
|
-
status=$?
|
|
47
|
-
if [ $status -eq 0 ]; then
|
|
48
|
-
mv $f $DONE_DIR
|
|
49
|
-
echo "Done: $f"
|
|
50
|
-
fi
|
|
51
|
-
done
|
|
52
|
-
echo "Uploaded files moved to done/ folder"
|
|
53
|
-
|
|
54
|
-
# return the error code from the curl command
|
|
55
|
-
exit $status
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
require 'test_plugin_helper'
|
|
2
|
-
require 'foreman_tasks/test_helpers'
|
|
3
|
-
|
|
4
|
-
class UploadReportJobTest < ActiveSupport::TestCase
|
|
5
|
-
include Dynflow::Testing::Factories
|
|
6
|
-
|
|
7
|
-
test 'returns aborted state when disconnected' do
|
|
8
|
-
organization = FactoryBot.create(:organization)
|
|
9
|
-
Organization.any_instance.stubs(:owner_details).returns(
|
|
10
|
-
'upstreamConsumer' => {
|
|
11
|
-
'idCert' => 'TEST_CERT',
|
|
12
|
-
}
|
|
13
|
-
)
|
|
14
|
-
ForemanInventoryUpload::Async::UploadReportJob.any_instance.expects(:content_disconnected?).returns(true)
|
|
15
|
-
|
|
16
|
-
action = create_and_plan_action(ForemanInventoryUpload::Async::UploadReportJob, '', organization.id)
|
|
17
|
-
run_action(action)
|
|
18
|
-
|
|
19
|
-
label = ForemanInventoryUpload::Async::UploadReportJob.output_label(organization.id)
|
|
20
|
-
progress_output = ForemanInventoryUpload::Async::ProgressOutput.get(label)
|
|
21
|
-
assert_match(/upload was canceled because connection to Insights is not enabled/, progress_output.full_output)
|
|
22
|
-
assert_match(/Report location:/, progress_output.full_output)
|
|
23
|
-
assert_match(/exit 1/, progress_output.status)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
test 'returns aborted state when no certificate defined on organization' do
|
|
27
|
-
organization = FactoryBot.create(:organization)
|
|
28
|
-
Organization.any_instance.expects(:owner_details).returns(nil)
|
|
29
|
-
|
|
30
|
-
action = create_and_plan_action(ForemanInventoryUpload::Async::UploadReportJob, '', organization.id)
|
|
31
|
-
run_action(action)
|
|
32
|
-
|
|
33
|
-
label = ForemanInventoryUpload::Async::UploadReportJob.output_label(organization.id)
|
|
34
|
-
progress_output = ForemanInventoryUpload::Async::ProgressOutput.get(label)
|
|
35
|
-
assert_match(/Skipping organization/, progress_output.full_output)
|
|
36
|
-
assert_match(/exit 1/, progress_output.status)
|
|
37
|
-
end
|
|
38
|
-
end
|