foreman_rh_cloud 1.0.5 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +0 -1
  3. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +7 -14
  4. data/config/routes.rb +0 -1
  5. data/lib/foreman_inventory_upload.rb +0 -12
  6. data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +0 -8
  7. data/lib/foreman_inventory_upload/async/upload_report_job.rb +1 -5
  8. data/lib/foreman_inventory_upload/generators/archived_report.rb +3 -6
  9. data/lib/foreman_inventory_upload/generators/queries.rb +0 -1
  10. data/lib/foreman_inventory_upload/generators/slice.rb +4 -20
  11. data/lib/foreman_rh_cloud/engine.rb +1 -5
  12. data/lib/foreman_rh_cloud/version.rb +1 -1
  13. data/package.json +20 -100
  14. data/test/controllers/accounts_controller_test.rb +3 -8
  15. data/test/controllers/uploads_controller_test.rb +0 -13
  16. data/test/unit/slice_generator_test.rb +2 -45
  17. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +0 -2
  18. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js +5 -14
  19. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +1 -2
  20. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +0 -8
  21. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +0 -2
  22. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +1 -1
  23. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +1 -1
  24. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +1 -1
  25. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +1 -1
  26. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +1 -1
  27. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +1 -1
  28. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +1 -1
  29. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +1 -12
  30. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +2 -10
  31. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +0 -10
  32. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +2 -5
  33. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +13 -9
  34. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.stories.js +5 -15
  35. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +1 -2
  36. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +15 -2
  37. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +2 -3
  38. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +1 -1
  39. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +1 -1
  40. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +1 -1
  41. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +1 -1
  42. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +5 -2
  43. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/NavContainer.test.js +1 -2
  44. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +1 -1
  45. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +1 -1
  46. data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +1 -1
  47. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.fixtures.js +0 -1
  48. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.js +2 -4
  49. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +2 -1
  50. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +2 -0
  51. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -12
  52. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +1 -1
  53. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +1 -1
  54. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +1 -1
  55. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +1 -1
  56. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +1 -1
  57. data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +1 -1
  58. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +1 -1
  59. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +1 -2
  60. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +4 -5
  61. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.test.js +1 -1
  62. data/webpack/ForemanInventoryUpload/__snapshots__/ForemanInventoryUpload.test.js.snap +5 -6
  63. metadata +2 -24
  64. data/app/models/setting/rh_cloud.rb +0 -13
  65. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +0 -1
  66. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +0 -32
  67. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +0 -27
  68. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +0 -2
  69. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcher.test.js +0 -14
  70. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +0 -14
  71. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +0 -38
  72. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +0 -14
  73. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/autoUploadSwitcher.scss +0 -3
  74. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/index.js +0 -17
  75. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +0 -21
  76. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +0 -13
  77. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +0 -33
  78. data/webpack/ForemanInventoryUpload/Components/PageHeader/index.js +0 -1
  79. data/webpack/stories/ForemanInventoryUploadReducers.js +0 -3
  80. data/webpack/stories/configureStore.js +0 -15
  81. data/webpack/stories/decorators/index.js +0 -1
  82. data/webpack/stories/decorators/withCardsDecorator.js +0 -14
  83. data/webpack/stories/index.js +0 -10
  84. data/webpack/stories/index.scss +0 -7
  85. data/webpack/test_setup.js +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5492f054563594467c7f237d388dbe7dbcb2ccd184e1d9eb493b31757f500c66
4
- data.tar.gz: 02cf9ab283f73239246cebf291dee44878f80734c694baab0610e748e707e975
3
+ metadata.gz: 1f6361a25739c19a67518378257d51f67fc443839d76d7d07f5bd597f09ef15d
4
+ data.tar.gz: b558ad39920b634ee4c9be77ec20f65235eb3193de374879dc85bc284a15bfa5
5
5
  SHA512:
6
- metadata.gz: '059b4ef6c7238a1efb31767e48e2edba060d33f915a0a8c0d9aa1b4552517a32aaecf0655f57ca9e34fd779a863d017f79983e66a813a4c6eb115ab8fba1d14b'
7
- data.tar.gz: 9fc152b2d8f82c9b42e59135b1a620808d3a8bada32f592aefab487caf3b3fd312a2bc89c23c650c1da06dd5b380ee40d9b746f9980f7e5f8459906f866b12f3
6
+ metadata.gz: 83b2169b736d8c57d544b8ce53bda7e91e4741efdd384953fd32a22ac96e531282e97ef740112a7be5310ef44fc0569fe8995972304844302d0b2eb3db6215f8
7
+ data.tar.gz: 3b7bbd7d76a68b5b41874472961eabd2360de0ad871705430d7549d8c44b48e5811ba9d566d74a3c0a8774b7c3b4c0c5a0f75ae57f2f38519ef528e12239c4f3
@@ -25,7 +25,6 @@ module ForemanInventoryUpload
25
25
  ]
26
26
 
27
27
  render json: {
28
- autoUploadEnabled: Setting[:allow_auto_inventory_upload],
29
28
  accounts: accounts,
30
29
  }, status: :ok
31
30
  end
@@ -11,10 +11,14 @@ module ForemanInventoryUpload
11
11
 
12
12
  def download_file
13
13
  filename = ForemanInventoryUpload.facts_archive_name(params[:organization_id])
14
- files = Dir["{#{ForemanInventoryUpload.uploads_file_path(filename)},#{ForemanInventoryUpload.done_file_path(filename)}}"]
14
+ path = Rails.root.join(ForemanInventoryUpload.uploads_folder, filename)
15
+ unless File.exist? path
16
+ return throw_flash_error(
17
+ "Path doesn't exist: #{path}"
18
+ )
19
+ end
15
20
 
16
- return send_file files.first, disposition: 'attachment', filename: filename unless files.empty?
17
- throw_flash_error "File doesn't exist"
21
+ send_file path, disposition: 'attachment', filename: filename
18
22
  end
19
23
 
20
24
  def throw_flash_error(message)
@@ -23,16 +27,5 @@ module ForemanInventoryUpload
23
27
  :error_msg => message
24
28
  )
25
29
  end
26
-
27
- def auto_upload
28
- Setting[:allow_auto_inventory_upload] = auto_upload_params
29
- render json: {
30
- autoUploadEnabled: Setting[:allow_auto_inventory_upload],
31
- }
32
- end
33
-
34
- def auto_upload_params
35
- ActiveModel::Type::Boolean.new.cast(params.require(:value))
36
- end
37
30
  end
38
31
  end
@@ -6,6 +6,5 @@ Rails.application.routes.draw do
6
6
  get ':organization_id/uploads/last', to: 'uploads#last', constraints: { organization_id: %r{[^\/]+} }
7
7
  get ':organization_id/uploads/file', to: 'uploads#download_file', constraints: { organization_id: %r{[^\/]+} }
8
8
  get 'accounts', to: 'accounts#index'
9
- post 'auto_upload', to: 'uploads#auto_upload'
10
9
  end
11
10
  end
@@ -18,18 +18,6 @@ module ForemanInventoryUpload
18
18
  )
19
19
  end
20
20
 
21
- def self.uploads_file_path(filename)
22
- File.join(ForemanInventoryUpload.uploads_folder, filename)
23
- end
24
-
25
- def self.done_folder
26
- File.join(ForemanInventoryUpload.uploads_folder, 'done/')
27
- end
28
-
29
- def self.done_file_path(filename)
30
- File.join(ForemanInventoryUpload.done_folder, filename)
31
- end
32
-
33
21
  def self.generated_reports_folder
34
22
  @generated_reports_folder ||= ensure_folder(
35
23
  File.join(
@@ -2,14 +2,6 @@ module ForemanInventoryUpload
2
2
  module Async
3
3
  class GenerateAllReportsJob < ::ApplicationJob
4
4
  def perform
5
- unless Setting[:allow_auto_inventory_upload]
6
- logger.debug(
7
- 'The scheduled process is disabled due to the "allow_auto_inventory_upload"
8
- setting being set to false.'
9
- )
10
- return
11
- end
12
-
13
5
  organizations = Organization.unscoped.all
14
6
 
15
7
  organizations.map do |organization|
@@ -37,11 +37,7 @@ module ForemanInventoryUpload
37
37
  end
38
38
 
39
39
  def http_proxy_string
40
- @http_proxy_string ||= begin
41
- if Setting[:content_default_http_proxy]
42
- HttpProxy.unscoped.find_by(name: Setting[:content_default_http_proxy])&.full_url
43
- end
44
- end
40
+ @http_proxy_string ||= HttpProxy.default_global_content_proxy&.full_url
45
41
  end
46
42
 
47
43
  def rh_credentials
@@ -16,9 +16,9 @@ module ForemanInventoryUpload
16
16
  first = true
17
17
  host_batches.each do |hosts_batch|
18
18
  slice_id = Foreman.uuid
19
- @logger.info "Adding slice #{slice_id}"
20
- hosts_count = generate_slice(tmpdir, slice_id, hosts_batch)
21
- @logger.info "slice #{slice_id} was created with #{hosts_count} hosts"
19
+ hosts_count = hosts_batch.count
20
+ @logger.info "Adding slice #{slice_id} with #{hosts_count} hosts"
21
+ generate_slice(tmpdir, slice_id, hosts_batch)
22
22
  inner_generator.add_slice(slice_id, hosts_count, first)
23
23
  first = false
24
24
  end
@@ -43,13 +43,10 @@ module ForemanInventoryUpload
43
43
  private
44
44
 
45
45
  def generate_slice(tmpdir, slice_id, hosts_batch)
46
- hosts_count = 0
47
46
  File.open(File.join(tmpdir, "#{slice_id}.json"), 'w') do |slice_out|
48
47
  slice_generator = ForemanInventoryUpload::Generators::Slice.new(hosts_batch, slice_out, slice_id)
49
48
  slice_generator.render
50
- hosts_count = slice_generator.hosts_count
51
49
  end
52
- hosts_count
53
50
  end
54
51
  end
55
52
  end
@@ -18,7 +18,6 @@ module ForemanInventoryUpload
18
18
  'uname::release',
19
19
  'lscpu::flags',
20
20
  'distribution::version',
21
- 'distribution::id',
22
21
  ]).pluck(:name, :id)
23
22
  ]
24
23
  end
@@ -4,13 +4,11 @@ module ForemanInventoryUpload
4
4
  include FactHelpers
5
5
 
6
6
  attr_accessor :slice_id
7
- attr_reader :hosts_count
8
7
 
9
8
  def initialize(hosts, output = [], slice_id = Foreman.uuid)
10
9
  @stream = JsonStream.new(output)
11
10
  @hosts = hosts
12
11
  @slice_id = slice_id
13
- @hosts_count = 0
14
12
  end
15
13
 
16
14
  def render
@@ -28,10 +26,7 @@ module ForemanInventoryUpload
28
26
  hosts_batch.each do |host|
29
27
  next unless host&.subscription_facet&.pools&.first
30
28
  @stream.comma unless first
31
- if report_host(host)
32
- first = false
33
- @hosts_count += 1
34
- end
29
+ first = false if report_host(host)
35
30
  end
36
31
  end
37
32
  end
@@ -41,7 +36,7 @@ module ForemanInventoryUpload
41
36
  @stream.object do
42
37
  @stream.simple_field('display_name', host.name)
43
38
  @stream.simple_field('fqdn', host.fqdn)
44
- @stream.simple_field('account', host.subscription_facet.pools.where.not(account_number: nil).first&.account_number&.to_s)
39
+ @stream.simple_field('account', host.subscription_facet.pools.first.account_number.to_s)
45
40
  @stream.simple_field('subscription_manager_id', host.subscription_facet.uuid)
46
41
  @stream.simple_field('satellite_id', host.subscription_facet.uuid)
47
42
  @stream.simple_field('bios_uuid', fact_value(host, 'dmi::system::uuid'))
@@ -70,7 +65,7 @@ module ForemanInventoryUpload
70
65
 
71
66
  @stream.array_field('tags', :last) do
72
67
  report_tag('satellite', 'satellite_instance_id', Foreman.instance_id) if Foreman.respond_to?(:instance_id)
73
- report_tag('satellite', 'organization_id', host.organization_id.to_s, :last)
68
+ report_tag('satellite', 'organization_id', host.organization_id, :last)
74
69
  end
75
70
  end
76
71
  end
@@ -110,14 +105,7 @@ module ForemanInventoryUpload
110
105
  end.join(', '))
111
106
  end
112
107
  end
113
- @stream.simple_field(
114
- 'os_release',
115
- os_release_value(
116
- name: fact_value(host, 'distribution::name'),
117
- version: fact_value(host, 'distribution::version'),
118
- codename: fact_value(host, 'distribution::id')
119
- )
120
- )
108
+ @stream.simple_field('os_release', fact_value(host, 'distribution::name'))
121
109
  @stream.simple_field('os_kernel_version', fact_value(host, 'uname::release'))
122
110
  @stream.simple_field('arch', host.architecture&.name)
123
111
  @stream.simple_field('subscription_status', host.subscription_status_label)
@@ -154,10 +142,6 @@ module ForemanInventoryUpload
154
142
  @stream.simple_field('satellite_instance_id', Foreman.respond_to?(:instance_id) ? Foreman.instance_id : nil)
155
143
  @stream.simple_field('organization_id', host.organization_id, :last)
156
144
  end
157
-
158
- def os_release_value(name:, version:, codename:)
159
- "#{name} #{version} (#{codename})"
160
- end
161
145
  end
162
146
  end
163
147
  end
@@ -5,10 +5,6 @@ module ForemanRhCloud
5
5
  class Engine < ::Rails::Engine
6
6
  engine_name 'foreman_rh_cloud'
7
7
 
8
- initializer 'foreman_rh_cloud.load_default_settings', :before => :load_config_initializers do
9
- require_dependency File.expand_path('../../app/models/setting/rh_cloud.rb', __dir__)
10
- end
11
-
12
8
  config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
13
9
  config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
14
10
  config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
@@ -26,7 +22,7 @@ module ForemanRhCloud
26
22
 
27
23
  initializer 'foreman_rh_cloud.register_plugin', :before => :finisher_hook do |_app|
28
24
  Foreman::Plugin.register :foreman_rh_cloud do
29
- requires_foreman '~> 1.24.0'
25
+ requires_foreman '> 1.24'
30
26
 
31
27
  # Add permissions
32
28
  security_block :foreman_rh_cloud do
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '1.0.5'.freeze
2
+ VERSION = '2.0.4'.freeze
3
3
  end
@@ -4,14 +4,14 @@
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "lint": "./node_modules/.bin/eslint -c .eslintrc webpack/",
8
- "test": "node node_modules/.bin/jest --no-cache",
9
- "test:watch": "node node_modules/.bin/jest --watchAll",
10
- "test:current": "node node_modules/.bin/jest --watch",
11
- "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
12
- "storybook": "start-storybook -p 6006",
13
- "storybook:build": "node --max_old_space_size=2048 ./node_modules/.bin/build-storybook --config-dir .storybook --output-dir .storybook-dist",
14
- "storybook:deploy": "surge --project .storybook-dist"
7
+ "lint": "tfm-lint --plugin -d /webpack",
8
+ "test": "tfm-test --plugin",
9
+ "test:watch": "tfm-test --plugin --watchAll",
10
+ "test:current": "tfm-test --plugin --watch",
11
+ "publish-coverage": "tfm-publish-coverage",
12
+ "stories": "tfm-stories --plugin",
13
+ "stories:build": "tfm-build-stories --plugin",
14
+ "stories:deploy": "surge --project .storybook-dist"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -20,106 +20,26 @@
20
20
  "bugs": {
21
21
  "url": "http://projects.theforeman.org/projects/foreman_rh_cloud/issues"
22
22
  },
23
- "optionalDependencies": {
24
- "babel-plugin-module-resolver": "^3.2.0"
23
+ "peerDependencies": {
24
+ "@theforeman/vendor": ">= 4.0.2"
25
25
  },
26
26
  "devDependencies": {
27
- "@storybook/addon-actions": "^5.0.1",
28
- "@storybook/addon-knobs": "^5.0.1",
29
- "@storybook/react": "^5.0.1",
30
- "babel-cli": "^6.10.1",
31
- "babel-core": "^6.26.3",
32
- "babel-eslint": "^8.2.3",
33
- "babel-jest": "^23.6.0",
34
- "babel-loader": "^7.1.1",
35
- "babel-plugin-dynamic-import-node": "^2.0.0",
36
- "babel-plugin-lodash": "^3.3.4",
37
- "babel-plugin-syntax-dynamic-import": "^6.18.0",
38
- "babel-plugin-transform-class-properties": "^6.24.1",
39
- "babel-plugin-transform-object-assign": "^6.8.0",
40
- "babel-plugin-transform-object-rest-spread": "^6.8.0",
41
- "babel-preset-env": "^1.7.0",
42
- "babel-preset-react": "^6.5.0",
43
- "coveralls": "^3.0.0",
44
- "enzyme": "^3.4.0",
45
- "enzyme-adapter-react-16": "^1.4.0",
46
- "enzyme-to-json": "^3.2.1",
47
- "eslint": "^4.10.0",
48
- "eslint-import-resolver-babel-module": "^4.0.0",
49
- "eslint-plugin-patternfly-react": "0.2.0",
50
- "identity-obj-proxy": "^3.0.0",
51
- "jed": "^1.1.1",
52
- "jest-cli": "^23.6.0",
53
- "jest-prop-type-error": "^1.1.0",
54
- "node-sass": "^4.5.0",
55
- "patternfly": "^3.58.0",
27
+ "@babel/core": "^7.7.0",
28
+ "@theforeman/builder": "^4.0.2",
29
+ "@theforeman/stories": "^4.0.2",
30
+ "@theforeman/test": "^4.0.2",
31
+ "@theforeman/vendor-dev": "^4.0.2",
32
+ "@theforeman/eslint-plugin-foreman": "^4.0.2",
33
+ "babel-eslint": "^10.0.0",
34
+ "eslint": "^6.7.2",
56
35
  "prettier": "^1.13.5",
57
36
  "raf": "^3.4.0",
58
- "react-redux-test-utils": "^0.1.1",
59
- "react-remarkable": "^1.1.3",
60
- "sass-loader": "^6.0.7",
61
37
  "stylelint": "^9.3.0",
62
38
  "stylelint-config-standard": "^18.0.0",
63
39
  "surge": "^0.20.3"
64
40
  },
65
41
  "dependencies": {
66
- "babel-polyfill": "^6.26.0",
67
- "classnames": "^2.2.5",
68
- "lodash": "^4.17.10",
69
- "patternfly-react": "^2.19.1",
70
- "prop-types": "^15.6.0",
71
- "react": "^16.4.0",
72
- "react-dom": "^16.4.0",
73
- "react-intl": "^2.8.0",
74
- "react-redux": "^5.0.6",
75
- "redux": "^3.6.0",
76
- "redux-thunk": "^2.2.0",
77
- "reselect": "^3.0.1",
78
- "seamless-immutable": "^7.1.2",
79
- "urijs": "^1.18.10",
80
- "uuid": "^3.0.1"
81
- },
82
- "jest": {
83
- "automock": true,
84
- "verbose": true,
85
- "testMatch": [
86
- "**/*.test.js"
87
- ],
88
- "testURL": "http://localhost/",
89
- "collectCoverage": true,
90
- "collectCoverageFrom": [
91
- "webpack/**/*.js",
92
- "!webpack/index.js",
93
- "!webpack/test_setup.js",
94
- "!webpack/**/bundle*",
95
- "!webpack/stories/**",
96
- "!webpack/**/*stories.js"
97
- ],
98
- "coverageReporters": [
99
- "lcov"
100
- ],
101
- "unmockedModulePathPatterns": [
102
- "webpack/",
103
- "react",
104
- "node_modules/"
105
- ],
106
- "moduleNameMapper": {
107
- "^.+\\.(png|gif|css|scss)$": "identity-obj-proxy"
108
- },
109
- "globals": {
110
- "__testing__": true
111
- },
112
- "transform": {
113
- "^.+\\.js$": "babel-jest"
114
- },
115
- "moduleDirectories": [
116
- "node_modules",
117
- "webpack"
118
- ],
119
- "setupFiles": [
120
- "raf/polyfill",
121
- "jest-prop-type-error",
122
- "./webpack/test_setup.js"
123
- ]
42
+ "jed": "^1.1.1",
43
+ "react-intl": "^2.8.0"
124
44
  }
125
45
  }
@@ -14,17 +14,12 @@ class AccountsControllerTest < ActionController::TestCase
14
14
  upload_label = ForemanInventoryUpload::Async::UploadReportJob.output_label(test_org.id)
15
15
  upload_output = ForemanInventoryUpload::Async::ProgressOutput.register(upload_label)
16
16
  upload_output.status = 'upload_status_test'
17
- FactoryBot.create(:setting, :name => 'allow_auto_inventory_upload', :value => true)
18
- assert_equal true, Setting[:allow_auto_inventory_upload]
19
17
 
20
18
  get :index, session: set_session_user
21
19
 
22
20
  assert_response :success
23
- actual = JSON.parse(response.body)
24
- actual_account_statuses = actual['accounts'][test_org.id.to_s]
25
- assert_equal 'generate_status_test', actual_account_statuses['generate_report_status']
26
- assert_equal 'upload_status_test', actual_account_statuses['upload_report_status']
27
-
28
- assert_equal true, actual['autoUploadEnabled']
21
+ actual = JSON.parse(response.body)['accounts'][test_org.id.to_s]
22
+ assert_equal 'generate_status_test', actual['generate_report_status']
23
+ assert_equal 'upload_status_test', actual['upload_report_status']
29
24
  end
30
25
  end
@@ -18,17 +18,4 @@ class UploadsControllerTest < ActionController::TestCase
18
18
  actual = JSON.parse(response.body)
19
19
  assert_equal 'test output', actual['output']
20
20
  end
21
-
22
- test 'should update allow_auto_inventory_upload setting' do
23
- FactoryBot.create(:setting, :name => 'allow_auto_inventory_upload', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => false)
24
-
25
- assert_equal false, Setting[:allow_auto_inventory_upload]
26
-
27
- post :auto_upload, params: { value: true }, session: set_session_user
28
-
29
- assert_response :success
30
- actual = JSON.parse(response.body)
31
- assert_equal true, actual['autoUploadEnabled']
32
- assert_equal true, Setting[:allow_auto_inventory_upload]
33
- end
34
21
  end
@@ -17,8 +17,6 @@ class ReportGeneratorTest < ActiveSupport::TestCase
17
17
  )
18
18
 
19
19
  @host.subscription_facet.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
20
-
21
- ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
22
20
  end
23
21
 
24
22
  def interesting_facts
@@ -32,11 +30,9 @@ class ReportGeneratorTest < ActiveSupport::TestCase
32
30
  'dmi::bios::vendor',
33
31
  'dmi::bios::version',
34
32
  'dmi::bios::relase_date',
33
+ 'distribution::name',
35
34
  'uname::release',
36
35
  'lscpu::flags',
37
- 'distribution::name',
38
- 'distribution::version',
39
- 'distribution::id',
40
36
  ]
41
37
  end
42
38
 
@@ -60,7 +56,6 @@ class ReportGeneratorTest < ActiveSupport::TestCase
60
56
  assert_equal @host.name, actual_host['display_name']
61
57
  assert_equal @host.fqdn, actual_host['fqdn']
62
58
  assert_equal '1234', actual_host['account']
63
- assert_equal 1, generator.hosts_count
64
59
  end
65
60
 
66
61
  test 'generates a report with satellite facts' do
@@ -83,7 +78,7 @@ class ReportGeneratorTest < ActiveSupport::TestCase
83
78
 
84
79
  org_id_tag = actual['hosts'].first['tags'].find { |tag| tag['namespace'] == 'satellite' && tag['key'] == 'organization_id'}
85
80
  assert_not_nil org_id_tag
86
- assert_equal @host.organization_id.to_s, org_id_tag['value']
81
+ assert_equal @host.organization_id, org_id_tag['value']
87
82
 
88
83
  version = satellite_facts['satellite_version']
89
84
  if defined?(ForemanThemeSatellite)
@@ -163,7 +158,6 @@ class ReportGeneratorTest < ActiveSupport::TestCase
163
158
  assert_equal @host.name, actual_host['display_name']
164
159
  assert_equal @host.fqdn, actual_host['fqdn']
165
160
  assert_equal '1234', actual_host['account']
166
- assert_equal 1, generator.hosts_count
167
161
  end
168
162
 
169
163
  test 'shows system_memory_bytes in bytes' do
@@ -180,41 +174,4 @@ class ReportGeneratorTest < ActiveSupport::TestCase
180
174
  assert_not_nil(actual_profile = actual_host['system_profile'])
181
175
  assert_equal 1024, actual_profile['system_memory_bytes']
182
176
  end
183
-
184
- test 'reports an account for hosts with multiple pools' do
185
- first_pool = @host.subscription_facet.pools.first
186
- second_pool = FactoryBot.create(:katello_pool, account_number: nil, cp_id: 2)
187
- @host.subscription_facet.pools = []
188
- @host.subscription_facet.save!
189
- @host.subscription_facet.pools << first_pool
190
- @host.subscription_facet.pools << second_pool
191
-
192
- batch = Host.where(id: @host.id).in_batches.first
193
- generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
194
-
195
- json_str = generator.render
196
- actual = JSON.parse(json_str.join("\n"))
197
-
198
- assert_equal 'slice_123', actual['report_slice_id']
199
- assert_not_nil(actual_host = actual['hosts'].first)
200
- assert_not_nil(actual_host['account'])
201
- assert_not_empty(actual_host['account'])
202
- end
203
-
204
- test 'Generates os_release with version and id' do
205
- FactoryBot.create(:fact_value, fact_name: fact_names['distribution::name'], value: 'Red Hat Test Linux', host: @host)
206
- FactoryBot.create(:fact_value, fact_name: fact_names['distribution::version'], value: '7.1', host: @host)
207
- FactoryBot.create(:fact_value, fact_name: fact_names['distribution::id'], value: 'TestId', host: @host)
208
-
209
- batch = Host.where(id: @host.id).in_batches.first
210
- generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
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_profile = actual_host['system_profile'])
218
- assert_equal 'Red Hat Test Linux 7.1 (TestId)', actual_profile['os_release']
219
- end
220
177
  end