foreman_rh_cloud 12.2.9 → 12.2.11

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_rh_cloud/locale/fr/foreman_rh_cloud.js +47 -26
  3. data/app/assets/javascripts/foreman_rh_cloud/locale/ja/foreman_rh_cloud.js +46 -25
  4. data/app/assets/javascripts/foreman_rh_cloud/locale/ka/foreman_rh_cloud.js +32 -11
  5. data/app/assets/javascripts/foreman_rh_cloud/locale/ko/foreman_rh_cloud.js +46 -25
  6. data/app/assets/javascripts/foreman_rh_cloud/locale/zh_CN/foreman_rh_cloud.js +46 -25
  7. data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +2 -3
  8. data/app/services/foreman_rh_cloud/cert_auth.rb +13 -3
  9. data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +3 -1
  10. data/app/services/foreman_rh_cloud/tags_auth.rb +2 -1
  11. data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +29 -0
  12. data/lib/foreman_inventory_upload/async/generate_host_report.rb +20 -0
  13. data/lib/foreman_inventory_upload/async/generate_report_job.rb +1 -1
  14. data/lib/foreman_inventory_upload/async/host_inventory_report_job.rb +39 -0
  15. data/lib/foreman_inventory_upload/async/single_host_report_job.rb +20 -0
  16. data/lib/foreman_inventory_upload/async/upload_report_job.rb +2 -1
  17. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +2 -2
  18. data/lib/foreman_inventory_upload/generators/slice.rb +3 -3
  19. data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +7 -1
  20. data/lib/foreman_rh_cloud/plugin.rb +9 -9
  21. data/lib/foreman_rh_cloud/version.rb +1 -1
  22. data/lib/tasks/rh_cloud_inventory.rake +14 -32
  23. data/locale/foreman_rh_cloud.pot +55 -18
  24. data/locale/fr/foreman_rh_cloud.po +48 -27
  25. data/locale/ja/foreman_rh_cloud.po +47 -26
  26. data/locale/ka/foreman_rh_cloud.po +32 -11
  27. data/locale/ko/foreman_rh_cloud.po +47 -26
  28. data/locale/zh_CN/foreman_rh_cloud.po +47 -26
  29. data/package.json +1 -1
  30. data/test/unit/fact_helpers_test.rb +47 -0
  31. data/test/unit/slice_generator_test.rb +57 -0
  32. data/webpack/InsightsHostDetailsTab/InsightsTotalRiskChart.js +57 -21
  33. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTotalRiskChart.test.js +194 -0
  34. data/webpack/InsightsVulnerabilityHostIndexExtensions/CVECountCell.js +8 -2
  35. data/webpack/InsightsVulnerabilityHostIndexExtensions/__tests__/CVECountCell.test.js +48 -2
  36. metadata +6 -2
  37. data/app/services/foreman_rh_cloud/gateway_request.rb +0 -26
@@ -3,25 +3,31 @@ import PropTypes from 'prop-types';
3
3
  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
-
7
6
  import { insightsCloudUrl } from '../InsightsCloudSync/InsightsCloudSyncHelpers';
7
+ import { useAdvisorEngineConfig } 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 = useAdvisorEngineConfig();
14
+
13
15
  // eslint-disable-next-line camelcase
14
16
  const uuid = hostDetails?.subscription_facet_attributes?.uuid;
15
17
 
16
18
  const key = `HOST_CVE_COUNT_${uuid}`;
17
19
  const response = useAPI(
18
- uuid ? 'get' : null,
20
+ isIopEnabled && uuid ? 'get' : null,
19
21
  vulnerabilityApiPath(`systems?uuid=${uuid}`),
20
22
  {
21
23
  key,
22
24
  }
23
25
  );
24
26
 
27
+ if (!isIopEnabled) {
28
+ return <UnknownIcon />;
29
+ }
30
+
25
31
  if (uuid === undefined) {
26
32
  return <UnknownIcon />;
27
33
  }
@@ -2,8 +2,11 @@ import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import { API } from 'foremanReact/redux/API';
4
4
  import { CVECountCell } from '../CVECountCell';
5
+ import * as ConfigHooks from '../../common/Hooks/ConfigHooks';
5
6
 
6
7
  jest.mock('foremanReact/redux/API');
8
+ jest.mock('../../common/Hooks/ConfigHooks');
9
+
7
10
  API.get.mockImplementation(async () => ({
8
11
  data: [
9
12
  {
@@ -14,15 +17,58 @@ API.get.mockImplementation(async () => ({
14
17
  ],
15
18
  }));
16
19
 
20
+ const hostDetailsMock = {
21
+ name: 'test-host.example.com',
22
+ subscription_facet_attributes: {
23
+ uuid: 'test-uuid-123',
24
+ },
25
+ };
26
+
17
27
  describe('CVECountCell', () => {
18
- it('renders an empty cves count column', () => {
19
- const hostDetailsMock = {
28
+ beforeEach(() => {
29
+ ConfigHooks.useAdvisorEngineConfig.mockReturnValue(true);
30
+ });
31
+
32
+ afterEach(() => {
33
+ jest.clearAllMocks();
34
+ });
35
+
36
+ it('renders an empty cves count column when no subscription UUID', () => {
37
+ const hostDetailsMockIoP = {
20
38
  name: 'test-host.example.com',
21
39
  subscription_facet_attributes: {
22
40
  uuid: null, // no subscription
23
41
  },
24
42
  };
43
+ render(<CVECountCell hostDetails={hostDetailsMockIoP} />);
44
+ expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
45
+ });
46
+
47
+ it('renders UnknownIcon when IoP is not enabled', () => {
48
+ ConfigHooks.useAdvisorEngineConfig.mockReturnValue(false);
49
+ render(<CVECountCell hostDetails={hostDetailsMock} />);
50
+ expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
51
+ expect(ConfigHooks.useAdvisorEngineConfig).toHaveBeenCalled();
52
+ });
53
+
54
+ it('renders UnknownIcon when IoP is enabled but CVE API call fails', () => {
55
+ // Mock successful IoP config
56
+ ConfigHooks.useAdvisorEngineConfig.mockReturnValue(true);
57
+ // Mock CVE API failure - override the global mock for this test
58
+ API.get.mockImplementationOnce(async () => {
59
+ throw new Error('CVE API call failed');
60
+ });
61
+
62
+ render(<CVECountCell hostDetails={hostDetailsMock} />);
63
+ // Should render UnknownIcon when CVE API fails
64
+ expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
65
+ expect(ConfigHooks.useAdvisorEngineConfig).toHaveBeenCalled();
66
+ });
67
+
68
+ it('renders UnknownIcon when IoP is undefined (API call pending)', () => {
69
+ ConfigHooks.useAdvisorEngineConfig.mockReturnValue(undefined);
25
70
  render(<CVECountCell hostDetails={hostDetailsMock} />);
26
71
  expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
72
+ expect(ConfigHooks.useAdvisorEngineConfig).toHaveBeenCalled();
27
73
  });
28
74
  });
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.9
4
+ version: 12.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
@@ -139,7 +139,6 @@ files:
139
139
  - app/services/foreman_rh_cloud/cloud_presence.rb
140
140
  - app/services/foreman_rh_cloud/cloud_request.rb
141
141
  - app/services/foreman_rh_cloud/cloud_request_forwarder.rb
142
- - app/services/foreman_rh_cloud/gateway_request.rb
143
142
  - app/services/foreman_rh_cloud/hit_remediations_retriever.rb
144
143
  - app/services/foreman_rh_cloud/hits_uploader.rb
145
144
  - app/services/foreman_rh_cloud/insights_api_forwarder.rb
@@ -185,13 +184,17 @@ files:
185
184
  - db/seeds.d/50_job_templates.rb
186
185
  - lib/foreman_inventory_upload.rb
187
186
  - lib/foreman_inventory_upload/async/async_helpers.rb
187
+ - lib/foreman_inventory_upload/async/create_missing_insights_facets.rb
188
188
  - lib/foreman_inventory_upload/async/delayed_start.rb
189
189
  - lib/foreman_inventory_upload/async/generate_all_reports_job.rb
190
+ - lib/foreman_inventory_upload/async/generate_host_report.rb
190
191
  - lib/foreman_inventory_upload/async/generate_report_job.rb
192
+ - lib/foreman_inventory_upload/async/host_inventory_report_job.rb
191
193
  - lib/foreman_inventory_upload/async/progress_output.rb
192
194
  - lib/foreman_inventory_upload/async/queue_for_upload_job.rb
193
195
  - lib/foreman_inventory_upload/async/remove_insights_hosts_job.rb
194
196
  - lib/foreman_inventory_upload/async/shell_process.rb
197
+ - lib/foreman_inventory_upload/async/single_host_report_job.rb
195
198
  - lib/foreman_inventory_upload/async/upload_report_job.rb
196
199
  - lib/foreman_inventory_upload/generators/archived_report.rb
197
200
  - lib/foreman_inventory_upload/generators/fact_helpers.rb
@@ -619,6 +622,7 @@ files:
619
622
  - webpack/InsightsHostDetailsTab/__tests__/InsightsTabIntegration.test.js
620
623
  - webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js
621
624
  - webpack/InsightsHostDetailsTab/__tests__/InsightsTabSelectors.test.js
625
+ - webpack/InsightsHostDetailsTab/__tests__/InsightsTotalRiskChart.test.js
622
626
  - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap
623
627
  - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap
624
628
  - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap
@@ -1,26 +0,0 @@
1
- module ForemanRhCloud
2
- module GatewayRequest
3
- extend ActiveSupport::Concern
4
-
5
- include CloudRequest
6
-
7
- def execute_cloud_request(params)
8
- certs = params.delete(:certs) || foreman_certificates
9
- final_params = {
10
- ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
11
- ssl_client_key: OpenSSL::PKey.read(certs[:key]),
12
- ssl_ca_file: Setting[:ssl_ca_file],
13
- verify_ssl: OpenSSL::SSL::VERIFY_PEER,
14
- }.deep_merge(params)
15
-
16
- super(final_params)
17
- end
18
-
19
- def foreman_certificates
20
- {
21
- cert: File.read(Setting[:ssl_certificate]),
22
- key: File.read(Setting[:ssl_priv_key]),
23
- }
24
- end
25
- end
26
- end