foreman_rh_cloud 0.9.12 → 0.9.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +2 -0
  3. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +18 -0
  4. data/app/helpers/foreman_inventory_upload_host_helper.rb +2 -3
  5. data/app/models/concerns/rh_cloud_host.rb +4 -1
  6. data/app/models/insights_hit.rb +1 -1
  7. data/app/models/setting/rh_cloud.rb +2 -0
  8. data/app/overrides/hosts_list.rb +1 -1
  9. data/app/services/foreman_rh_cloud/cloud_auth.rb +28 -0
  10. data/config/routes.rb +2 -0
  11. data/db/migrate/20201007115752_add_hits_count_to_insights_facets_table.foreman_rh_cloud.rb +5 -0
  12. data/db/migrate/20201007121540_setup_hits_count_cache.foreman_rh_cloud.rb +10 -0
  13. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +35 -0
  14. data/lib/foreman_inventory_upload/generators/json_stream.rb +7 -2
  15. data/lib/foreman_inventory_upload/generators/queries.rb +2 -0
  16. data/lib/foreman_inventory_upload/generators/slice.rb +26 -24
  17. data/lib/foreman_rh_cloud.rb +2 -1
  18. data/lib/foreman_rh_cloud/engine.rb +3 -2
  19. data/lib/foreman_rh_cloud/version.rb +1 -1
  20. data/lib/insights_cloud/async/insights_full_sync.rb +4 -25
  21. data/lib/inventory_sync/async/inventory_full_sync.rb +2 -23
  22. data/package.json +1 -1
  23. data/test/unit/fact_helpers_test.rb +22 -0
  24. data/test/unit/insights_facet_test.rb +7 -0
  25. data/test/unit/slice_generator_test.rb +107 -1
  26. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +14 -1
  27. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +22 -18
  28. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +16 -0
  29. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +6 -0
  30. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +7 -0
  31. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +12 -8
  32. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +9 -0
  33. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +19 -0
  34. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +11 -0
  35. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -0
  36. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +2 -0
  37. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +10 -11
  38. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +0 -1
  39. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +12 -2
  40. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +17 -0
  41. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.fixtures.js +1 -0
  42. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +30 -0
  43. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +29 -0
  44. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherConstants.js +1 -0
  45. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcher.test.js +13 -0
  46. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +21 -0
  47. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +38 -0
  48. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcherActions.test.js.snap +31 -0
  49. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +41 -0
  50. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +38 -0
  51. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/excludePackagesSwitcher.scss +3 -0
  52. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/index.js +20 -0
  53. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +2 -1
  54. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +1 -0
  55. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.scss +3 -0
  56. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +10 -11
  57. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +0 -2
  58. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +12 -2
  59. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +18 -1
  60. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +4 -0
  61. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +2 -0
  62. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.fixtures.js +1 -0
  63. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +29 -0
  64. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +29 -0
  65. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants.js +1 -0
  66. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcher.test.js +13 -0
  67. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +21 -0
  68. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +38 -0
  69. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcherActions.test.js.snap +31 -0
  70. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/index.js +20 -0
  71. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +8 -2
  72. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +9 -11
  73. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +1 -1
  74. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +2 -2
  75. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +18 -0
  76. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +1 -8
  77. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +62 -0
  78. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +0 -7
  79. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +6 -1
  80. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +2 -4
  81. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +8 -0
  82. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +17 -20
  83. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsConstants.js +0 -6
  84. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsReducer.js +0 -4
  85. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +16 -0
  86. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +1 -24
  87. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +38 -4
  88. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +0 -14
  89. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +10 -11
  90. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -2
  91. data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +9 -8
  92. data/webpack/InsightsHostDetailsTab/InsightsTabConstants.js +0 -1
  93. data/webpack/InsightsHostDetailsTab/InsightsTabReducer.js +2 -9
  94. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +7 -1
  95. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js +0 -9
  96. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +40 -2
  97. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +0 -7
  98. metadata +39 -15
  99. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/hostObfuscationSwitcher.scss +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "0.9.12",
3
+ "version": "0.9.13",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,4 +26,26 @@ class FactHelpersTest < ActiveSupport::TestCase
26
26
 
27
27
  assert actual
28
28
  end
29
+
30
+ test 'obfuscates ips with insights-client data' do
31
+ host = mock('host')
32
+ @instance.expects(:fact_value).with(host, 'insights_client::ips').returns(
33
+ '[{"obfuscated": "10.230.230.1", "original": "224.0.0.1"}, {"obfuscated": "10.230.230.2", "original": "224.0.0.251"}]'
34
+ )
35
+
36
+ actual = @instance.obfuscated_ips(host)
37
+
38
+ assert_equal '10.230.230.1', actual['224.0.0.1']
39
+ assert_equal '10.230.230.3', actual['224.0.0.2']
40
+ end
41
+
42
+ test 'obfuscates ips without insights-client data' do
43
+ host = mock('host')
44
+ @instance.expects(:fact_value).with(host, 'insights_client::ips').returns(nil)
45
+
46
+ actual = @instance.obfuscated_ips(host)
47
+
48
+ assert_equal '10.230.230.1', actual['224.0.0.1']
49
+ assert_equal '10.230.230.2', actual['224.0.0.2']
50
+ end
29
51
  end
@@ -3,6 +3,7 @@ require 'test_plugin_helper'
3
3
  class InsightsFacetTest < ActiveSupport::TestCase
4
4
  setup do
5
5
  @host = FactoryBot.create(:host, :with_insights_hits)
6
+ InsightsFacet.reset_counters(@host.insights.id, :hits_count)
6
7
  end
7
8
 
8
9
  test 'host with hits can be deleted' do
@@ -13,4 +14,10 @@ class InsightsFacetTest < ActiveSupport::TestCase
13
14
  actual_host = Host.find_by_id(host_id)
14
15
  assert_nil actual_host
15
16
  end
17
+
18
+ test 'search host by recommendations_count' do
19
+ FactoryBot.create(:host) # create another host with no recommendations
20
+
21
+ assert_equal 1, Host.search_for('insights_recommendations_count = 1').count
22
+ end
16
23
  end
@@ -1,6 +1,6 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
- class ReportGeneratorTest < ActiveSupport::TestCase
3
+ class SliceGeneratorTest < ActiveSupport::TestCase
4
4
  setup do
5
5
  User.current = User.find_by(login: 'secret_admin')
6
6
 
@@ -44,6 +44,8 @@ class ReportGeneratorTest < ActiveSupport::TestCase
44
44
  'dmi::chassis::asset_tag',
45
45
  'insights_client::obfuscate_hostname_enabled',
46
46
  'insights_client::hostname',
47
+ 'insights_client::obfuscate_ip_enabled',
48
+ 'insights_client::ips',
47
49
  ]
48
50
  end
49
51
 
@@ -69,6 +71,31 @@ class ReportGeneratorTest < ActiveSupport::TestCase
69
71
  assert_equal @host.fqdn, actual_host['fqdn']
70
72
  assert_equal '1234', actual_host['account']
71
73
  assert_equal 1, generator.hosts_count
74
+ assert_not_nil(actual_system_profile = actual_host['system_profile'])
75
+ assert_nil actual_system_profile['number_of_cpus']
76
+ assert_nil actual_system_profile['number_of_sockets']
77
+ assert_nil actual_system_profile['cores_per_socket']
78
+ assert_nil actual_system_profile['system_memory_bytes']
79
+ assert_nil actual_system_profile['os_release']
80
+ end
81
+
82
+ test 'hosts report fields should be present if fact exist' do
83
+ FactoryBot.create(:fact_value, fact_name: fact_names['cpu::cpu(s)'], value: '4', host: @host)
84
+ FactoryBot.create(:fact_value, fact_name: fact_names['cpu::cpu_socket(s)'], value: '2', host: @host)
85
+ FactoryBot.create(:fact_value, fact_name: fact_names['cpu::core(s)_per_socket'], value: '1', host: @host)
86
+
87
+ batch = Host.where(id: @host.id).in_batches.first
88
+ generator = create_generator(batch)
89
+
90
+ json_str = generator.render
91
+ actual = JSON.parse(json_str.join("\n"))
92
+
93
+ assert_equal 'slice_123', actual['report_slice_id']
94
+ assert_not_nil(actual_host = actual['hosts'].first)
95
+ assert_not_nil(actual_system_profile = actual_host['system_profile'])
96
+ assert_equal 4, actual_system_profile['number_of_cpus']
97
+ assert_equal 2, actual_system_profile['number_of_sockets']
98
+ assert_equal 1, actual_system_profile['cores_per_socket']
72
99
  end
73
100
 
74
101
  test 'generates ip_address and mac_address fields' do
@@ -88,6 +115,59 @@ class ReportGeneratorTest < ActiveSupport::TestCase
88
115
  assert_equal 1, generator.hosts_count
89
116
  end
90
117
 
118
+ test 'generates obfuscated ip_address fields without inisghts-client' do
119
+ FactoryBot.create(:setting, :name => 'obfuscate_inventory_ips', :value => true)
120
+
121
+ @host.interfaces << FactoryBot.build(:nic_managed)
122
+ batch = Host.where(id: @host.id).in_batches.first
123
+ generator = create_generator(batch)
124
+
125
+ json_str = generator.render
126
+ actual = JSON.parse(json_str.join("\n"))
127
+
128
+ assert_equal 'slice_123', actual['report_slice_id']
129
+ assert_not_nil(actual_host = actual['hosts'].first)
130
+ assert_equal '10.230.230.1', actual_host['ip_addresses'].first
131
+ assert_not_nil(actual_system_profile = actual_host['system_profile'])
132
+ assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
133
+ assert_not_nil(actual_nic = actual_network_interfaces.first)
134
+ assert_equal '10.230.230.1', actual_nic['ipv4_addresses'].first
135
+ assert_equal @host.fqdn, actual_host['fqdn']
136
+ assert_equal '1234', actual_host['account']
137
+ assert_equal 1, generator.hosts_count
138
+ end
139
+
140
+ test 'generates obfuscated ip_address fields with inisghts-client' do
141
+ nic = FactoryBot.build(:nic_primary_and_provision)
142
+ @host.interfaces = [nic]
143
+ @host.save!
144
+
145
+ FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::obfuscate_ip_enabled'], value: 'true', host: @host)
146
+ FactoryBot.create(
147
+ :fact_value,
148
+ fact_name: fact_names['insights_client::ips'],
149
+ value: "[{\"obfuscated\": \"10.230.230.100\", \"original\": \"#{nic.ip}\"}]",
150
+ host: @host
151
+ )
152
+
153
+ batch = Host.where(id: @host.id).in_batches.first
154
+ generator = create_generator(batch)
155
+
156
+ json_str = generator.render
157
+ actual = JSON.parse(json_str.join("\n"))
158
+
159
+ assert_equal 'slice_123', actual['report_slice_id']
160
+ assert_not_nil(actual_host = actual['hosts'].first)
161
+ assert_equal '10.230.230.100', actual_host['ip_addresses'].first
162
+ assert_not_nil(actual_system_profile = actual_host['system_profile'])
163
+ assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
164
+ assert_not_nil(actual_nic = actual_network_interfaces.first)
165
+ assert_equal '10.230.230.100', actual_nic['ipv4_addresses'].first
166
+ assert_equal @host.fqdn, actual_host['fqdn']
167
+ assert_equal '1234', actual_host['account']
168
+ assert_equal 1, generator.hosts_count
169
+ end
170
+
91
171
  test 'obfuscates fqdn when instructed by insights-client' do
92
172
  FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::obfuscate_hostname_enabled'], value: 'true', host: @host)
93
173
  FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::hostname'], value: 'obfuscated_name', host: @host)
@@ -449,6 +529,32 @@ class ReportGeneratorTest < ActiveSupport::TestCase
449
529
  assert_equal 'alibaba', actual_profile['cloud_provider']
450
530
  end
451
531
 
532
+ test 'include packages installed in the report' do
533
+ FactoryBot.create(:setting, :name => 'exclude_installed_packages', :value => false)
534
+ installed_package = ::Katello::InstalledPackage.create(name: 'test-package', nvra: 'test-package-1.0.x86_64')
535
+
536
+ another_host = FactoryBot.create(
537
+ :host,
538
+ :with_subscription,
539
+ :with_content,
540
+ content_view: @host.content_view,
541
+ lifecycle_environment: @host.lifecycle_environment,
542
+ organization: @host.organization,
543
+ installed_packages: [installed_package]
544
+ )
545
+
546
+ batch = Host.where(id: another_host.id).in_batches.first
547
+ generator = create_generator(batch)
548
+
549
+ json_str = generator.render
550
+ actual = JSON.parse(json_str.join("\n"))
551
+
552
+ assert_equal 'slice_123', actual['report_slice_id']
553
+ assert_not_nil(actual_host = actual['hosts'].first)
554
+ assert_not_nil(actual_profile = actual_host['system_profile'])
555
+ assert_not_nil(actual_profile['installed_packages'])
556
+ end
557
+
452
558
  private
453
559
 
454
560
  def create_generator(batch, name = 'slice_123')
@@ -34,10 +34,14 @@ export const autoUploadEnabled = true;
34
34
 
35
35
  export const hostObfuscationEnabled = true;
36
36
 
37
+ export const ipsObfuscationEnabled = true;
38
+
37
39
  export const filterTerm = 'some_filter';
38
40
 
39
41
  export const cloudToken = 'some-cloud-token';
40
42
 
43
+ export const excludePackages = false;
44
+
41
45
  export const props = {
42
46
  accounts,
43
47
  fetchAccountsStatus: noop,
@@ -46,6 +50,15 @@ export const props = {
46
50
  pollingProcessID,
47
51
  };
48
52
 
53
+ export const pollingResponse = {
54
+ accounts,
55
+ autoUploadEnabled,
56
+ hostObfuscationEnabled,
57
+ ipsObfuscationEnabled,
58
+ cloudToken,
59
+ excludePackages,
60
+ };
61
+
49
62
  export const fetchAccountsStatusResponse = {
50
- data: { accounts, autoUploadEnabled, hostObfuscationEnabled, cloudToken },
63
+ data: pollingResponse,
51
64
  };
@@ -1,4 +1,5 @@
1
1
  import API from 'foremanReact/API';
2
+ import { addToast } from 'foremanReact/redux/actions/toasts';
2
3
  import { inventoryUrl } from '../../ForemanInventoryHelpers';
3
4
  import {
4
5
  INVENTORY_ACCOUNT_STATUS_POLLING,
@@ -10,17 +11,10 @@ import {
10
11
 
11
12
  export const fetchAccountsStatus = () => async dispatch => {
12
13
  try {
13
- const {
14
- data: { accounts, autoUploadEnabled, hostObfuscationEnabled, cloudToken },
15
- } = await API.get(inventoryUrl('accounts'));
14
+ const { data } = await API.get(inventoryUrl('accounts'));
16
15
  dispatch({
17
16
  type: INVENTORY_ACCOUNT_STATUS_POLLING,
18
- payload: {
19
- accounts,
20
- autoUploadEnabled,
21
- hostObfuscationEnabled,
22
- cloudToken,
23
- },
17
+ payload: data,
24
18
  });
25
19
  } catch (error) {
26
20
  dispatch({
@@ -46,7 +40,7 @@ export const stopAccountStatusPolling = pollingProcessID => dispatch => {
46
40
  });
47
41
  };
48
42
 
49
- export const restartProcess = (accountID, activeTab) => dispatch => {
43
+ export const restartProcess = (accountID, activeTab) => async dispatch => {
50
44
  let processController = null;
51
45
  let processStatusName = null;
52
46
 
@@ -58,12 +52,22 @@ export const restartProcess = (accountID, activeTab) => dispatch => {
58
52
  processStatusName = 'generate_report_status';
59
53
  }
60
54
 
61
- API.post(inventoryUrl(`${accountID}/${processController}`));
62
- dispatch({
63
- type: INVENTORY_PROCESS_RESTART,
64
- payload: {
65
- accountID,
66
- processStatusName,
67
- },
68
- });
55
+ try {
56
+ await API.post(inventoryUrl(`${accountID}/${processController}`));
57
+ dispatch({
58
+ type: INVENTORY_PROCESS_RESTART,
59
+ payload: {
60
+ accountID,
61
+ processStatusName,
62
+ },
63
+ });
64
+ } catch (error) {
65
+ dispatch(
66
+ addToast({
67
+ sticky: true,
68
+ type: 'error',
69
+ message: error.message,
70
+ })
71
+ );
72
+ }
69
73
  };
@@ -1,6 +1,8 @@
1
1
  import Immutable from 'seamless-immutable';
2
2
  import { AUTO_UPLOAD_TOGGLE } from '../AutoUploadSwitcher/AutoUploadSwitcherConstants';
3
3
  import { HOST_OBFUSCATION_TOGGLE } from '../HostObfuscationSwitcher/HostObfuscationSwitcherConstants';
4
+ import { IPS_OBFUSCATION_TOGGLE } from '../IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants';
5
+ import { EXCLUDE_PACKAGES_TOGGLE } from '../ExcludePackagesSwitcher/ExcludePackagesSwitcherConstants';
4
6
  import {
5
7
  INVENTORY_ACCOUNT_STATUS_POLLING,
6
8
  INVENTORY_ACCOUNT_STATUS_POLLING_ERROR,
@@ -24,7 +26,9 @@ export default (state = initialState, action) => {
24
26
  processStatusName,
25
27
  autoUploadEnabled,
26
28
  hostObfuscationEnabled,
29
+ ipsObfuscationEnabled,
27
30
  cloudToken,
31
+ excludePackages,
28
32
  } = {},
29
33
  } = action;
30
34
 
@@ -35,7 +39,9 @@ export default (state = initialState, action) => {
35
39
  accounts,
36
40
  autoUploadEnabled,
37
41
  hostObfuscationEnabled,
42
+ ipsObfuscationEnabled,
38
43
  cloudToken,
44
+ excludePackages,
39
45
  error: null,
40
46
  });
41
47
  case INVENTORY_ACCOUNT_STATUS_POLLING_ERROR:
@@ -67,6 +73,16 @@ export default (state = initialState, action) => {
67
73
  ...state,
68
74
  hostObfuscationEnabled,
69
75
  });
76
+ case EXCLUDE_PACKAGES_TOGGLE:
77
+ return state.merge({
78
+ ...state,
79
+ excludePackages,
80
+ });
81
+ case IPS_OBFUSCATION_TOGGLE:
82
+ return state.merge({
83
+ ...state,
84
+ ipsObfuscationEnabled,
85
+ });
70
86
  default:
71
87
  return state;
72
88
  }
@@ -16,4 +16,10 @@ export const selectAutoUploadEnabled = state =>
16
16
  export const selectHostObfuscationEnabled = state =>
17
17
  selectAccountsList(state).hostObfuscationEnabled;
18
18
 
19
+ export const selectIpsObfuscationEnabled = state =>
20
+ selectAccountsList(state).ipsObfuscationEnabled;
21
+
19
22
  export const selectCloudToken = state => selectAccountsList(state).cloudToken;
23
+
24
+ export const selectExcludePackages = state =>
25
+ selectAccountsList(state).excludePackages;
@@ -22,6 +22,13 @@ const fixtures = {
22
22
  'should stopAccountStatusPolling': () =>
23
23
  stopAccountStatusPolling(pollingProcessID),
24
24
  'should restartProcess': () => restartProcess(accountID, activeTab),
25
+ 'should invoke toast notification upon failure': () => {
26
+ API.post.mockImplementationOnce(() =>
27
+ Promise.reject(new Error('test error'))
28
+ );
29
+
30
+ return restartProcess(accountID, activeTab);
31
+ },
25
32
  };
26
33
 
27
34
  describe('AccountList actions', () => testActionSnapshotWithFixtures(fixtures));
@@ -9,29 +9,25 @@ import {
9
9
  } from '../AccountListConstants';
10
10
  import reducer from '../AccountListReducer';
11
11
  import {
12
- accounts,
13
12
  error,
14
13
  pollingProcessID,
15
14
  accountID,
16
15
  processStatusName,
17
16
  autoUploadEnabled,
18
17
  hostObfuscationEnabled,
19
- cloudToken,
18
+ ipsObfuscationEnabled,
19
+ pollingResponse,
20
20
  } from '../AccountList.fixtures';
21
21
  import { AUTO_UPLOAD_TOGGLE } from '../../AutoUploadSwitcher/AutoUploadSwitcherConstants';
22
22
  import { HOST_OBFUSCATION_TOGGLE } from '../../HostObfuscationSwitcher/HostObfuscationSwitcherConstants';
23
+ import { IPS_OBFUSCATION_TOGGLE } from '../../IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants';
23
24
 
24
25
  const fixtures = {
25
26
  'should return the initial state': {},
26
27
  'should handle INVENTORY_ACCOUNT_STATUS_POLLING': {
27
28
  action: {
28
29
  type: INVENTORY_ACCOUNT_STATUS_POLLING,
29
- payload: {
30
- accounts,
31
- autoUploadEnabled,
32
- hostObfuscationEnabled,
33
- cloudToken,
34
- },
30
+ payload: pollingResponse,
35
31
  },
36
32
  },
37
33
  'should handle INVENTORY_ACCOUNT_STATUS_POLLING_ERROR': {
@@ -78,6 +74,14 @@ const fixtures = {
78
74
  },
79
75
  },
80
76
  },
77
+ 'should handle IPS_OBFUSCATION_TOGGLE': {
78
+ action: {
79
+ type: IPS_OBFUSCATION_TOGGLE,
80
+ payload: {
81
+ ipsObfuscationEnabled,
82
+ },
83
+ },
84
+ },
81
85
  };
82
86
 
83
87
  describe('AccountList reducer', () =>
@@ -5,12 +5,16 @@ import {
5
5
  selectPollingProcessID,
6
6
  selectAutoUploadEnabled,
7
7
  selectHostObfuscationEnabled,
8
+ selectCloudToken,
9
+ selectExcludePackages,
8
10
  } from '../AccountListSelectors';
9
11
  import {
10
12
  pollingProcessID,
11
13
  accounts,
12
14
  autoUploadEnabled,
13
15
  hostObfuscationEnabled,
16
+ cloudToken,
17
+ excludePackages,
14
18
  } from '../AccountList.fixtures';
15
19
  import { rhCloudStateWrapper } from '../../../../ForemanRhCloudTestHelpers';
16
20
 
@@ -20,6 +24,8 @@ const state = rhCloudStateWrapper({
20
24
  pollingProcessID,
21
25
  autoUploadEnabled,
22
26
  hostObfuscationEnabled,
27
+ cloudToken,
28
+ excludePackages,
23
29
  },
24
30
  });
25
31
 
@@ -32,6 +38,9 @@ const fixtures = {
32
38
  selectAutoUploadEnabled(state),
33
39
  'should return AccountList hostObfuscationEnabled': () =>
34
40
  selectHostObfuscationEnabled(state),
41
+ 'should return AccountList cloudToken': () => selectCloudToken(state),
42
+ 'should return AccountList excludePackages': () =>
43
+ selectExcludePackages(state),
35
44
  };
36
45
 
37
46
  describe('AccountList selectors', () =>