foreman_rh_cloud 13.2.8 → 13.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/insights_cloud/candlepin_proxies_extensions.rb +23 -0
  3. data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +9 -0
  4. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +13 -10
  5. data/app/controllers/insights_cloud/ui_requests_controller.rb +3 -7
  6. data/app/models/concerns/rh_cloud_host.rb +4 -2
  7. data/app/models/insights_client_report_status.rb +9 -1
  8. data/app/models/inventory_sync/inventory_status.rb +16 -4
  9. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +26 -4
  10. data/lib/foreman_inventory_upload.rb +8 -1
  11. data/lib/foreman_rh_cloud/engine.rb +1 -0
  12. data/lib/foreman_rh_cloud/version.rb +1 -1
  13. data/lib/foreman_rh_cloud.rb +36 -9
  14. data/lib/insights_cloud/async/insights_generate_notifications.rb +10 -1
  15. data/lib/inventory_sync/async/inventory_full_sync.rb +39 -3
  16. data/lib/inventory_sync/async/inventory_self_host_sync.rb +12 -2
  17. data/package.json +1 -1
  18. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +56 -2
  19. data/test/controllers/insights_cloud/candlepin_proxies_extensions_test.rb +70 -0
  20. data/test/controllers/insights_cloud/ui_requests_controller_test.rb +16 -2
  21. data/test/jobs/insights_client_status_aging_test.rb +40 -0
  22. data/test/jobs/insights_generate_notifications_test.rb +26 -0
  23. data/test/jobs/inventory_full_sync_test.rb +212 -0
  24. data/test/jobs/inventory_self_host_sync_test.rb +9 -0
  25. data/test/models/insights_client_report_status_test.rb +109 -0
  26. data/test/models/inventory_sync/inventory_status_test.rb +85 -0
  27. data/test/unit/foreman_rh_cloud_self_host_test.rb +50 -2
  28. data/test/unit/metadata_generator_test.rb +24 -1
  29. data/test/unit/rh_cloud_host_test.rb +60 -0
  30. data/webpack/CVEsHostDetailsTab/CVEsHostDetailsTab.js +24 -2
  31. data/webpack/CVEsHostDetailsTab/__tests__/CVEsHostDetailsTab.test.js +73 -10
  32. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +8 -2
  33. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +1 -0
  34. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js +1 -0
  35. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +43 -17
  36. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/__tests__/Toast.test.js +82 -0
  37. data/webpack/ForemanRhCloudHelpers.js +22 -0
  38. data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +27 -1
  39. data/webpack/InsightsHostDetailsTab/__tests__/NewHostDetailsTab.test.js +134 -22
  40. metadata +16 -2
@@ -2,9 +2,20 @@ import React from 'react';
2
2
  import { render } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom';
4
4
  import { Provider } from 'react-redux';
5
+ import { MemoryRouter } from 'react-router-dom';
5
6
  import configureMockStore from 'redux-mock-store';
6
7
  import thunk from 'redux-thunk';
7
8
  import NewHostDetailsTab from '../NewHostDetailsTab';
9
+ import { OVERVIEW_TAB_PATH } from '../../ForemanRhCloudHelpers';
10
+
11
+ const mockHistoryReplace = jest.fn();
12
+
13
+ jest.mock('react-router-dom', () => ({
14
+ ...jest.requireActual('react-router-dom'),
15
+ useHistory: () => ({
16
+ replace: mockHistoryReplace,
17
+ }),
18
+ }));
8
19
 
9
20
  jest.mock('../../common/Hooks/ConfigHooks', () => ({
10
21
  useIopConfig: jest.fn(() => false),
@@ -14,8 +25,33 @@ jest.mock('foremanReact/common/I18n', () => ({
14
25
  translate: jest.fn(str => str),
15
26
  }));
16
27
 
28
+ jest.mock(
29
+ 'foremanReact/components/SearchBar',
30
+ () => () => <div>SearchBar</div>,
31
+ { virtual: true }
32
+ );
33
+
34
+ jest.mock('../../InsightsCloudSync/Components/InsightsTable', () => () => (
35
+ <div>InsightsTable</div>
36
+ ));
37
+
38
+ jest.mock('../../InsightsCloudSync/Components/RemediationModal', () => () => (
39
+ <div>RemediationModal</div>
40
+ ));
41
+
42
+ jest.mock(
43
+ '../../InsightsCloudSync/Components/InsightsTable/Pagination',
44
+ () => () => <div>Pagination</div>
45
+ );
46
+
17
47
  const mockStore = configureMockStore([thunk]);
18
48
 
49
+ const defaultResponse = {
50
+ id: 1,
51
+ operatingsystem_name: 'Red Hat Enterprise Linux 8',
52
+ insights_attributes: { uuid: 'test-uuid' },
53
+ };
54
+
19
55
  describe('NewHostDetailsTab', () => {
20
56
  let store;
21
57
  let mockRouter;
@@ -68,17 +104,18 @@ describe('NewHostDetailsTab', () => {
68
104
  it('should preserve hash when clearing search params on unmount', () => {
69
105
  const { unmount } = render(
70
106
  <Provider store={store}>
71
- <NewHostDetailsTab
72
- hostName="test-host.example.com"
73
- router={mockRouter}
74
- />
107
+ <MemoryRouter>
108
+ <NewHostDetailsTab
109
+ hostName="test-host.example.com"
110
+ router={mockRouter}
111
+ response={defaultResponse}
112
+ />
113
+ </MemoryRouter>
75
114
  </Provider>
76
115
  );
77
116
 
78
- // Unmount the component to trigger cleanup
79
117
  unmount();
80
118
 
81
- // Verify router.replace was called with both search: null AND the existing hash
82
119
  expect(mockRouter.replace).toHaveBeenCalledWith({
83
120
  search: null,
84
121
  hash: '#/Insights',
@@ -90,16 +127,18 @@ describe('NewHostDetailsTab', () => {
90
127
 
91
128
  const { unmount } = render(
92
129
  <Provider store={store}>
93
- <NewHostDetailsTab
94
- hostName="test-host.example.com"
95
- router={mockRouter}
96
- />
130
+ <MemoryRouter>
131
+ <NewHostDetailsTab
132
+ hostName="test-host.example.com"
133
+ router={mockRouter}
134
+ response={defaultResponse}
135
+ />
136
+ </MemoryRouter>
97
137
  </Provider>
98
138
  );
99
139
 
100
140
  unmount();
101
141
 
102
- // When there's no hash, should only pass search: null
103
142
  expect(mockRouter.replace).toHaveBeenCalledWith({
104
143
  search: null,
105
144
  });
@@ -114,16 +153,18 @@ describe('NewHostDetailsTab', () => {
114
153
 
115
154
  const { unmount } = render(
116
155
  <Provider store={store}>
117
- <NewHostDetailsTab
118
- hostName="test-host.example.com"
119
- router={routerWithoutLocation}
120
- />
156
+ <MemoryRouter>
157
+ <NewHostDetailsTab
158
+ hostName="test-host.example.com"
159
+ router={routerWithoutLocation}
160
+ response={defaultResponse}
161
+ />
162
+ </MemoryRouter>
121
163
  </Provider>
122
164
  );
123
165
 
124
166
  unmount();
125
167
 
126
- // Should still call replace with search: null even if location is undefined
127
168
  expect(routerWithoutLocation.replace).toHaveBeenCalledWith({
128
169
  search: null,
129
170
  });
@@ -132,23 +173,94 @@ describe('NewHostDetailsTab', () => {
132
173
  it('should use the latest hash value at unmount time, not a stale captured value', () => {
133
174
  const { unmount } = render(
134
175
  <Provider store={store}>
135
- <NewHostDetailsTab
136
- hostName="test-host.example.com"
137
- router={mockRouter}
138
- />
176
+ <MemoryRouter>
177
+ <NewHostDetailsTab
178
+ hostName="test-host.example.com"
179
+ router={mockRouter}
180
+ response={defaultResponse}
181
+ />
182
+ </MemoryRouter>
139
183
  </Provider>
140
184
  );
141
185
 
142
- // Change the hash after mount, before unmount
143
186
  mockRouter.location.hash = '#/Overview';
144
187
 
145
188
  unmount();
146
189
 
147
- // Verify router.replace was called with the UPDATED hash, not the initial '#/Insights'
148
190
  expect(mockRouter.replace).toHaveBeenCalledWith({
149
191
  search: null,
150
192
  hash: '#/Overview',
151
193
  });
152
194
  });
153
195
  });
196
+
197
+ describe('tab visibility', () => {
198
+ it('should redirect to Overview when host is not RHEL', () => {
199
+ const nonRhelResponse = {
200
+ id: 2,
201
+ operatingsystem_name: 'Ubuntu 20.04',
202
+ insights_attributes: { uuid: 'test-uuid' },
203
+ };
204
+
205
+ render(
206
+ <Provider store={store}>
207
+ <MemoryRouter>
208
+ <NewHostDetailsTab
209
+ hostName="test-host.example.com"
210
+ response={nonRhelResponse}
211
+ />
212
+ </MemoryRouter>
213
+ </Provider>
214
+ );
215
+
216
+ expect(mockHistoryReplace).toHaveBeenCalledWith(OVERVIEW_TAB_PATH);
217
+ });
218
+
219
+ it('should redirect to Overview when insights facet is missing', () => {
220
+ const responseWithoutInsights = {
221
+ id: 3,
222
+ operatingsystem_name: 'Red Hat Enterprise Linux 8',
223
+ };
224
+
225
+ render(
226
+ <Provider store={store}>
227
+ <MemoryRouter>
228
+ <NewHostDetailsTab
229
+ hostName="test-host.example.com"
230
+ response={responseWithoutInsights}
231
+ />
232
+ </MemoryRouter>
233
+ </Provider>
234
+ );
235
+
236
+ expect(mockHistoryReplace).toHaveBeenCalledWith(OVERVIEW_TAB_PATH);
237
+ });
238
+
239
+ it('should not redirect when host is valid RHEL with insights facet', () => {
240
+ render(
241
+ <Provider store={store}>
242
+ <MemoryRouter>
243
+ <NewHostDetailsTab
244
+ hostName="test-host.example.com"
245
+ response={defaultResponse}
246
+ />
247
+ </MemoryRouter>
248
+ </Provider>
249
+ );
250
+
251
+ expect(mockHistoryReplace).not.toHaveBeenCalled();
252
+ });
253
+
254
+ it('should not redirect when host data is not yet loaded', () => {
255
+ render(
256
+ <Provider store={store}>
257
+ <MemoryRouter>
258
+ <NewHostDetailsTab hostName="test-host.example.com" response={{}} />
259
+ </MemoryRouter>
260
+ </Provider>
261
+ );
262
+
263
+ expect(mockHistoryReplace).not.toHaveBeenCalled();
264
+ });
265
+ });
154
266
  });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_rh_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.2.8
4
+ version: 13.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
@@ -30,6 +30,9 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 10.0.0
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: 13.0.0
33
36
  type: :runtime
34
37
  prerelease: false
35
38
  version_requirements: !ruby/object:Gem::Requirement
@@ -37,6 +40,9 @@ dependencies:
37
40
  - - ">="
38
41
  - !ruby/object:Gem::Version
39
42
  version: 10.0.0
43
+ - - "<"
44
+ - !ruby/object:Gem::Version
45
+ version: 13.0.0
40
46
  - !ruby/object:Gem::Dependency
41
47
  name: katello
42
48
  requirement: !ruby/object:Gem::Requirement
@@ -101,6 +107,7 @@ files:
101
107
  - app/controllers/concerns/foreman_rh_cloud/iop_smart_proxy_access.rb
102
108
  - app/controllers/concerns/foreman_rh_cloud/registration_manager_extensions.rb
103
109
  - app/controllers/concerns/insights_cloud/candlepin_cache.rb
110
+ - app/controllers/concerns/insights_cloud/candlepin_proxies_extensions.rb
104
111
  - app/controllers/concerns/insights_cloud/client_authentication.rb
105
112
  - app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb
106
113
  - app/controllers/concerns/inventory_upload/report_actions.rb
@@ -248,6 +255,7 @@ files:
248
255
  - test/controllers/insights_cloud/api/advisor_engine_controller_test.rb
249
256
  - test/controllers/insights_cloud/api/cloud_request_controller_test.rb
250
257
  - test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb
258
+ - test/controllers/insights_cloud/candlepin_proxies_extensions_test.rb
251
259
  - test/controllers/insights_cloud/ui_requests_controller_test.rb
252
260
  - test/controllers/insights_sync/settings_controller_test.rb
253
261
  - test/controllers/inventory_upload/api/inventory_controller_test.rb
@@ -263,6 +271,7 @@ files:
263
271
  - test/jobs/host_inventory_report_job_test.rb
264
272
  - test/jobs/insights_client_status_aging_test.rb
265
273
  - test/jobs/insights_full_sync_test.rb
274
+ - test/jobs/insights_generate_notifications_test.rb
266
275
  - test/jobs/insights_resolutions_sync_test.rb
267
276
  - test/jobs/insights_rules_sync_test.rb
268
277
  - test/jobs/inventory_full_sync_test.rb
@@ -274,6 +283,7 @@ files:
274
283
  - test/jobs/single_host_report_job_test.rb
275
284
  - test/jobs/upload_report_direct_job_test.rb
276
285
  - test/models/insights_client_report_status_test.rb
286
+ - test/models/inventory_sync/inventory_status_test.rb
277
287
  - test/test_plugin_helper.rb
278
288
  - test/unit/archived_report_generator_test.rb
279
289
  - test/unit/fact_helpers_test.rb
@@ -448,6 +458,7 @@ files:
448
458
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap
449
459
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
450
460
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js
461
+ - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/__tests__/Toast.test.js
451
462
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js
452
463
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js
453
464
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js
@@ -669,7 +680,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
669
680
  - !ruby/object:Gem::Version
670
681
  version: '0'
671
682
  requirements: []
672
- rubygems_version: 4.0.6
683
+ rubygems_version: 4.0.16
673
684
  specification_version: 4
674
685
  summary: Summary of ForemanRhCloud.
675
686
  test_files:
@@ -677,6 +688,7 @@ test_files:
677
688
  - test/controllers/insights_cloud/api/advisor_engine_controller_test.rb
678
689
  - test/controllers/insights_cloud/api/cloud_request_controller_test.rb
679
690
  - test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb
691
+ - test/controllers/insights_cloud/candlepin_proxies_extensions_test.rb
680
692
  - test/controllers/insights_cloud/ui_requests_controller_test.rb
681
693
  - test/controllers/insights_sync/settings_controller_test.rb
682
694
  - test/controllers/inventory_upload/api/inventory_controller_test.rb
@@ -692,6 +704,7 @@ test_files:
692
704
  - test/jobs/host_inventory_report_job_test.rb
693
705
  - test/jobs/insights_client_status_aging_test.rb
694
706
  - test/jobs/insights_full_sync_test.rb
707
+ - test/jobs/insights_generate_notifications_test.rb
695
708
  - test/jobs/insights_resolutions_sync_test.rb
696
709
  - test/jobs/insights_rules_sync_test.rb
697
710
  - test/jobs/inventory_full_sync_test.rb
@@ -703,6 +716,7 @@ test_files:
703
716
  - test/jobs/single_host_report_job_test.rb
704
717
  - test/jobs/upload_report_direct_job_test.rb
705
718
  - test/models/insights_client_report_status_test.rb
719
+ - test/models/inventory_sync/inventory_status_test.rb
706
720
  - test/test_plugin_helper.rb
707
721
  - test/unit/archived_report_generator_test.rb
708
722
  - test/unit/fact_helpers_test.rb