foreman_rh_cloud 5.0.34 → 5.0.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/rh_cloud/cloud_request_controller.rb +1 -1
  3. data/app/controllers/foreman_inventory_upload/uploads_settings_controller.rb +0 -1
  4. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +7 -1
  5. data/app/controllers/insights_cloud/hits_controller.rb +0 -1
  6. data/app/controllers/insights_cloud/settings_controller.rb +0 -8
  7. data/app/controllers/insights_cloud/tasks_controller.rb +1 -1
  8. data/app/models/insights_facet.rb +1 -0
  9. data/app/models/insights_hit.rb +1 -0
  10. data/app/models/insights_rule.rb +2 -0
  11. data/app/models/setting/rh_cloud.rb +1 -2
  12. data/app/services/foreman_rh_cloud/cert_auth.rb +22 -0
  13. data/app/services/foreman_rh_cloud/cloud_connector.rb +10 -1
  14. data/app/services/foreman_rh_cloud/cloud_ping_service.rb +0 -27
  15. data/app/services/foreman_rh_cloud/hit_remediations_retriever.rb +4 -0
  16. data/app/services/foreman_rh_cloud/remediations_retriever.rb +7 -3
  17. data/app/services/foreman_rh_cloud/template_renderer_helper.rb +4 -3
  18. data/app/services/foreman_rh_cloud/url_remediations_retriever.rb +6 -1
  19. data/app/views/job_templates/cloud_connector.erb +6 -0
  20. data/app/views/job_templates/rh_cloud_download_playbook.erb +5 -1
  21. data/config/routes.rb +0 -1
  22. data/db/migrate/20220321000001_add_unique_to_insights_rules.foreman_rh_cloud.rb +13 -0
  23. data/lib/foreman_inventory_upload.rb +1 -1
  24. data/lib/foreman_rh_cloud/engine.rb +14 -11
  25. data/lib/foreman_rh_cloud/version.rb +1 -1
  26. data/lib/foreman_rh_cloud.rb +0 -5
  27. data/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +7 -1
  28. data/lib/insights_cloud/async/insights_full_sync.rb +40 -24
  29. data/lib/insights_cloud/async/insights_resolutions_sync.rb +10 -13
  30. data/lib/insights_cloud/async/insights_rules_sync.rb +27 -19
  31. data/lib/insights_cloud/async/insights_scheduled_sync.rb +5 -1
  32. data/lib/insights_cloud.rb +4 -8
  33. data/lib/inventory_sync/async/host_result.rb +3 -2
  34. data/lib/inventory_sync/async/inventory_full_sync.rb +3 -3
  35. data/lib/inventory_sync/async/inventory_hosts_sync.rb +11 -10
  36. data/lib/inventory_sync/async/inventory_self_host_sync.rb +5 -6
  37. data/lib/inventory_sync/async/query_inventory_job.rb +40 -12
  38. data/lib/tasks/insights.rake +1 -1
  39. data/package.json +1 -1
  40. data/test/controllers/insights_cloud/api/cloud_request_controller_test.rb +0 -1
  41. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +16 -0
  42. data/test/controllers/inventory_upload/cloud_status_controller_test.rb +0 -6
  43. data/test/jobs/insights_full_sync_test.rb +9 -5
  44. data/test/jobs/insights_resolutions_sync_test.rb +7 -1
  45. data/test/jobs/insights_rules_sync_test.rb +8 -4
  46. data/test/jobs/inventory_full_sync_test.rb +16 -5
  47. data/test/jobs/inventory_hosts_sync_test.rb +18 -4
  48. data/test/jobs/inventory_self_host_sync_test.rb +6 -1
  49. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +12 -8
  50. data/test/unit/services/foreman_rh_cloud/cloud_status_service_test.rb +1 -14
  51. data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +5 -1
  52. data/test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb +3 -1
  53. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsSelectors.js +0 -2
  54. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.js +1 -10
  55. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +3 -12
  56. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +1 -1
  57. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +0 -4
  58. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +0 -2
  59. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +0 -3
  60. data/webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js +16 -0
  61. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableSelectors.test.js +0 -2
  62. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap +0 -2
  63. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +0 -1
  64. data/webpack/InsightsCloudSync/InsightsCloudSync.js +1 -17
  65. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +0 -7
  66. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -4
  67. data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +0 -7
  68. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +0 -9
  69. data/webpack/InsightsCloudSync/index.js +1 -5
  70. metadata +11 -17
  71. data/app/services/foreman_rh_cloud/cloud_auth.rb +0 -44
  72. data/config/package-lock.json +0 -41822
  73. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.scss +0 -5
  74. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +0 -63
  75. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +0 -20
  76. data/webpack/InsightsCloudSync/Components/NoTokenEmptyState.js +0 -79
  77. data/webpack/InsightsCloudSync/Components/__tests__/NoTokenEmptyState.test.js +0 -19
  78. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +0 -225
@@ -6,18 +6,22 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
6
6
 
7
7
  setup do
8
8
  @forwarder = ::ForemanRhCloud::CloudRequestForwarder.new
9
+
10
+ ForemanRhCloud.stubs(:base_url).returns('https://cloud.example.com')
11
+ ForemanRhCloud.stubs(:cert_base_url).returns('https://cert.cloud.example.com')
12
+ ForemanRhCloud.stubs(:legacy_insights_url).returns('https://cert-api.access.example.com')
9
13
  end
10
14
 
11
15
  test 'should prepare correct cloud url' do
12
16
  paths = {
13
- "/redhat_access/r/insights/platform/module-update-router/v1/channel?module=insights-core" => "https://cert.cloud.redhat.com/api/module-update-router/v1/channel?module=insights-core",
14
- "/redhat_access/r/insights/v1/static/release/insights-core.egg" => "https://cert-api.access.redhat.com/r/insights/v1/static/release/insights-core.egg",
15
- "/redhat_access/r/insights/v1/static/uploader.v2.json" => "https://cert-api.access.redhat.com/r/insights/v1/static/uploader.v2.json",
16
- "/redhat_access/r/insights/v1/static/uploader.v2.json.asc" => "https://cert-api.access.redhat.com/r/insights/v1/static/uploader.v2.json.asc",
17
- "/redhat_access/r/insights/platform/inventory/v1/hosts" => "https://cert.cloud.redhat.com/api/inventory/v1/hosts",
18
- "/redhat_access/r/insights/platform/ingress/v1/upload" => "https://cert.cloud.redhat.com/api/ingress/v1/upload",
19
- "/redhat_access/r/insights/uploads/67200803-132b-474b-a6f9-37be74185df4" => "https://cert-api.access.redhat.com/r/insights/uploads/67200803-132b-474b-a6f9-37be74185df4",
20
- "/redhat_access/r/insights/" => "https://cert.cloud.redhat.com/api/apicast-tests/ping",
17
+ "/redhat_access/r/insights/platform/module-update-router/v1/channel?module=insights-core" => "https://cert.cloud.example.com/api/module-update-router/v1/channel?module=insights-core",
18
+ "/redhat_access/r/insights/v1/static/release/insights-core.egg" => "https://cert-api.access.example.com/r/insights/v1/static/release/insights-core.egg",
19
+ "/redhat_access/r/insights/v1/static/uploader.v2.json" => "https://cert-api.access.example.com/r/insights/v1/static/uploader.v2.json",
20
+ "/redhat_access/r/insights/v1/static/uploader.v2.json.asc" => "https://cert-api.access.example.com/r/insights/v1/static/uploader.v2.json.asc",
21
+ "/redhat_access/r/insights/platform/inventory/v1/hosts" => "https://cert.cloud.example.com/api/inventory/v1/hosts",
22
+ "/redhat_access/r/insights/platform/ingress/v1/upload" => "https://cert.cloud.example.com/api/ingress/v1/upload",
23
+ "/redhat_access/r/insights/uploads/67200803-132b-474b-a6f9-37be74185df4" => "https://cert-api.access.example.com/r/insights/uploads/67200803-132b-474b-a6f9-37be74185df4",
24
+ "/redhat_access/r/insights/" => "https://cert.cloud.example.com/api/apicast-tests/ping",
21
25
  }
22
26
 
23
27
  paths.each do |key, value|
@@ -9,10 +9,6 @@ class CloudStatusServiceTest < ActiveSupport::TestCase
9
9
  test 'generates ping response for each org' do
10
10
  organizations = FactoryBot.create_list(:organization, 2)
11
11
 
12
- ForemanRhCloud::CloudPingService::TokenPing.any_instance.expects(:execute_cloud_request).returns(
13
- RestClient::Response.new('TEST RESPONSE')
14
- )
15
-
16
12
  setup_certs_expectation do
17
13
  ForemanRhCloud::CloudPingService::CertPing.any_instance.expects(:candlepin_id_cert).with(organizations[0])
18
14
  end
@@ -33,22 +29,15 @@ class CloudStatusServiceTest < ActiveSupport::TestCase
33
29
  service = ForemanRhCloud::CloudPingService.new(organizations, nil)
34
30
  actual = service.ping
35
31
 
36
- assert actual[:token_auth][:success]
37
- assert_nil actual[:token_auth][:error]
38
32
  assert actual[:cert_auth][organizations[0]][:success]
39
33
  assert_nil actual[:cert_auth][organizations[0]][:error]
40
34
  assert actual[:cert_auth][organizations[1]][:success]
41
35
  assert_nil actual[:cert_auth][organizations[1]][:error]
42
36
  end
43
37
 
44
- test 'generates ping error response for org and token' do
38
+ test 'generates ping error response for org' do
45
39
  organizations = FactoryBot.create_list(:organization, 1)
46
40
 
47
- ForemanRhCloud::CloudPingService::TokenPing.any_instance.expects(:execute_cloud_request).raises(
48
- RuntimeError,
49
- 'TEST RESPONSE TOKEN'
50
- )
51
-
52
41
  setup_certs_expectation do
53
42
  ForemanRhCloud::CloudPingService::CertPing.any_instance.expects(:candlepin_id_cert).with(organizations[0])
54
43
  end
@@ -62,8 +51,6 @@ class CloudStatusServiceTest < ActiveSupport::TestCase
62
51
  service = ForemanRhCloud::CloudPingService.new(organizations, nil)
63
52
  actual = service.ping
64
53
 
65
- refute actual[:token_auth][:success]
66
- assert_match /TEST RESPONSE TOKEN/, actual[:token_auth][:error]
67
54
  refute actual[:cert_auth][organizations[0]][:success]
68
55
  assert_match /TEST RESPONSE ORG 0/, actual[:cert_auth][organizations[0]][:error]
69
56
  end
@@ -2,13 +2,17 @@ require 'test_plugin_helper'
2
2
 
3
3
  class TemplateRendererHelperTest < ActiveSupport::TestCase
4
4
  include ForemanRhCloud::TemplateRendererHelper
5
+ include MockCerts
5
6
 
6
7
  setup do
7
8
  response = mock('respone')
8
9
  response.stubs(:body).returns('TEST PLAYBOOK')
9
10
  ForemanRhCloud::RemediationsRetriever.any_instance.stubs(:query_playbook).returns(response)
10
11
  @host1 = FactoryBot.create(:host)
11
- Setting[:rh_cloud_token] = 'MOCK_TOKEN'
12
+
13
+ setup_certs_expectation do
14
+ ForemanRhCloud::RemediationsRetriever.any_instance.stubs(:candlepin_id_cert)
15
+ end
12
16
  end
13
17
 
14
18
  test 'Generates a playbook for hit and remediation' do
@@ -2,8 +2,8 @@ require 'test_plugin_helper'
2
2
 
3
3
  class UrlRemediationsRetrieverTest < ActiveSupport::TestCase
4
4
  test 'Calls the given url' do
5
- Setting[:rh_cloud_token] = 'TEST_TOKEN'
6
5
  retreiver = ForemanRhCloud::UrlRemediationsRetriever.new(
6
+ organization_id: FactoryBot.create(:organization).id,
7
7
  url: 'http://test.example.com',
8
8
  payload: 'TEST_PAYLOAD',
9
9
  headers: {
@@ -11,6 +11,8 @@ class UrlRemediationsRetrieverTest < ActiveSupport::TestCase
11
11
  }
12
12
  )
13
13
 
14
+ retreiver.stubs(:cert_auth_available?).returns(true)
15
+
14
16
  response = mock('response')
15
17
  response.stubs(:body).returns('TEST_RESPONSE')
16
18
  retreiver.expects(:execute_cloud_request).with do |params|
@@ -15,5 +15,3 @@ export const selectIpsObfuscationEnabled = state =>
15
15
 
16
16
  export const selectExcludePackages = state =>
17
17
  selectSettings(state).excludePackagesEnabled;
18
-
19
- export const selectCloudToken = state => selectSettings(state).cloudToken;
@@ -21,18 +21,16 @@ import { translate as __, sprintf } from 'foremanReact/common/I18n';
21
21
  import { STATUS } from 'foremanReact/constants';
22
22
  import { selectAPIStatus } from 'foremanReact/redux/API/APISelectors';
23
23
  import { inventoryUrl } from '../../../../ForemanInventoryHelpers';
24
- import './index.scss';
25
24
 
26
25
  export const API_KEY = 'CLOUD_PING';
27
26
 
28
27
  const CloudPingModal = ({ title, isOpen, toggle }) => {
29
28
  const [rows, setRows] = useState([]);
30
- const [tokenStatus, setTokenStatus] = useState({});
31
29
  const dispatch = useDispatch();
32
30
  const handleSuccess = useCallback(
33
31
  ({
34
32
  data: {
35
- ping: { cert_auth = [], token_auth = {} },
33
+ ping: { cert_auth = [] },
36
34
  },
37
35
  }) => {
38
36
  cert_auth.length &&
@@ -53,7 +51,6 @@ const CloudPingModal = ({ title, isOpen, toggle }) => {
53
51
  ],
54
52
  }))
55
53
  );
56
- setTokenStatus(token_auth);
57
54
  },
58
55
  [status]
59
56
  );
@@ -83,12 +80,6 @@ const CloudPingModal = ({ title, isOpen, toggle }) => {
83
80
  isOpen={isOpen}
84
81
  onClose={toggle}
85
82
  >
86
- <Card className="token-status">
87
- <CardTitle>
88
- <StatusIcon isPending={isPending} authStatus={tokenStatus} />{' '}
89
- {__('API token status')}
90
- </CardTitle>
91
- </Card>
92
83
  <Card className="certs-status">
93
84
  <CardTitle>{__('Organization status')}</CardTitle>
94
85
  <CardBody>
@@ -1,9 +1,8 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { Spinner, Button } from '@patternfly/react-core';
4
- import { ExclamationTriangleIcon, RedoIcon } from '@patternfly/react-icons';
4
+ import { RedoIcon } from '@patternfly/react-icons';
5
5
  import { STATUS } from 'foremanReact/constants';
6
- import SyncModal from './components/Modal';
7
6
  import { SYNC_BUTTON_TEXT } from '../../../../ForemanInventoryConstants';
8
7
 
9
8
  class SyncButton extends React.Component {
@@ -16,12 +15,11 @@ class SyncButton extends React.Component {
16
15
  };
17
16
 
18
17
  render() {
19
- const { cloudToken, handleSync, status } = this.props;
18
+ const { handleSync, status } = this.props;
20
19
 
21
- const handleClick = !cloudToken ? this.toggleModal : handleSync;
20
+ const handleClick = handleSync;
22
21
  return (
23
22
  <React.Fragment>
24
- <SyncModal show={this.state.showModal} toggleModal={this.toggleModal} />
25
23
  <Button
26
24
  className="sync_button"
27
25
  onClick={handleClick}
@@ -29,11 +27,6 @@ class SyncButton extends React.Component {
29
27
  isDisabled={status === STATUS.PENDING}
30
28
  variant="secondary"
31
29
  >
32
- {!cloudToken && (
33
- <span>
34
- <ExclamationTriangleIcon />{' '}
35
- </span>
36
- )}
37
30
  {status === STATUS.PENDING ? <Spinner size="sm" /> : <RedoIcon />}
38
31
  {SYNC_BUTTON_TEXT}
39
32
  </Button>
@@ -43,13 +36,11 @@ class SyncButton extends React.Component {
43
36
  }
44
37
 
45
38
  SyncButton.propTypes = {
46
- cloudToken: PropTypes.bool,
47
39
  handleSync: PropTypes.func.isRequired,
48
40
  status: PropTypes.string,
49
41
  };
50
42
 
51
43
  SyncButton.defaultProps = {
52
- cloudToken: false,
53
44
  status: null,
54
45
  };
55
46
 
@@ -4,7 +4,7 @@ import { noop } from 'foremanReact/common/helpers';
4
4
  import SyncButton from '../SyncButton';
5
5
 
6
6
  const fixtures = {
7
- 'render with Props': { cloudToken: true, handleSync: noop },
7
+ 'render with Props': { handleSync: noop },
8
8
  };
9
9
 
10
10
  describe('SyncButton', () => {
@@ -2,10 +2,6 @@
2
2
 
3
3
  exports[`SyncButton rendering render with Props 1`] = `
4
4
  <Fragment>
5
- <SyncModal
6
- show={false}
7
- toggleModal={[Function]}
8
- />
9
5
  <Button
10
6
  className="sync_button"
11
7
  isDisabled={false}
@@ -3,12 +3,10 @@ import { connect } from 'react-redux';
3
3
 
4
4
  import * as actions from './SyncButtonActions';
5
5
  import SyncButton from './SyncButton';
6
- import { selectCloudToken } from '../../../InventorySettings/InventorySettingsSelectors';
7
6
  import { selectTaskStatus } from './SyncButtonSelectors';
8
7
 
9
8
  // map state to props
10
9
  const mapStateToProps = state => ({
11
- cloudToken: selectCloudToken(state),
12
10
  status: selectTaskStatus(state),
13
11
  });
14
12
 
@@ -73,6 +73,3 @@ export const selectShowSelectAllAlert = state =>
73
73
 
74
74
  export const selectItemCount = state =>
75
75
  selectAPIResponse(state, INSIGHTS_HITS_API_KEY).itemCount || 0;
76
-
77
- export const selectHasToken = state =>
78
- selectAPIResponse(state, INSIGHTS_HITS_API_KEY).hasToken;
@@ -5,6 +5,7 @@ import {
5
5
  Pagination as PfPagination,
6
6
  PaginationVariant,
7
7
  } from '@patternfly/react-core';
8
+ import { translate as __ } from 'foremanReact/common/I18n';
8
9
  import { useForemanSettings } from 'foremanReact/Root/Context/ForemanContext';
9
10
  import { onTablePerPageSelect, onTableSetPage } from './InsightsTableActions';
10
11
  import { getPerPageOptions } from './InsightsTableHelpers';
@@ -14,6 +15,20 @@ import {
14
15
  selectPerPage,
15
16
  } from './InsightsTableSelectors';
16
17
 
18
+ const paginationTitles = {
19
+ items: __('items'),
20
+ page: '', // doesn't work well with translations as it adds 's' for plural, see: https://github.com/patternfly/patternfly-react/issues/6707
21
+ itemsPerPage: __('Items per page'),
22
+ perPageSuffix: __('per page'),
23
+ toFirstPage: __('Go to first page'),
24
+ toPreviousPage: __('Go to previous page'),
25
+ toLastPage: __('Go to last page'),
26
+ toNextPage: __('Go to next page'),
27
+ optionsToggle: __('Items per page'),
28
+ currPage: __('Current page'),
29
+ paginationTitle: __('Pagination'),
30
+ };
31
+
17
32
  const Pagination = ({ variant, ...props }) => {
18
33
  const dispatch = useDispatch();
19
34
  const onSetPage = (e, pageNumber) => dispatch(onTableSetPage(e, pageNumber));
@@ -35,6 +50,7 @@ const Pagination = ({ variant, ...props }) => {
35
50
  onSetPage={onSetPage}
36
51
  onPerPageSelect={onPerPageSelect}
37
52
  perPageOptions={getPerPageOptions(urlPerPage, appPerPage)}
53
+ titles={paginationTitles}
38
54
  {...props}
39
55
  />
40
56
  );
@@ -3,7 +3,6 @@ import { insightsStateWrapper } from '../../../../ForemanRhCloudTestHelpers';
3
3
  import { routerState, APIState, APIErrorState } from './fixtures';
4
4
  import {
5
5
  selectError,
6
- selectHasToken,
7
6
  selectHits,
8
7
  selectInsightsCloudTable,
9
8
  selectIsAllSelected,
@@ -46,7 +45,6 @@ const fixtures = {
46
45
  'should return API error': () => selectError({ ...state, ...APIErrorState }),
47
46
  'should return API hits': () => selectHits(state),
48
47
  'should return API item count': () => selectItemCount(state),
49
- 'should return API has token': () => selectHasToken(state),
50
48
  'should return insights table': () => selectInsightsCloudTable(state),
51
49
  'should return insights selectedIds': () => selectSelectedIds(state),
52
50
  'should return insights isAllSelected': () => selectIsAllSelected(state),
@@ -2,8 +2,6 @@
2
2
 
3
3
  exports[`InsightsTable selectors should return API error 1`] = `"Request failed with status code 503"`;
4
4
 
5
- exports[`InsightsTable selectors should return API has token 1`] = `true`;
6
-
7
5
  exports[`InsightsTable selectors should return API hits 1`] = `
8
6
  Array [
9
7
  Object {
@@ -78,7 +78,6 @@ export const APIState = {
78
78
  url: '/insights_cloud/hits',
79
79
  },
80
80
  response: {
81
- hasToken: true,
82
81
  hits,
83
82
  itemCount: 2,
84
83
  },
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import PageLayout from 'foremanReact/routes/common/PageLayout/PageLayout';
4
4
  import InsightsHeader from './Components/InsightsHeader';
5
- import { NoTokenEmptyState } from './Components/NoTokenEmptyState';
6
5
  import InsightsTable from './Components/InsightsTable';
7
6
  import RemediationModal from './Components/RemediationModal';
8
7
  import {
@@ -14,20 +13,7 @@ import Pagination from './Components/InsightsTable/Pagination';
14
13
  import ToolbarDropdown from './Components/ToolbarDropdown';
15
14
  import InsightsSettings from './Components/InsightsSettings';
16
15
 
17
- const InsightsCloudSync = ({
18
- syncInsights,
19
- query,
20
- fetchInsights,
21
- hasToken,
22
- }) => {
23
- if (!hasToken) {
24
- return (
25
- <PageLayout header={INSIGHTS_SYNC_PAGE_TITLE} searchable={false}>
26
- <NoTokenEmptyState />
27
- </PageLayout>
28
- );
29
- }
30
-
16
+ const InsightsCloudSync = ({ syncInsights, query, fetchInsights }) => {
31
17
  const onRecommendationSync = () => syncInsights(fetchInsights, query);
32
18
  const toolbarButtons = (
33
19
  <>
@@ -63,12 +49,10 @@ InsightsCloudSync.propTypes = {
63
49
  syncInsights: PropTypes.func.isRequired,
64
50
  fetchInsights: PropTypes.func.isRequired,
65
51
  query: PropTypes.string,
66
- hasToken: PropTypes.bool,
67
52
  };
68
53
 
69
54
  InsightsCloudSync.defaultProps = {
70
55
  query: '',
71
- hasToken: true,
72
56
  };
73
57
 
74
58
  export default InsightsCloudSync;
@@ -8,13 +8,6 @@ const fixtures = {
8
8
  syncInsights: noop,
9
9
  fetchInsights: noop,
10
10
  query: '',
11
- hasToken: true,
12
- },
13
- 'render no token': {
14
- status: 'RESOLVED',
15
- syncInsights: noop,
16
- fetchInsights: noop,
17
- hasToken: false,
18
11
  },
19
12
  };
20
13
 
@@ -10,10 +10,6 @@ export const INSIGHTS_SYNC_PAGE_TITLE = __('Red Hat Insights');
10
10
 
11
11
  export const INSIGHTS_PATH = foremanUrl('/foreman_rh_cloud/insights_cloud');
12
12
 
13
- export const INSIGHTS_SAVE_AND_SYNC_PATH = foremanUrl(
14
- '/insights_cloud/save_token_and_sync'
15
- );
16
-
17
13
  export const INSIGHTS_SEARCH_PROPS = {
18
14
  ...getControllerSearchProps('/insights_cloud/hits'),
19
15
  controller: 'insights_hits',
@@ -1,14 +1,7 @@
1
- import URI from 'urijs';
2
1
  import { foremanUrl } from '../ForemanRhCloudHelpers';
3
2
 
4
3
  export const insightsCloudUrl = path => foremanUrl(`/insights_cloud/${path}`);
5
4
 
6
- export const cloudTokenSettingUrl = () => {
7
- const settingsUrl = new URI(foremanUrl('/settings'));
8
- settingsUrl.setSearch({ search: 'name = rh_cloud_token' });
9
- return settingsUrl.toString();
10
- };
11
-
12
5
  export const redHatConsole = path => `https://console.redhat.com/${path || ''}`;
13
6
  export const redHatInsights = path => redHatConsole(`insights/${path || ''}`);
14
7
  export const redHatInventory = path =>
@@ -52,12 +52,3 @@ exports[`InsightsCloudSync render 1`] = `
52
52
  </PageLayout>
53
53
  </div>
54
54
  `;
55
-
56
- exports[`InsightsCloudSync render no token 1`] = `
57
- <PageLayout
58
- header="Red Hat Insights"
59
- searchable={false}
60
- >
61
- <NoTokenEmptyState />
62
- </PageLayout>
63
- `;
@@ -5,14 +5,10 @@ import * as actions from './InsightsCloudSyncActions';
5
5
  import { fetchInsights } from './Components/InsightsTable/InsightsTableActions';
6
6
  import InsightsCloudSync from './InsightsCloudSync';
7
7
  import insightsCloudSyncReducers from './InsightsCloudSyncReducers';
8
- import {
9
- selectSearch,
10
- selectHasToken,
11
- } from './Components/InsightsTable/InsightsTableSelectors';
8
+ import { selectSearch } from './Components/InsightsTable/InsightsTableSelectors';
12
9
  // map state to props
13
10
  const mapStateToProps = state => ({
14
11
  query: selectSearch(state),
15
- hasToken: selectHasToken(state),
16
12
  });
17
13
 
18
14
  // map action dispatchers to props
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_rh_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.34
4
+ version: 5.0.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-26 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello
@@ -164,7 +164,7 @@ files:
164
164
  - app/overrides/hosts_list.rb
165
165
  - app/overrides/layouts/base/styles.html.erb.deface
166
166
  - app/services/foreman_rh_cloud/branch_info.rb
167
- - app/services/foreman_rh_cloud/cloud_auth.rb
167
+ - app/services/foreman_rh_cloud/cert_auth.rb
168
168
  - app/services/foreman_rh_cloud/cloud_connector.rb
169
169
  - app/services/foreman_rh_cloud/cloud_ping_service.rb
170
170
  - app/services/foreman_rh_cloud/cloud_presence.rb
@@ -182,7 +182,6 @@ files:
182
182
  - app/views/layouts/foreman_rh_cloud/application.html.erb
183
183
  - config/Gemfile.lock.gh_test
184
184
  - config/database.yml.example
185
- - config/package-lock.json
186
185
  - config/package-lock.json.gh_test
187
186
  - config/package-lock.json.plugin
188
187
  - config/rh_cert-api_chain.pem
@@ -198,6 +197,7 @@ files:
198
197
  - db/migrate/20210404000001_change_resolutions.foreman_rh_cloud.rb
199
198
  - db/migrate/20210720000001_remove_old_insights_statuses.foreman_rh_cloud.rb
200
199
  - db/migrate/20211027000001_create_task_output.foreman_rh_cloud.rb
200
+ - db/migrate/20220321000001_add_unique_to_insights_rules.foreman_rh_cloud.rb
201
201
  - db/seeds.d/179_ui_notifications.rb
202
202
  - db/seeds.d/50_job_templates.rb
203
203
  - lib/foreman_inventory_upload.rb
@@ -428,7 +428,6 @@ files:
428
428
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap
429
429
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js
430
430
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.js
431
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.scss
432
431
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js
433
432
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/PageDescription.test.js
434
433
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap
@@ -448,9 +447,7 @@ files:
448
447
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap
449
448
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap
450
449
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
451
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js
452
450
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js
453
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss
454
451
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js
455
452
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js
456
453
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js
@@ -576,7 +573,6 @@ files:
576
573
  - webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js
577
574
  - webpack/InsightsCloudSync/Components/InsightsTable/index.js
578
575
  - webpack/InsightsCloudSync/Components/InsightsTable/table.scss
579
- - webpack/InsightsCloudSync/Components/NoTokenEmptyState.js
580
576
  - webpack/InsightsCloudSync/Components/RemediationModal/RemediationActions.js
581
577
  - webpack/InsightsCloudSync/Components/RemediationModal/RemediationHelpers.js
582
578
  - webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js
@@ -587,9 +583,7 @@ files:
587
583
  - webpack/InsightsCloudSync/Components/RemediationModal/index.js
588
584
  - webpack/InsightsCloudSync/Components/ToolbarDropdown.js
589
585
  - webpack/InsightsCloudSync/Components/__tests__/InsightsHeader.test.js
590
- - webpack/InsightsCloudSync/Components/__tests__/NoTokenEmptyState.test.js
591
586
  - webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap
592
- - webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap
593
587
  - webpack/InsightsCloudSync/InsightsCloudSync.js
594
588
  - webpack/InsightsCloudSync/InsightsCloudSync.scss
595
589
  - webpack/InsightsCloudSync/InsightsCloudSync.test.js
@@ -678,7 +672,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
678
672
  - !ruby/object:Gem::Version
679
673
  version: '0'
680
674
  requirements: []
681
- rubygems_version: 3.2.22
675
+ rubygems_version: 3.1.4
682
676
  signing_key:
683
677
  specification_version: 4
684
678
  summary: Summary of ForemanRhCloud.
@@ -694,33 +688,33 @@ test_files:
694
688
  - test/controllers/uploads_settings_controller_test.rb
695
689
  - test/factories/insights_factories.rb
696
690
  - test/factories/inventory_upload_factories.rb
697
- - test/jobs/connector_playbook_execution_reporter_task_test.rb
698
691
  - test/jobs/insights_client_status_aging_test.rb
692
+ - test/jobs/inventory_scheduled_sync_test.rb
693
+ - test/jobs/upload_report_job_test.rb
694
+ - test/jobs/connector_playbook_execution_reporter_task_test.rb
699
695
  - test/jobs/insights_full_sync_test.rb
700
696
  - test/jobs/insights_resolutions_sync_test.rb
701
697
  - test/jobs/insights_rules_sync_test.rb
702
698
  - test/jobs/inventory_full_sync_test.rb
703
699
  - test/jobs/inventory_hosts_sync_test.rb
704
- - test/jobs/inventory_scheduled_sync_test.rb
705
700
  - test/jobs/inventory_self_host_sync_test.rb
706
- - test/jobs/upload_report_job_test.rb
707
701
  - test/models/insights_client_report_status_test.rb
708
702
  - test/test_plugin_helper.rb
709
703
  - test/unit/archived_report_generator_test.rb
710
704
  - test/unit/fact_helpers_test.rb
711
- - test/unit/foreman_rh_cloud_self_host_test.rb
712
705
  - test/unit/insights_facet_test.rb
713
706
  - test/unit/metadata_generator_test.rb
714
- - test/unit/playbook_progress_generator_test.rb
715
707
  - test/unit/rh_cloud_http_proxy_test.rb
716
708
  - test/unit/rh_cloud_permissions_test.rb
717
709
  - test/unit/services/foreman_rh_cloud/branch_info_test.rb
710
+ - test/unit/services/foreman_rh_cloud/insights_status_cleaner_test.rb
718
711
  - test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb
719
712
  - test/unit/services/foreman_rh_cloud/cloud_status_service_test.rb
720
713
  - test/unit/services/foreman_rh_cloud/hit_remediations_retriever_test.rb
721
- - test/unit/services/foreman_rh_cloud/insights_status_cleaner_test.rb
722
714
  - test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb
723
715
  - test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb
724
716
  - test/unit/shell_process_job_test.rb
725
717
  - test/unit/slice_generator_test.rb
726
718
  - test/unit/tags_generator_test.rb
719
+ - test/unit/foreman_rh_cloud_self_host_test.rb
720
+ - test/unit/playbook_progress_generator_test.rb
@@ -1,44 +0,0 @@
1
- module ForemanRhCloud
2
- module CloudAuth
3
- extend ActiveSupport::Concern
4
-
5
- include CloudRequest
6
-
7
- def cloud_auth_available?
8
- Setting[:rh_cloud_token].present?
9
- end
10
-
11
- def rh_credentials
12
- @rh_credentials ||= query_refresh_token
13
- end
14
-
15
- def query_refresh_token
16
- token_response = RestClient::Request.execute(
17
- method: :post,
18
- url: ForemanRhCloud.authentication_url,
19
- verify_ssl: ForemanRhCloud.verify_ssl_method,
20
- proxy: ForemanRhCloud.transformed_http_proxy_string(logger: logger),
21
- payload: {
22
- grant_type: 'refresh_token',
23
- client_id: 'rhsm-api',
24
- refresh_token: Setting[:rh_cloud_token],
25
- }
26
- )
27
-
28
- JSON.parse(token_response)['access_token']
29
- rescue RestClient::ExceptionWithResponse => e
30
- Foreman::Logging.exception('Unable to authenticate using rh_cloud_token setting', e)
31
- raise ::Foreman::WrappedException.new(e, N_('Unable to authenticate using rh_cloud_token setting'))
32
- end
33
-
34
- def execute_cloud_request(params)
35
- final_params = {
36
- headers: {
37
- Authorization: "Bearer #{rh_credentials}",
38
- },
39
- }.deep_merge(params)
40
-
41
- super(final_params)
42
- end
43
- end
44
- end