foreman_rh_cloud 0.9.6 → 0.9.7

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +2 -6
  3. data/app/controllers/foreman_rh_cloud/react_controller.rb +8 -0
  4. data/app/models/setting/rh_cloud.rb +1 -0
  5. data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +1 -0
  6. data/app/views/{foreman_inventory_upload/layouts/react.html.erb → layouts/foreman_rh_cloud/application.html.erb} +2 -2
  7. data/config/routes.rb +4 -1
  8. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +43 -0
  9. data/lib/foreman_inventory_upload/generators/queries.rb +5 -0
  10. data/lib/foreman_inventory_upload/generators/slice.rb +2 -1
  11. data/lib/foreman_rh_cloud/engine.rb +16 -4
  12. data/lib/foreman_rh_cloud/version.rb +1 -1
  13. data/test/unit/slice_generator_test.rb +132 -0
  14. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +6 -2
  15. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +13 -10
  16. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +3 -2
  17. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +10 -0
  18. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +1 -1
  19. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/EmptyResults.js +15 -0
  20. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +13 -0
  21. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +18 -0
  22. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss +7 -0
  23. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/index.js +1 -0
  24. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +1 -4
  25. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +1 -0
  26. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +12 -0
  27. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +1 -1
  28. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +7 -8
  29. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +2 -3
  30. data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +2 -0
  31. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +4 -1
  32. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +4 -3
  33. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +1 -1
  34. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +2 -3
  35. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +1 -1
  36. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +3 -2
  37. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js +26 -0
  38. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/index.js +1 -0
  39. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js +2 -0
  40. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +39 -0
  41. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterActions.js +16 -0
  42. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterConstants.js +3 -0
  43. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +36 -0
  44. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterSelectors.js +7 -0
  45. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +14 -0
  46. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +14 -0
  47. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +35 -0
  48. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +21 -0
  49. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +25 -0
  50. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +17 -0
  51. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +25 -0
  52. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +9 -0
  53. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +31 -0
  54. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +18 -0
  55. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/index.js +17 -0
  56. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/inventoryFilter.scss +28 -0
  57. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +12 -3
  58. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +11 -2
  59. data/webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss +3 -0
  60. data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +3 -0
  61. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +4 -0
  62. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +16 -8
  63. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +4 -4
  64. data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +11 -0
  65. data/webpack/ForemanInventoryUpload/{ForemanInventoryUpload.test.js → __tests__/ForemanInventoryUpload.test.js} +1 -1
  66. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +3 -0
  67. data/webpack/ForemanInventoryUpload/{__snapshots__ → __tests__/__snapshots__}/ForemanInventoryUpload.test.js.snap +0 -0
  68. data/webpack/ForemanRhCloudHelpers.js +6 -0
  69. data/webpack/ForemanRhCloudReducers.js +8 -0
  70. data/webpack/ForemanRhCloudSelectors.js +3 -0
  71. data/webpack/ForemanRhCloudTestHelpers.js +5 -0
  72. data/webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js +1 -0
  73. data/webpack/__tests__/ForemanRhCloudHelpers.test.js +11 -0
  74. data/webpack/__tests__/ForemanRhCloudSelectors.test.js +17 -0
  75. data/webpack/__tests__/ForemanRhCloudTestHelpers.test.js +10 -0
  76. data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +3 -0
  77. data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +15 -0
  78. data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +11 -0
  79. data/webpack/index.js +1 -1
  80. metadata +49 -9
  81. data/app/controllers/foreman_inventory_upload/react_controller.rb +0 -7
  82. data/test/unit/slice_generator_test.rb.orig +0 -280
  83. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +0 -4
@@ -0,0 +1,6 @@
1
+ /**
2
+ * copied from core, since it's not in the ReactApp folder,
3
+ * it's complicated to import it and mock it in tests.
4
+ * should be imported once core moves it to the ReactApp folder.
5
+ */
6
+ export const foremanUrl = path => `${window.URL_PREFIX}${path}`;
@@ -0,0 +1,8 @@
1
+ import { combineReducers } from 'redux';
2
+ import inventoryUploadReducers from './ForemanInventoryUpload/ForemanInventoryUploadReducers';
3
+
4
+ export default {
5
+ ForemanRhCloud: combineReducers({
6
+ ...inventoryUploadReducers,
7
+ }),
8
+ };
@@ -0,0 +1,3 @@
1
+ export const selectForemanRhCloud = state => state.ForemanRhCloud;
2
+ export const selectForemanInventoryUpload = state =>
3
+ selectForemanRhCloud(state).inventoryUpload;
@@ -0,0 +1,5 @@
1
+ export const inventoryStateWrapper = innerState => ({
2
+ ForemanRhCloud: {
3
+ inventoryUpload: { ...innerState },
4
+ },
5
+ });
@@ -0,0 +1 @@
1
+ export const LAYOUT_CHANGE_ORG = 'LAYOUT_CHANGE_ORG';
@@ -0,0 +1,11 @@
1
+ import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
2
+ import { foremanUrl } from '../ForemanRhCloudHelpers';
3
+
4
+ global.URL_PREFIX = 'MY_TEST_URL_PREFIX.example.com';
5
+
6
+ const fixtures = {
7
+ 'should return foreman Url': () => foremanUrl('/test_path'),
8
+ };
9
+
10
+ describe('ForemanRhCloud helpers', () =>
11
+ testSelectorsSnapshotWithFixtures(fixtures));
@@ -0,0 +1,17 @@
1
+ import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
2
+ import { inventoryStateWrapper } from '../ForemanRhCloudTestHelpers';
3
+ import {
4
+ selectForemanRhCloud,
5
+ selectForemanInventoryUpload,
6
+ } from '../ForemanRhCloudSelectors';
7
+
8
+ const state = inventoryStateWrapper({ inventoryReducersNamespaces: {} });
9
+
10
+ const fixtures = {
11
+ 'should return ForemanRhCloud': () => selectForemanRhCloud(state),
12
+ 'should return ForemanInventoryUpload': () =>
13
+ selectForemanInventoryUpload(state),
14
+ };
15
+
16
+ describe('ForemanRhCloud selectors', () =>
17
+ testSelectorsSnapshotWithFixtures(fixtures));
@@ -0,0 +1,10 @@
1
+ import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
2
+ import { inventoryStateWrapper } from '../ForemanRhCloudTestHelpers';
3
+
4
+ const fixtures = {
5
+ 'should return inventory wrapper': () =>
6
+ inventoryStateWrapper({ inventoryChildren: null }),
7
+ };
8
+
9
+ describe('ForemanRhCloud helpers', () =>
10
+ testSelectorsSnapshotWithFixtures(fixtures));
@@ -0,0 +1,3 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ForemanRhCloud helpers should return foreman Url 1`] = `"MY_TEST_URL_PREFIX.example.com/test_path"`;
@@ -0,0 +1,15 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ForemanRhCloud selectors should return ForemanInventoryUpload 1`] = `
4
+ Object {
5
+ "inventoryReducersNamespaces": Object {},
6
+ }
7
+ `;
8
+
9
+ exports[`ForemanRhCloud selectors should return ForemanRhCloud 1`] = `
10
+ Object {
11
+ "inventoryUpload": Object {
12
+ "inventoryReducersNamespaces": Object {},
13
+ },
14
+ }
15
+ `;
@@ -0,0 +1,11 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ForemanRhCloud helpers should return inventory wrapper 1`] = `
4
+ Object {
5
+ "ForemanRhCloud": Object {
6
+ "inventoryUpload": Object {
7
+ "inventoryChildren": null,
8
+ },
9
+ },
10
+ }
11
+ `;
data/webpack/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable import/extensions */
4
4
  import componentRegistry from 'foremanReact/components/componentRegistry';
5
5
  import { registerReducer } from 'foremanReact/common/MountingService';
6
- import reducers from './ForemanInventoryUpload/ForemanInventoryUploadReducers';
6
+ import reducers from './ForemanRhCloudReducers';
7
7
  import ForemanInventoryUpload from './ForemanInventoryUpload';
8
8
 
9
9
  // register reducers
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: 0.9.6
4
+ version: 0.9.7
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: 2020-04-22 00:00:00.000000000 Z
11
+ date: 2020-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello
@@ -77,12 +77,13 @@ files:
77
77
  - README.md
78
78
  - Rakefile
79
79
  - app/controllers/foreman_inventory_upload/accounts_controller.rb
80
- - app/controllers/foreman_inventory_upload/react_controller.rb
81
80
  - app/controllers/foreman_inventory_upload/reports_controller.rb
82
81
  - app/controllers/foreman_inventory_upload/uploads_controller.rb
82
+ - app/controllers/foreman_rh_cloud/react_controller.rb
83
83
  - app/helpers/foreman_inventory_upload_helper.rb
84
84
  - app/models/setting/rh_cloud.rb
85
- - app/views/foreman_inventory_upload/layouts/react.html.erb
85
+ - app/views/foreman_rh_cloud/react/inventory_upload.html.erb
86
+ - app/views/layouts/foreman_rh_cloud/application.html.erb
86
87
  - config/routes.rb
87
88
  - lib/foreman_inventory_upload.rb
88
89
  - lib/foreman_inventory_upload/async/async_helpers.rb
@@ -119,7 +120,6 @@ files:
119
120
  - test/unit/metadata_generator_test.rb
120
121
  - test/unit/shell_process_job_test.rb
121
122
  - test/unit/slice_generator_test.rb
122
- - test/unit/slice_generator_test.rb.orig
123
123
  - webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js
124
124
  - webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
125
125
  - webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js
@@ -128,6 +128,11 @@ files:
128
128
  - webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js
129
129
  - webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
130
130
  - webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js
131
+ - webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/EmptyResults.js
132
+ - webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js
133
+ - webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap
134
+ - webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss
135
+ - webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/index.js
131
136
  - webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.fixtures.js
132
137
  - webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.js
133
138
  - webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyStateHelper.js
@@ -158,6 +163,7 @@ files:
158
163
  - webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss
159
164
  - webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js
160
165
  - webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js
166
+ - webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js
161
167
  - webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js
162
168
  - webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js
163
169
  - webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js
@@ -210,6 +216,26 @@ files:
210
216
  - webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap
211
217
  - webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss
212
218
  - webpack/ForemanInventoryUpload/Components/FullScreenModal/index.js
219
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js
220
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/index.js
221
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js
222
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
223
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterActions.js
224
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterConstants.js
225
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js
226
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterSelectors.js
227
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js
228
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js
229
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js
230
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js
231
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap
232
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap
233
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap
234
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap
235
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap
236
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js
237
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/index.js
238
+ - webpack/ForemanInventoryUpload/Components/InventoryFilter/inventoryFilter.scss
213
239
  - webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js
214
240
  - webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.js
215
241
  - webpack/ForemanInventoryUpload/Components/NavContainer/NavContainerHelper.js
@@ -221,6 +247,7 @@ files:
221
247
  - webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js
222
248
  - webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap
223
249
  - webpack/ForemanInventoryUpload/Components/PageHeader/index.js
250
+ - webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss
224
251
  - webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js
225
252
  - webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js
226
253
  - webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerateHelper.js
@@ -284,15 +311,29 @@ files:
284
311
  - webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap
285
312
  - webpack/ForemanInventoryUpload/Components/Terminal/index.js
286
313
  - webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss
314
+ - webpack/ForemanInventoryUpload/ForemanInventoryConstants.js
315
+ - webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js
287
316
  - webpack/ForemanInventoryUpload/ForemanInventoryUpload.js
288
- - webpack/ForemanInventoryUpload/ForemanInventoryUpload.test.js
289
317
  - webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js
290
- - webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js
291
- - webpack/ForemanInventoryUpload/__snapshots__/ForemanInventoryUpload.test.js.snap
318
+ - webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js
319
+ - webpack/ForemanInventoryUpload/__tests__/ForemanInventoryUpload.test.js
320
+ - webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap
321
+ - webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap
292
322
  - webpack/ForemanInventoryUpload/index.js
323
+ - webpack/ForemanRhCloudHelpers.js
324
+ - webpack/ForemanRhCloudReducers.js
325
+ - webpack/ForemanRhCloudSelectors.js
326
+ - webpack/ForemanRhCloudTestHelpers.js
293
327
  - webpack/__mocks__/foremanReact/API.js
294
328
  - webpack/__mocks__/foremanReact/common/I18n.js
295
329
  - webpack/__mocks__/foremanReact/common/helpers.js
330
+ - webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js
331
+ - webpack/__tests__/ForemanRhCloudHelpers.test.js
332
+ - webpack/__tests__/ForemanRhCloudSelectors.test.js
333
+ - webpack/__tests__/ForemanRhCloudTestHelpers.test.js
334
+ - webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap
335
+ - webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap
336
+ - webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap
296
337
  - webpack/index.js
297
338
  - webpack/stories/ForemanInventoryUploadReducers.js
298
339
  - webpack/stories/configureStore.js
@@ -332,7 +373,6 @@ test_files:
332
373
  - test/factories/inventory_upload_factories.rb
333
374
  - test/unit/shell_process_job_test.rb
334
375
  - test/unit/metadata_generator_test.rb
335
- - test/unit/slice_generator_test.rb.orig
336
376
  - test/unit/fact_helpers_test.rb
337
377
  - test/unit/archived_report_generator_test.rb
338
378
  - test/unit/slice_generator_test.rb
@@ -1,7 +0,0 @@
1
- module ForemanInventoryUpload
2
- class ReactController < ::ApplicationController
3
- def index
4
- render 'foreman_inventory_upload/layouts/react', :layout => false
5
- end
6
- end
7
- end
@@ -1,280 +0,0 @@
1
- require 'test_plugin_helper'
2
-
3
- class ReportGeneratorTest < ActiveSupport::TestCase
4
- setup do
5
- User.current = User.find_by(login: 'secret_admin')
6
-
7
- env = FactoryBot.create(:katello_k_t_environment)
8
- cv = env.content_views << FactoryBot.create(:katello_content_view, organization: env.organization)
9
-
10
- @host = FactoryBot.create(
11
- :host,
12
- :with_subscription,
13
- :with_content,
14
- content_view: cv.first,
15
- lifecycle_environment: env,
16
- organization: env.organization
17
- )
18
-
19
- @host.organization.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
20
-
21
- ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
22
- end
23
-
24
- def interesting_facts
25
- [
26
- 'dmi::system::uuid',
27
- 'virt::uuid',
28
- 'cpu::cpu(s)',
29
- 'cpu::cpu_socket(s)',
30
- 'cpu::core(s)_per_socket',
31
- 'memory::memtotal',
32
- 'dmi::bios::vendor',
33
- 'dmi::bios::version',
34
- 'dmi::bios::relase_date',
35
- 'uname::release',
36
- 'lscpu::flags',
37
- 'distribution::name',
38
- 'distribution::version',
39
- 'distribution::id',
40
- 'virt::is_guest',
41
- ]
42
- end
43
-
44
- def fact_names
45
- @fact_names ||= Hash[
46
- interesting_facts.map do |fact|
47
- [fact, FactoryBot.create(:fact_name, name: fact, type: 'Katello::RhsmFactName')]
48
- end
49
- ]
50
- end
51
-
52
- test 'generates a report for a single host' do
53
- batch = Host.where(id: @host.id).in_batches.first
54
- generator = create_generator(batch)
55
-
56
- json_str = generator.render
57
- actual = JSON.parse(json_str.join("\n"))
58
-
59
- assert_equal 'slice_123', actual['report_slice_id']
60
- assert_not_nil(actual_host = actual['hosts'].first)
61
- assert_equal @host.name, actual_host['display_name']
62
- assert_equal @host.fqdn, actual_host['fqdn']
63
- assert_equal '1234', actual_host['account']
64
- assert_equal 1, generator.hosts_count
65
- end
66
-
67
- test 'generates a report with satellite facts' do
68
- Foreman.expects(:instance_id).twice.returns('satellite-id')
69
- batch = Host.where(id: @host.id).in_batches.first
70
- generator = create_generator(batch)
71
-
72
- json_str = generator.render
73
- actual = JSON.parse(json_str.join("\n"))
74
-
75
- facts = actual['hosts'].first['facts'].first
76
- assert_equal 'satellite', facts['namespace']
77
- satellite_facts = facts['facts']
78
- assert_equal 'satellite-id', satellite_facts['satellite_instance_id']
79
- assert_equal @host.organization_id, satellite_facts['organization_id']
80
-
81
- instance_id_tag = actual['hosts'].first['tags'].find { |tag| tag['namespace'] == 'satellite' && tag['key'] == 'satellite_instance_id' }
82
- assert_not_nil instance_id_tag
83
- assert_equal 'satellite-id', instance_id_tag['value']
84
-
85
- org_id_tag = actual['hosts'].first['tags'].find { |tag| tag['namespace'] == 'satellite' && tag['key'] == 'organization_id' }
86
- assert_not_nil org_id_tag
87
- assert_equal @host.organization_id.to_s, org_id_tag['value']
88
-
89
- version = satellite_facts['satellite_version']
90
- if defined?(ForemanThemeSatellite)
91
- assert_equal ForemanThemeSatellite::SATELLITE_VERSION, version
92
- else
93
- assert_nil version
94
- end
95
- end
96
-
97
- test 'generates a report for a host with hypervisor' do
98
- hypervisor_host = FactoryBot.create(
99
- :host,
100
- :with_subscription,
101
- :with_content,
102
- content_view: @host.content_view,
103
- lifecycle_environment: @host.lifecycle_environment,
104
- organization: @host.organization
105
- )
106
-
107
- @host.subscription_facet.hypervisor_host = hypervisor_host
108
- @host.save!
109
-
110
- batch = Host.where(id: @host.id).in_batches.first
111
- generator = create_generator(batch)
112
-
113
- json_str = generator.render
114
- actual = JSON.parse(json_str.join("\n"))
115
-
116
- assert_equal 'slice_123', actual['report_slice_id']
117
- assert_not_nil(actual_host = actual['hosts'].first)
118
- assert_equal @host.name, actual_host['display_name']
119
- assert_equal @host.fqdn, actual_host['fqdn']
120
- assert_not_nil(host_facts = actual_host['facts']&.first)
121
- assert_equal 'satellite', host_facts['namespace']
122
- assert_not_nil(fact_values = host_facts['facts'])
123
- assert_equal hypervisor_host.name, fact_values['virtual_host_name']
124
- assert_equal hypervisor_host.subscription_facet.uuid, fact_values['virtual_host_uuid']
125
- end
126
-
127
- test 'generates a report with system purpose' do
128
- @host.subscription_facet.purpose_usage = 'test_usage'
129
- @host.subscription_facet.purpose_role = 'test_role'
130
- @host.subscription_facet.save!
131
-
132
- batch = Host.where(id: @host.id).in_batches.first
133
- generator = create_generator(batch)
134
-
135
- json_str = generator.render
136
- actual = JSON.parse(json_str.join("\n"))
137
-
138
- assert_equal 'slice_123', actual['report_slice_id']
139
- assert_not_nil(actual_host = actual['hosts'].first)
140
- assert_equal @host.name, actual_host['display_name']
141
- assert_equal @host.fqdn, actual_host['fqdn']
142
- assert_not_nil(host_facts = actual_host['facts']&.first)
143
- assert_equal 'satellite', host_facts['namespace']
144
- assert_not_nil(fact_values = host_facts['facts'])
145
- assert_equal 'test_usage', fact_values['system_purpose_usage']
146
- assert_equal 'test_role', fact_values['system_purpose_role']
147
- end
148
-
149
- test 'generates a report for a golden ticket' do
150
- batch = Host.where(id: @host.id).in_batches.first
151
- generator = create_generator(batch) do |generator|
152
- generator.stubs(:golden_ticket?).returns(true)
153
- end
154
-
155
- json_str = generator.render
156
- actual = JSON.parse(json_str.join("\n"))
157
-
158
- assert_equal 'slice_123', actual['report_slice_id']
159
- assert_not_nil(actual_host = actual['hosts'].first)
160
- assert_equal @host.name, actual_host['display_name']
161
- assert_equal @host.fqdn, actual_host['fqdn']
162
- assert_equal '1234', actual_host['account']
163
- assert_equal 1, generator.hosts_count
164
- end
165
-
166
- test 'skips hosts without subscription' do
167
- a_host = FactoryBot.create(
168
- :host,
169
- organization: @host.organization
170
- )
171
-
172
- # make a_host last
173
- batch = Host.where(id: [@host.id, a_host.id]).order(:name).in_batches.first
174
- generator = create_generator(batch)
175
-
176
- json_str = generator.render
177
- actual = JSON.parse(json_str.join("\n"))
178
-
179
- assert_equal 'slice_123', actual['report_slice_id']
180
- assert_not_nil(actual_host = actual['hosts'].first)
181
- assert_equal @host.name, actual_host['display_name']
182
- assert_equal @host.fqdn, actual_host['fqdn']
183
- assert_equal '1234', actual_host['account']
184
- assert_equal 1, generator.hosts_count
185
- end
186
-
187
- test 'shows system_memory_bytes in bytes' do
188
- FactoryBot.create(:fact_value, fact_name: fact_names['memory::memtotal'], value: '1', host: @host)
189
-
190
- batch = Host.where(id: @host.id).in_batches.first
191
- generator = create_generator(batch)
192
-
193
- json_str = generator.render
194
- actual = JSON.parse(json_str.join("\n"))
195
-
196
- assert_equal 'slice_123', actual['report_slice_id']
197
- assert_not_nil(actual_host = actual['hosts'].first)
198
- assert_not_nil(actual_profile = actual_host['system_profile'])
199
- assert_equal 1024, actual_profile['system_memory_bytes']
200
- end
201
-
202
- test 'reports an account for hosts with multiple pools' do
203
- first_pool = @host.organization.pools.first
204
- second_pool = FactoryBot.create(:katello_pool, account_number: nil, cp_id: 2)
205
- new_org = FactoryBot.create(:organization, pools: [first_pool, second_pool])
206
- @host.organization = new_org
207
- @host.save!
208
-
209
- batch = Host.where(id: @host.id).in_batches.first
210
- generator = create_generator(batch)
211
-
212
- json_str = generator.render
213
- actual = JSON.parse(json_str.join("\n"))
214
-
215
- assert_equal 'slice_123', actual['report_slice_id']
216
- assert_not_nil(actual_host = actual['hosts'].first)
217
- assert_not_nil(actual_host['account'])
218
- assert_not_empty(actual_host['account'])
219
- end
220
-
221
- test 'Generates os_release with version and id' do
222
- FactoryBot.create(:fact_value, fact_name: fact_names['distribution::name'], value: 'Red Hat Test Linux', host: @host)
223
- FactoryBot.create(:fact_value, fact_name: fact_names['distribution::version'], value: '7.1', host: @host)
224
- FactoryBot.create(:fact_value, fact_name: fact_names['distribution::id'], value: 'TestId', host: @host)
225
-
226
- batch = Host.where(id: @host.id).in_batches.first
227
- generator = create_generator(batch)
228
-
229
- json_str = generator.render
230
- actual = JSON.parse(json_str.join("\n"))
231
-
232
- assert_equal 'slice_123', actual['report_slice_id']
233
- assert_not_nil(actual_host = actual['hosts'].first)
234
- assert_not_nil(actual_profile = actual_host['system_profile'])
235
- assert_equal 'Red Hat Test Linux 7.1 (TestId)', actual_profile['os_release']
236
- end
237
-
238
- <<<<<<< HEAD
239
- test 'sets infrastructure_type to "virtual" based on virt.is_guest fact' do
240
- FactoryBot.create(:fact_value, fact_name: fact_names['virt::is_guest'], value: true, host: @host)
241
-
242
- batch = Host.where(id: @host.id).in_batches.first
243
- generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
244
-
245
- json_str = generator.render
246
- actual = JSON.parse(json_str.join("\n"))
247
-
248
- assert_equal 'slice_123', actual['report_slice_id']
249
- assert_not_nil(actual_host = actual['hosts'].first)
250
- assert_not_nil(actual_profile = actual_host['system_profile'])
251
- assert_equal 'virtual', actual_profile['infrastructure_type']
252
- end
253
-
254
- test 'sets infrastructure_type to "physical" based on virt.is_guest fact' do
255
- FactoryBot.create(:fact_value, fact_name: fact_names['virt::is_guest'], value: false, host: @host)
256
-
257
- batch = Host.where(id: @host.id).in_batches.first
258
- generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
259
-
260
- json_str = generator.render
261
- actual = JSON.parse(json_str.join("\n"))
262
-
263
- assert_equal 'slice_123', actual['report_slice_id']
264
- assert_not_nil(actual_host = actual['hosts'].first)
265
- assert_not_nil(actual_profile = actual_host['system_profile'])
266
- assert_equal 'physical', actual_profile['infrastructure_type']
267
- =======
268
- private
269
-
270
- def create_generator(batch, name = 'slice_123')
271
- generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], name)
272
- if block_given?
273
- yield(generator)
274
- else
275
- generator.stubs(:golden_ticket?).returns(false)
276
- end
277
- generator
278
- >>>>>>> Add support fo golden ticket
279
- end
280
- end