foreman_rh_cloud 15.0.0 → 15.0.2

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/advisor_engine/advisor_engine_controller.rb +1 -73
  3. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +29 -14
  4. data/app/controllers/insights_cloud/ui_requests_controller.rb +19 -2
  5. data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +93 -79
  6. data/config/package-lock.json.plugin +7160 -21310
  7. data/config/routes.rb +0 -4
  8. data/lib/foreman_inventory_upload/async/generate_host_report.rb +6 -1
  9. data/lib/foreman_inventory_upload/async/host_inventory_report_job.rb +10 -0
  10. data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +1 -0
  11. data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +16 -2
  12. data/lib/foreman_inventory_upload/generators/archived_report.rb +4 -4
  13. data/lib/foreman_inventory_upload/generators/slice.rb +55 -12
  14. data/lib/foreman_inventory_upload.rb +69 -0
  15. data/lib/foreman_rh_cloud/plugin.rb +24 -11
  16. data/lib/foreman_rh_cloud/version.rb +1 -1
  17. data/package.json +6 -13
  18. data/test/controllers/insights_cloud/api/advisor_engine_controller_test.rb +4 -15
  19. data/test/controllers/insights_cloud/ui_requests_controller_test.rb +217 -5
  20. data/test/jobs/generate_host_report_test.rb +1 -1
  21. data/test/jobs/host_inventory_report_job_test.rb +72 -0
  22. data/test/jobs/queue_for_upload_job_test.rb +4 -1
  23. data/test/jobs/upload_report_direct_job_test.rb +28 -7
  24. data/test/unit/archived_report_generator_test.rb +21 -0
  25. data/test/unit/foreman_inventory_upload_host_report_path_test.rb +111 -0
  26. data/test/unit/rh_cloud_permissions_test.rb +0 -2
  27. data/test/unit/services/foreman_rh_cloud/insights_api_forwarder_test.rb +189 -356
  28. data/test/unit/slice_generator_test.rb +28 -0
  29. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +1 -0
  30. data/webpack/ForemanInventoryUpload/Components/TaskProgress/TaskProgress.js +8 -2
  31. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +3 -1
  32. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +23 -0
  33. data/webpack/HostsIndexExtensions/VulnerabilityAnalysisActions.js +1 -1
  34. data/webpack/test_setup.js +18 -0
  35. metadata +3 -6
  36. data/app/controllers/foreman_inventory_upload/api/tasks_controller.rb +0 -110
  37. data/app/services/foreman_rh_cloud/hits_uploader.rb +0 -50
  38. data/lib/tasks/hybrid_cloud.rake +0 -132
  39. data/test/unit/services/foreman_rh_cloud/hits_uploader_test.rb +0 -131
data/config/routes.rb CHANGED
@@ -82,14 +82,10 @@ Rails.application.routes.draw do
82
82
  namespace 'rh_cloud' do
83
83
  post 'announce_to_sources', to: 'inventory#announce_to_sources'
84
84
  post 'cloud_request', to: 'cloud_request#update'
85
- # Inventory upload task endpoints
86
- get 'inventory_upload/tasks/current', to: 'foreman_inventory_upload/api/tasks#current'
87
- get 'inventory_upload/tasks/history', to: 'foreman_inventory_upload/api/tasks#history'
88
85
  end
89
86
 
90
87
  namespace 'advisor_engine' do
91
88
  get 'host_details', to: 'advisor_engine#host_details'
92
- patch 'upload_hits', to: 'advisor_engine#upload_hits'
93
89
  end
94
90
  end
95
91
  end
@@ -13,7 +13,12 @@ module ForemanInventoryUpload
13
13
  def run
14
14
  archived_report_generator = ForemanInventoryUpload::Generators::ArchivedReport.new(input[:target])
15
15
  archived_report_generator.render(organization: input[:organization_id], filter: input[:filter])
16
- output[:result] = "Generated #{input[:target]} for organization id #{input[:organization_id]}"
16
+ ForemanInventoryUpload.log_inventory_report_saved(logger, input[:target])
17
+ output[:result] = "Generated report for organization id #{input[:organization_id]}"
18
+ end
19
+
20
+ def logger
21
+ Foreman::Logging.logger('background')
17
22
  end
18
23
  end
19
24
  end
@@ -70,6 +70,16 @@ module ForemanInventoryUpload
70
70
  end
71
71
  end
72
72
 
73
+ # Whether the UploadReportDirectJob scheduled by this report job completed an upload.
74
+ # all_planned_actions is limited to this job's actions (one upload at most).
75
+ def uploaded?
76
+ return false unless input[:upload]
77
+ return false unless phase == Dynflow::Action::Present
78
+
79
+ upload_action = all_planned_actions(ForemanInventoryUpload::Async::UploadReportDirectJob).first
80
+ ActiveModel::Type::Boolean.new.cast(upload_action&.output&.[](:uploaded))
81
+ end
82
+
73
83
  def rescue_strategy_for_self
74
84
  Dynflow::Action::Rescue::Fail
75
85
  end
@@ -13,6 +13,7 @@ module ForemanInventoryUpload
13
13
  enqueued_file_name = File.join(uploads_folder, report_file)
14
14
  FileUtils.mv(File.join(base_folder, report_file), enqueued_file_name)
15
15
  logger.debug("Done copying #{report_file} to #{enqueued_file_name}")
16
+ ForemanInventoryUpload.log_inventory_report_saved(logger, enqueued_file_name)
16
17
 
17
18
  output[:enqueued_file_name] = enqueued_file_name
18
19
  end
@@ -57,14 +57,18 @@ module ForemanInventoryUpload
57
57
  end
58
58
 
59
59
  def try_execute
60
+ output[:uploaded] = false
61
+
60
62
  if content_disconnected?
61
- logger.info("Upload canceled: connection to Insights is not enabled. Report location: #{filename}")
63
+ logger.info('Upload canceled: connection to Insights is not enabled.')
64
+ ForemanInventoryUpload.log_inventory_report_saved(logger, filename)
62
65
  done!
63
66
  return
64
67
  end
65
68
 
66
69
  unless organization.owner_details&.dig('upstreamConsumer', 'idCert')
67
70
  logger.info("Skipping organization '#{organization}', no candlepin certificate defined.")
71
+ ForemanInventoryUpload.log_inventory_report_saved(logger, filename)
68
72
  done!
69
73
  return
70
74
  end
@@ -77,6 +81,7 @@ module ForemanInventoryUpload
77
81
  end
78
82
 
79
83
  move_to_done_folder
84
+ output[:uploaded] = true
80
85
  done!
81
86
  end
82
87
 
@@ -115,7 +120,16 @@ module ForemanInventoryUpload
115
120
  logger.warn("Destination file #{done_file} already exists. Overwriting with new report.")
116
121
  end
117
122
  FileUtils.mv(filename, done_file, force: true)
118
- logger.debug("Moved #{filename} to #{done_file}")
123
+ ForemanInventoryUpload.log_inventory_report_saved(logger, done_file)
124
+ end
125
+
126
+ def rescue_external_task(error)
127
+ if poll_attempts[:failed] < poll_max_retries
128
+ super
129
+ else
130
+ ForemanInventoryUpload.log_inventory_report_saved(logger, filename)
131
+ raise error
132
+ end
119
133
  end
120
134
 
121
135
  def certificate
@@ -31,11 +31,11 @@ module ForemanInventoryUpload
31
31
  Open3.popen2e('tar', '-Jcvf', @target, '-C', tmpdir, '.') do |_in, out, wait_thr|
32
32
  @logger.info("tar: #{out.read}")
33
33
 
34
- if wait_thr.value.success?
35
- @logger.info 'Report archived successfully'
36
- else
37
- @logger.info "Tar command failed: #{$CHILD_STATUS}"
34
+ unless wait_thr.value.success?
35
+ raise "Tar command failed while archiving inventory report: #{wait_thr.value}"
38
36
  end
37
+
38
+ @logger.info 'Report archived'
39
39
  end
40
40
  end
41
41
  end
@@ -62,9 +62,42 @@ module ForemanInventoryUpload
62
62
  'infrastructure_type',
63
63
  ActiveModel::Type::Boolean.new.cast(fact_value(host, 'virt::is_guest')) ? 'virtual' : 'physical'
64
64
  )
65
- @stream.object_field('system_profile') do
66
- unless (installed_products = host.subscription_facet&.installed_products).empty?
67
- @stream.array_field('installed_products') do
65
+ virtual_host_uuid = host.subscription_facet&.hypervisor_host&.subscription_facet&.uuid
66
+ cpu_socket_val = fact_value(host, 'cpu::cpu_socket(s)')
67
+ hypervisor_type_val = host.subscription_facet.hypervisor? ? fact_value(host, 'hypervisor::type') : nil
68
+ hypervisor_version_val = host.subscription_facet.hypervisor? ? fact_value(host, 'hypervisor::version') : nil
69
+
70
+ # Use the same omission rules as simple_field to predict which string fields
71
+ # will be written after system_profile. For the UUID, use present? to match
72
+ # the blank? guard that controls whether the facts array is emitted.
73
+ fields_follow_system_profile = [will_emit_field?(cpu_socket_val),
74
+ will_emit_field?(hypervisor_type_val),
75
+ will_emit_field?(hypervisor_version_val),
76
+ virtual_host_uuid.present?].any?
77
+
78
+ installed_products = host.subscription_facet&.installed_products || []
79
+ cores_val = fact_value(host, 'cpu::core(s)_per_socket')
80
+ memory_val = fact_value(host, 'memory::memtotal')
81
+ cpu_val = fact_value(host, 'cpu::cpu(s)')
82
+
83
+ # Numeric facts use present? (not will_emit_field?) so that whitespace-only
84
+ # values are excluded rather than converted to 0 by to_i.
85
+ # Determine which system_profile field will be emitted last so :last can
86
+ # be passed to the correct call and no trailing comma is left inside the object.
87
+ # Fields are listed in emission order; the last present one wins. Adding a new
88
+ # system_profile field only requires inserting it in the right position here.
89
+ sp_fields_in_order = [
90
+ [:products, installed_products.presence],
91
+ [:cores, cores_val],
92
+ [:memory, memory_val],
93
+ [:cpus, cpu_val],
94
+ [:sockets, cpu_socket_val],
95
+ ]
96
+ last_sp_field = sp_fields_in_order.reverse.find { |_, v| v.present? }&.first
97
+
98
+ @stream.object_field('system_profile', !fields_follow_system_profile) do
99
+ unless installed_products.empty?
100
+ @stream.array_field('installed_products', last_sp_field == :products) do
68
101
  @stream.raw(installed_products.map do |product|
69
102
  {
70
103
  'name': product.name,
@@ -73,18 +106,22 @@ module ForemanInventoryUpload
73
106
  end.join(', '))
74
107
  end
75
108
  end
76
- @stream.simple_field('cores_per_socket', fact_value(host, 'cpu::core(s)_per_socket')) { |v| v.to_i } if fact_value(host, 'cpu::core(s)_per_socket').present?
77
- @stream.simple_field('system_memory_bytes', fact_value(host, 'memory::memtotal')) { |v| kilobytes_to_bytes(v.to_i) } if fact_value(host, 'memory::memtotal').present?
78
- @stream.simple_field('number_of_cpus', fact_value(host, 'cpu::cpu(s)')) { |v| v.to_i } if fact_value(host, 'cpu::cpu(s)').present?
79
- @stream.simple_field('number_of_sockets', fact_value(host, 'cpu::cpu_socket(s)'), :last) { |v| v.to_i } if fact_value(host, 'cpu::cpu_socket(s)').present?
109
+ @stream.simple_field('cores_per_socket', cores_val, last_sp_field == :cores) { |v| v.to_i } if cores_val.present?
110
+ @stream.simple_field('system_memory_bytes', memory_val, last_sp_field == :memory) { |v| kilobytes_to_bytes(v.to_i) } if memory_val.present?
111
+ @stream.simple_field('number_of_cpus', cpu_val, last_sp_field == :cpus) { |v| v.to_i } if cpu_val.present?
112
+ @stream.simple_field('number_of_sockets', cpu_socket_val, last_sp_field == :sockets) { |v| v.to_i } if cpu_socket_val.present?
80
113
  end
81
- virtual_host_uuid = host.subscription_facet&.hypervisor_host&.subscription_facet&.uuid
114
+
82
115
  if host.subscription_facet.hypervisor?
83
- @stream.simple_field('cpu_socket(s)', fact_value(host, 'cpu::cpu_socket(s)'))
84
- @stream.simple_field('hypervisor_type', fact_value(host, 'hypervisor::type'))
85
- @stream.simple_field('hypervisor_version', fact_value(host, 'hypervisor::version'), virtual_host_uuid.blank?)
116
+ type_emits = will_emit_field?(hypervisor_type_val)
117
+ version_emits = will_emit_field?(hypervisor_version_val)
118
+ @stream.simple_field('cpu_socket(s)', cpu_socket_val,
119
+ !type_emits && !version_emits && virtual_host_uuid.blank?)
120
+ @stream.simple_field('hypervisor_type', hypervisor_type_val,
121
+ !version_emits && virtual_host_uuid.blank?)
122
+ @stream.simple_field('hypervisor_version', hypervisor_version_val, virtual_host_uuid.blank?)
86
123
  else
87
- @stream.simple_field('cpu_socket(s)', fact_value(host, 'cpu::cpu_socket(s)'), virtual_host_uuid.blank?)
124
+ @stream.simple_field('cpu_socket(s)', cpu_socket_val, virtual_host_uuid.blank?)
88
125
  end
89
126
  # Guests need the hypervisor mapping in the satellite facts namespace for Subscription Watch, even in minimal mode
90
127
  return if virtual_host_uuid.blank?
@@ -99,6 +136,12 @@ module ForemanInventoryUpload
99
136
  end
100
137
  end
101
138
 
139
+ def will_emit_field?(value)
140
+ return false if value.nil? || value.try(:empty?)
141
+ return false if value.kind_of?(Array) && value.compact.empty?
142
+ true
143
+ end
144
+
102
145
  def report_host(host)
103
146
  host_ips_cache = host_ips(host)
104
147
  @stream.object do
@@ -80,6 +80,75 @@ module ForemanInventoryUpload
80
80
  folder
81
81
  end
82
82
 
83
+ # Podman volume that holds inventory reports in foremanctl deployments.
84
+ FOREMAN_DATA_RUN_VOLUME = 'foreman-data-run'.freeze
85
+
86
+ # Absolute path of a report file (container or local filesystem).
87
+ def self.absolute_report_path(path)
88
+ return path if path.blank?
89
+
90
+ File.realpath(path)
91
+ rescue Errno::ENOENT
92
+ File.expand_path(path.to_s)
93
+ end
94
+
95
+ # Container path of the foreman-data-run volume root (parent of base_folder).
96
+ def self.inventory_volume_root
97
+ container_base = begin
98
+ File.realpath(base_folder)
99
+ rescue Errno::ENOENT
100
+ File.expand_path(base_folder)
101
+ end
102
+ File.dirname(container_base)
103
+ end
104
+
105
+ # Path of the report relative to the foreman-data-run volume root
106
+ # (e.g. "red_hat_inventory/uploads/done/report_for_1.tar.xz").
107
+ # Returns nil when the report is outside the volume.
108
+ def self.inventory_volume_relative_path(path)
109
+ absolute = absolute_report_path(path)
110
+ return nil if absolute.blank?
111
+
112
+ volume_root = inventory_volume_root
113
+ return nil unless absolute == volume_root || absolute.start_with?("#{volume_root}/")
114
+
115
+ relative = absolute.delete_prefix(volume_root).delete_prefix('/')
116
+ relative.presence || '.'
117
+ end
118
+
119
+ # True when logs should use the local filesystem path (dev/test).
120
+ # Production/foremanctl logs the volume name + relative path instead,
121
+ # since mountinfo typically exposes the volume device rather than a host directory.
122
+ # foremanctl can later inject FOREMAN_DATA_RUN_MOUNTPOINT for a complete host path.
123
+ def self.filesystem_report_path_logging?
124
+ Rails.env.development? || Rails.env.test?
125
+ end
126
+
127
+ # Human-readable location for inventory report logs.
128
+ def self.inventory_report_location(path)
129
+ return path if path.blank?
130
+
131
+ absolute = absolute_report_path(path)
132
+ return absolute if filesystem_report_path_logging?
133
+
134
+ relative = inventory_volume_relative_path(path)
135
+ mountpoint = ENV['FOREMAN_DATA_RUN_MOUNTPOINT'].presence
136
+
137
+ if relative.nil?
138
+ "#{absolute} (outside podman volume '#{FOREMAN_DATA_RUN_VOLUME}')"
139
+ elsif mountpoint
140
+ File.join(mountpoint, relative)
141
+ else
142
+ "podman volume '#{FOREMAN_DATA_RUN_VOLUME}' at relative path '#{relative}' " \
143
+ "(on the host, run: sudo podman volume inspect --format '{{.Mountpoint}}' #{FOREMAN_DATA_RUN_VOLUME} " \
144
+ "and append that relative path)"
145
+ end
146
+ end
147
+
148
+ def self.log_inventory_report_saved(logger, path)
149
+ logger.info("Inventory report saved to #{inventory_report_location(path)}")
150
+ end
151
+
83
152
  def self.inventory_base_url
84
153
  "#{ForemanRhCloud.cert_base_url}/api/inventory/v1/hosts"
85
154
  end
@@ -6,7 +6,7 @@ module ForemanRhCloud
6
6
  return if Foreman::Plugin.find(:foreman_rh_cloud)
7
7
 
8
8
  Foreman::Plugin.register :foreman_rh_cloud do
9
- requires_foreman '>= 3.17'
9
+ requires_foreman '>= 5.1'
10
10
  register_gettext
11
11
 
12
12
  apipie_documented_controllers ["#{ForemanRhCloud::Engine.root}/app/controllers/api/v2/**/*.rb"]
@@ -26,6 +26,14 @@ module ForemanRhCloud
26
26
  end
27
27
  end
28
28
 
29
+ # These actions use client or Smart Proxy authentication rather than a
30
+ # permission that can be delegated to a non-admin user.
31
+ tests_to_skip "AccessPermissionsTest" => [
32
+ 'insights_cloud/api/machine_telemetries/forward_request should have a permission that grants access',
33
+ 'insights_cloud/api/machine_telemetries/branch_info should have a permission that grants access',
34
+ 'api/v2/advisor_engine/advisor_engine/host_details should have a permission that grants access',
35
+ ]
36
+
29
37
  # Add permissions
30
38
  security_block :foreman_rh_cloud do
31
39
  permission(
@@ -44,7 +52,6 @@ module ForemanRhCloud
44
52
  'foreman_inventory_upload/reports': [:last],
45
53
  'foreman_inventory_upload/uploads': [:auto_upload, :show_auto_upload, :download_file, :last],
46
54
  'foreman_inventory_upload/tasks': [:show],
47
- 'foreman_inventory_upload/api/tasks': [:current, :history],
48
55
  'foreman_inventory_upload/cloud_status': [:index],
49
56
  'foreman_inventory_upload/uploads_settings': [:index],
50
57
  'foreman_inventory_upload/missing_hosts': [:index],
@@ -57,7 +64,7 @@ module ForemanRhCloud
57
64
  '/foreman_rh_cloud/insights_cloud': [:index], # for bookmarks and later for showing the page
58
65
  'insights_cloud/hits': [:index, :show, :auto_complete_search, :resolutions],
59
66
  'insights_cloud/settings': [:index, :show],
60
- 'insights_cloud/ui_requests': [:forward_request, :translate_insights_host],
67
+ 'insights_cloud/ui_requests': [:translate_insights_host],
61
68
  'react': [:index],
62
69
  },
63
70
  :resource_type => ::InsightsHit.name
@@ -73,34 +80,34 @@ module ForemanRhCloud
73
80
  # Insights Compliance permissions
74
81
  permission(
75
82
  :view_compliance,
76
- {},
83
+ { 'insights_cloud/ui_requests': [:forward_request] },
77
84
  :resource_type => 'ForemanRhCloud'
78
85
  )
79
86
  permission(
80
87
  :edit_compliance,
81
- {},
88
+ { 'insights_cloud/ui_requests': [:forward_request] },
82
89
  :resource_type => 'ForemanRhCloud'
83
90
  )
84
91
  # Insights Vulnerability permissions
85
92
  permission(
86
93
  :view_vulnerability,
87
- {},
94
+ { 'insights_cloud/ui_requests': [:forward_request] },
88
95
  :resource_type => 'ForemanRhCloud'
89
96
  )
90
97
  permission(
91
98
  :edit_vulnerability,
92
- {},
99
+ { 'insights_cloud/ui_requests': [:forward_request] },
93
100
  :resource_type => 'ForemanRhCloud'
94
101
  )
95
102
  # Insights Advisor permissions
96
103
  permission(
97
104
  :view_advisor,
98
- {},
105
+ { 'insights_cloud/ui_requests': [:forward_request] },
99
106
  :resource_type => 'ForemanRhCloud'
100
107
  )
101
108
  permission(
102
109
  :edit_advisor,
103
- {},
110
+ { 'insights_cloud/ui_requests': [:forward_request] },
104
111
  :resource_type => 'ForemanRhCloud'
105
112
  )
106
113
  end
@@ -137,14 +144,20 @@ module ForemanRhCloud
137
144
  url_hash: { controller: :react, action: :index },
138
145
  parent: :insights_menu,
139
146
  if: -> { !ForemanRhCloud.with_iop_smart_proxy? }
140
- menu :top_menu, :insights_hits, caption: N_('Recommendations'), url: '/foreman_rh_cloud/insights_cloud', url_hash: { controller: :react, action: :index }, parent: :insights_menu
147
+ menu :top_menu,
148
+ :insights_hits,
149
+ caption: N_('Recommendations'),
150
+ url: '/foreman_rh_cloud/insights_cloud',
151
+ url_hash: { controller: :react, action: :index },
152
+ parent: :insights_menu,
153
+ if: -> { ForemanRhCloud.with_iop_smart_proxy? ? (User.current&.can?(:view_advisor) && User.current&.can?(:view_insights_hits)) : User.current&.can?(:view_insights_hits) }
141
154
  menu :top_menu,
142
155
  :insights_vulnerability,
143
156
  caption: N_('Vulnerability'),
144
157
  url: '/foreman_rh_cloud/insights_vulnerability',
145
158
  url_hash: { controller: :react, action: :index },
146
159
  parent: :insights_menu,
147
- if: -> { ForemanRhCloud.with_iop_smart_proxy? }
160
+ if: -> { ForemanRhCloud.with_iop_smart_proxy? && User.current&.can?(:view_vulnerability) }
148
161
  menu :top_menu,
149
162
  :insights_compliance_reports,
150
163
  caption: N_('Compliance Reports'),
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '15.0.0'.freeze
2
+ VERSION = '15.0.2'.freeze
3
3
  end
data/package.json CHANGED
@@ -1,15 +1,10 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "15.0.0",
3
+ "version": "15.0.2",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "lint": "tfm-lint --plugin -d /webpack",
8
- "lint:spelling": "eslint ./webpack",
9
- "test": "tfm-test --plugin",
10
- "test:watch": "tfm-test --plugin --watchAll",
11
- "test:current": "tfm-test --plugin --watch",
12
- "publish-coverage": "tfm-publish-coverage"
7
+ "lint:spelling": "eslint -c eslint.spelling.config.js ./webpack"
13
8
  },
14
9
  "repository": {
15
10
  "type": "git",
@@ -18,20 +13,18 @@
18
13
  "bugs": {
19
14
  "url": "http://projects.theforeman.org/projects/foreman_rh_cloud/issues"
20
15
  },
21
- "peerDependencies": {
22
- "@theforeman/vendor": ">= 15.0.1"
23
- },
24
16
  "dependencies": {
25
17
  "@scalprum/react-core": "^0.9.3",
26
18
  "@scalprum/core": "^0.8.1"
27
19
  },
28
20
  "devDependencies": {
29
21
  "@babel/core": "^7.7.0",
30
- "@theforeman/builder": ">= 15.0.1",
31
- "@theforeman/test": ">= 15.0.1",
32
- "@theforeman/eslint-plugin-foreman": ">= 15.0.1",
33
22
  "babel-eslint": "~10.0.0",
34
23
  "eslint": "~6.7.2",
24
+ "eslint-plugin-import": "~2.22.1",
25
+ "eslint-plugin-jsx-a11y": "~6.4.1",
26
+ "eslint-plugin-react": "~7.22.0",
27
+ "eslint-plugin-react-hooks": "~4.2.0",
35
28
  "eslint-plugin-spellcheck": "~0.0.17",
36
29
  "jed": "~1.1.1",
37
30
  "prettier": "~1.19.1",
@@ -59,21 +59,10 @@ module InsightsCloud
59
59
  assert_equal 'No hosts found for the given UUIDs', JSON.parse(response.body)['error']
60
60
  end
61
61
 
62
- test 'test upload hits with payload' do
63
- uuid = SecureRandom.uuid
64
- payload = { "data": "dummy data" }
65
- ForemanRhCloud::HitsUploader.any_instance.expects(:upload!).returns
66
- patch :upload_hits, params: { host_name: @host1.name, host_uuid: uuid, payload: payload }
67
- assert_response :ok
68
- assert_equal 'success', JSON.parse(response.body)['action_status']
69
- end
70
-
71
- test 'test upload hits with bad host' do
72
- uuid = SecureRandom.uuid
73
- payload = { "data": "dummy data" }
74
- patch :upload_hits, params: { host_name: "NO SUCH HOST", host_uuid: uuid, payload: payload }
75
- assert_response :not_found
76
- assert_equal 'No host found for the given host name', JSON.parse(response.body)['error']
62
+ test 'does not expose the legacy hits upload endpoint' do
63
+ assert_raises(ActionController::RoutingError) do
64
+ Rails.application.routes.recognize_path('/api/v2/advisor_engine/upload_hits', method: :patch)
65
+ end
77
66
  end
78
67
  end
79
68
  end