foreman_rh_cloud 5.0.35 → 5.0.38

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_controller.rb +0 -7
  4. data/app/controllers/foreman_inventory_upload/uploads_settings_controller.rb +0 -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 +1 -1
  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/cloud_connector_announce_task.rb +44 -0
  28. data/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +7 -1
  29. data/lib/insights_cloud/async/insights_full_sync.rb +40 -24
  30. data/lib/insights_cloud/async/insights_resolutions_sync.rb +10 -13
  31. data/lib/insights_cloud/async/insights_rules_sync.rb +27 -19
  32. data/lib/insights_cloud/async/insights_scheduled_sync.rb +1 -1
  33. data/lib/insights_cloud.rb +4 -8
  34. data/lib/inventory_sync/async/host_result.rb +3 -2
  35. data/lib/inventory_sync/async/inventory_full_sync.rb +3 -3
  36. data/lib/inventory_sync/async/inventory_hosts_sync.rb +11 -10
  37. data/lib/inventory_sync/async/inventory_self_host_sync.rb +5 -6
  38. data/lib/inventory_sync/async/query_inventory_job.rb +40 -12
  39. data/lib/tasks/insights.rake +1 -1
  40. data/package.json +6 -6
  41. data/test/controllers/insights_cloud/api/cloud_request_controller_test.rb +0 -1
  42. data/test/controllers/inventory_upload/cloud_status_controller_test.rb +0 -6
  43. data/test/jobs/cloud_connector_announce_task_test.rb +125 -0
  44. data/test/jobs/insights_full_sync_test.rb +9 -5
  45. data/test/jobs/insights_resolutions_sync_test.rb +7 -1
  46. data/test/jobs/insights_rules_sync_test.rb +8 -4
  47. data/test/jobs/inventory_full_sync_test.rb +16 -5
  48. data/test/jobs/inventory_hosts_sync_test.rb +18 -4
  49. data/test/jobs/inventory_self_host_sync_test.rb +6 -1
  50. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +0 -1
  51. data/test/unit/services/foreman_rh_cloud/cloud_status_service_test.rb +1 -14
  52. data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +5 -1
  53. data/test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb +3 -1
  54. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsSelectors.js +0 -2
  55. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.js +1 -10
  56. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +3 -12
  57. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +1 -1
  58. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +0 -4
  59. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +0 -2
  60. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +0 -3
  61. data/webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js +16 -0
  62. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableSelectors.test.js +0 -2
  63. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap +0 -2
  64. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +0 -1
  65. data/webpack/InsightsCloudSync/InsightsCloudSync.js +1 -17
  66. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +0 -7
  67. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -4
  68. data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +0 -7
  69. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +0 -9
  70. data/webpack/InsightsCloudSync/index.js +1 -5
  71. metadata +7 -9
  72. data/app/services/foreman_rh_cloud/cloud_auth.rb +0 -44
  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
@@ -3,10 +3,14 @@ require 'foreman_tasks/test_helpers'
3
3
 
4
4
  class InventoryFullSyncTest < ActiveSupport::TestCase
5
5
  include ForemanTasks::TestHelpers::WithInThreadExecutor
6
+ include MockCerts
6
7
 
7
8
  setup do
8
9
  User.current = User.find_by(login: 'secret_admin')
9
10
 
11
+ InventorySync::Async::InventoryFullSync.any_instance.stubs(:plan_self_host_sync)
12
+ Organization.any_instance.stubs(:manifest_expired?).returns(false)
13
+
10
14
  env = FactoryBot.create(:katello_k_t_environment)
11
15
  cv = env.content_views << FactoryBot.create(:katello_content_view, organization: env.organization)
12
16
 
@@ -254,7 +258,10 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
254
258
  end
255
259
 
256
260
  test 'Host status should be SYNC for inventory hosts' do
257
- Setting[:rh_cloud_token] = 'TEST TOKEN'
261
+ setup_certs_expectation do
262
+ InventorySync::Async::InventoryFullSync.any_instance.stubs(:candlepin_id_cert)
263
+ end
264
+
258
265
  InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
259
266
 
260
267
  ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host2.organization)
@@ -266,7 +273,9 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
266
273
  end
267
274
 
268
275
  test 'Host status should be DISCONNECT for hosts that are not returned from cloud' do
269
- Setting[:rh_cloud_token] = 'TEST TOKEN'
276
+ setup_certs_expectation do
277
+ InventorySync::Async::InventoryFullSync.any_instance.stubs(:candlepin_id_cert)
278
+ end
270
279
  InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
271
280
  FactoryBot.create(:fact_value, fact_name: fact_names['virt::uuid'], value: '1234', host: @host2)
272
281
 
@@ -276,8 +285,8 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
276
285
  assert_equal InventorySync::InventoryStatus::DISCONNECT, InventorySync::InventoryStatus.where(host_id: @host1.id).first.status
277
286
  end
278
287
 
279
- test 'Task should be aborted if token is not present' do
280
- Setting[:rh_cloud_token] = ''
288
+ test 'Task should be aborted if manifest is not present' do
289
+ InventorySync::Async::InventoryFullSync.any_instance.expects(:upstream_owner).returns(nil)
281
290
 
282
291
  InventorySync::Async::InventoryFullSync.any_instance.expects(:plan_self).never
283
292
 
@@ -287,7 +296,9 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
287
296
  test 'Should skip hosts that are not returned in query' do
288
297
  assert_nil InventorySync::InventoryStatus.where(host_id: @host3.id).first
289
298
 
290
- Setting[:rh_cloud_token] = 'TEST TOKEN'
299
+ setup_certs_expectation do
300
+ InventorySync::Async::InventoryFullSync.any_instance.stubs(:candlepin_id_cert)
301
+ end
291
302
  InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
292
303
  InventorySync::Async::InventoryFullSync.any_instance.expects(:affected_host_ids).returns([@host1.id, @host2.id])
293
304
  FactoryBot.create(:fact_value, fact_name: fact_names['virt::uuid'], value: '1234', host: @host2)
@@ -3,10 +3,10 @@ require 'foreman_tasks/test_helpers'
3
3
 
4
4
  class InventoryHostsSyncTest < ActiveSupport::TestCase
5
5
  include ForemanTasks::TestHelpers::WithInThreadExecutor
6
+ include MockCerts
6
7
 
7
8
  setup do
8
9
  User.current = User.find_by(login: 'secret_admin')
9
- Setting[:rh_cloud_token] = 'MOCK_TOKEN'
10
10
 
11
11
  env = FactoryBot.create(:katello_k_t_environment)
12
12
  cv = env.content_views << FactoryBot.create(:katello_content_view, organization: env.organization)
@@ -40,6 +40,8 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
40
40
 
41
41
  ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
42
42
 
43
+ Organization.any_instance.stubs(:manifest_expired?).returns(false)
44
+
43
45
  inventory_json = <<-INVENTORY_JSON
44
46
  {
45
47
  "total": 3,
@@ -246,9 +248,13 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
246
248
  InventorySync::Async::InventoryHostsSync.any_instance.expects(:query_inventory).returns(@inventory)
247
249
  InventorySync::Async::InventoryHostsSync.any_instance.expects(:plan_self_host_sync)
248
250
 
251
+ setup_certs_expectation do
252
+ InventorySync::Async::InventoryHostsSync.any_instance.stubs(:candlepin_id_cert)
253
+ end
254
+
249
255
  @host2.build_insights.save
250
256
 
251
- ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync)
257
+ ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
252
258
 
253
259
  @host2.reload
254
260
 
@@ -259,7 +265,11 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
259
265
  InventorySync::Async::InventoryHostsSync.any_instance.expects(:query_inventory).returns(@inventory)
260
266
  InventorySync::Async::InventoryHostsSync.any_instance.expects(:plan_self_host_sync)
261
267
 
262
- ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync)
268
+ setup_certs_expectation do
269
+ InventorySync::Async::InventoryHostsSync.any_instance.stubs(:candlepin_id_cert)
270
+ end
271
+
272
+ ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
263
273
 
264
274
  @host2.reload
265
275
 
@@ -272,9 +282,13 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
272
282
  InventorySync::Async::InventoryHostsSync.any_instance.expects(:query_inventory).returns(empty_inventory)
273
283
  InventorySync::Async::InventoryHostsSync.any_instance.expects(:plan_self_host_sync)
274
284
 
285
+ setup_certs_expectation do
286
+ InventorySync::Async::InventoryHostsSync.any_instance.stubs(:candlepin_id_cert)
287
+ end
288
+
275
289
  assert_nil @host2.insights
276
290
 
277
- ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync)
291
+ ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
278
292
 
279
293
  @host2.reload
280
294
 
@@ -3,10 +3,15 @@ require 'foreman_tasks/test_helpers'
3
3
 
4
4
  class InventorySelfHostSyncTest < ActiveSupport::TestCase
5
5
  include ForemanTasks::TestHelpers::WithInThreadExecutor
6
+ include MockCerts
6
7
 
7
8
  setup do
8
9
  User.current = User.find_by(login: 'secret_admin')
9
- Setting[:rh_cloud_token] = 'MOCK_TOKEN'
10
+
11
+ setup_certs_expectation do
12
+ InventorySync::Async::InventorySelfHostSync.any_instance.stubs(:candlepin_id_cert)
13
+ end
14
+ Organization.any_instance.stubs(:manifest_expired?).returns(false)
10
15
 
11
16
  # this host would pass our plugin queries, so it could be uploaded to the cloud.
12
17
  @host1 = FactoryBot.create(:host)
@@ -10,7 +10,6 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
10
10
  ForemanRhCloud.stubs(:base_url).returns('https://cloud.example.com')
11
11
  ForemanRhCloud.stubs(:cert_base_url).returns('https://cert.cloud.example.com')
12
12
  ForemanRhCloud.stubs(:legacy_insights_url).returns('https://cert-api.access.example.com')
13
- ForemanRhCloud.stubs(:authentication_url).returns('https://sso.example.com/auth/realms/redhat-external/protocol/openid-connect/token')
14
13
  end
15
14
 
16
15
  test 'should prepare correct cloud url' do
@@ -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.35
4
+ version: 5.0.38
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-05-11 00:00:00.000000000 Z
11
+ date: 2022-06-09 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
@@ -198,6 +198,7 @@ files:
198
198
  - db/migrate/20210404000001_change_resolutions.foreman_rh_cloud.rb
199
199
  - db/migrate/20210720000001_remove_old_insights_statuses.foreman_rh_cloud.rb
200
200
  - db/migrate/20211027000001_create_task_output.foreman_rh_cloud.rb
201
+ - db/migrate/20220321000001_add_unique_to_insights_rules.foreman_rh_cloud.rb
201
202
  - db/seeds.d/179_ui_notifications.rb
202
203
  - db/seeds.d/50_job_templates.rb
203
204
  - lib/foreman_inventory_upload.rb
@@ -221,6 +222,7 @@ files:
221
222
  - lib/foreman_rh_cloud/engine.rb
222
223
  - lib/foreman_rh_cloud/version.rb
223
224
  - lib/insights_cloud.rb
225
+ - lib/insights_cloud/async/cloud_connector_announce_task.rb
224
226
  - lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb
225
227
  - lib/insights_cloud/async/insights_client_status_aging.rb
226
228
  - lib/insights_cloud/async/insights_full_sync.rb
@@ -255,6 +257,7 @@ files:
255
257
  - test/controllers/uploads_settings_controller_test.rb
256
258
  - test/factories/insights_factories.rb
257
259
  - test/factories/inventory_upload_factories.rb
260
+ - test/jobs/cloud_connector_announce_task_test.rb
258
261
  - test/jobs/connector_playbook_execution_reporter_task_test.rb
259
262
  - test/jobs/insights_client_status_aging_test.rb
260
263
  - test/jobs/insights_full_sync_test.rb
@@ -428,7 +431,6 @@ files:
428
431
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap
429
432
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js
430
433
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.js
431
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.scss
432
434
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js
433
435
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/PageDescription.test.js
434
436
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap
@@ -448,9 +450,7 @@ files:
448
450
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap
449
451
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap
450
452
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
451
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js
452
453
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js
453
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss
454
454
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js
455
455
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js
456
456
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js
@@ -576,7 +576,6 @@ files:
576
576
  - webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js
577
577
  - webpack/InsightsCloudSync/Components/InsightsTable/index.js
578
578
  - webpack/InsightsCloudSync/Components/InsightsTable/table.scss
579
- - webpack/InsightsCloudSync/Components/NoTokenEmptyState.js
580
579
  - webpack/InsightsCloudSync/Components/RemediationModal/RemediationActions.js
581
580
  - webpack/InsightsCloudSync/Components/RemediationModal/RemediationHelpers.js
582
581
  - webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js
@@ -587,9 +586,7 @@ files:
587
586
  - webpack/InsightsCloudSync/Components/RemediationModal/index.js
588
587
  - webpack/InsightsCloudSync/Components/ToolbarDropdown.js
589
588
  - webpack/InsightsCloudSync/Components/__tests__/InsightsHeader.test.js
590
- - webpack/InsightsCloudSync/Components/__tests__/NoTokenEmptyState.test.js
591
589
  - webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap
592
- - webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap
593
590
  - webpack/InsightsCloudSync/InsightsCloudSync.js
594
591
  - webpack/InsightsCloudSync/InsightsCloudSync.scss
595
592
  - webpack/InsightsCloudSync/InsightsCloudSync.test.js
@@ -694,6 +691,7 @@ test_files:
694
691
  - test/controllers/uploads_settings_controller_test.rb
695
692
  - test/factories/insights_factories.rb
696
693
  - test/factories/inventory_upload_factories.rb
694
+ - test/jobs/cloud_connector_announce_task_test.rb
697
695
  - test/jobs/connector_playbook_execution_reporter_task_test.rb
698
696
  - test/jobs/insights_client_status_aging_test.rb
699
697
  - test/jobs/insights_full_sync_test.rb