foreman_rh_cloud 13.0.8 → 13.0.9

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +1 -1
  3. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +1 -1
  4. data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +1 -23
  5. data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +200 -0
  6. data/lib/foreman_inventory_upload.rb +0 -4
  7. data/lib/foreman_rh_cloud/version.rb +1 -1
  8. data/lib/inventory_sync/async/inventory_hosts_sync.rb +0 -2
  9. data/package.json +1 -1
  10. data/test/controllers/accounts_controller_test.rb +1 -1
  11. data/test/controllers/uploads_controller_test.rb +1 -1
  12. data/test/jobs/queue_for_upload_job_test.rb +1 -12
  13. data/test/jobs/upload_report_direct_job_test.rb +399 -0
  14. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +1 -1
  15. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +4 -5
  16. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +4 -2
  17. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +9 -10
  18. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +4 -1
  19. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +24 -17
  20. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +178 -8
  21. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +3 -1
  22. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +69 -51
  23. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +11 -19
  24. data/webpack/InsightsVulnerabilityHostIndexExtensions/__tests__/CVECountCell.test.js +77 -22
  25. metadata +4 -8
  26. data/lib/foreman_inventory_upload/async/upload_report_job.rb +0 -97
  27. data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +0 -55
  28. data/test/jobs/upload_report_job_test.rb +0 -38
  29. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +0 -36
  30. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +0 -112
  31. data/webpack/__mocks__/foremanReact/common/hooks/API/APIHooks.js +0 -3
@@ -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
@@ -1,36 +0,0 @@
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
- `;
@@ -1,112 +0,0 @@
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
- `;
@@ -1,3 +0,0 @@
1
- export const useAPI = jest.fn(() => ({
2
- response: {},
3
- }));