foreman_rh_cloud 12.2.17 → 13.0.0
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/foreman_rh_cloud/locale/fr/foreman_rh_cloud.js +24 -78
- data/app/assets/javascripts/foreman_rh_cloud/locale/ja/foreman_rh_cloud.js +24 -78
- data/app/assets/javascripts/foreman_rh_cloud/locale/ka/foreman_rh_cloud.js +23 -77
- data/app/assets/javascripts/foreman_rh_cloud/locale/ko/foreman_rh_cloud.js +23 -77
- data/app/assets/javascripts/foreman_rh_cloud/locale/zh_CN/foreman_rh_cloud.js +23 -77
- data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +3 -5
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +1 -1
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +1 -1
- data/app/controllers/insights_cloud/ui_requests_controller.rb +3 -2
- data/app/models/concerns/rh_cloud_host.rb +1 -45
- data/app/models/foreman_rh_cloud/ping.rb +1 -2
- data/app/models/insights_hit.rb +1 -1
- data/app/services/foreman_rh_cloud/cert_auth.rb +3 -13
- data/app/services/foreman_rh_cloud/gateway_request.rb +26 -0
- data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +1 -3
- data/app/services/foreman_rh_cloud/tags_auth.rb +4 -15
- data/app/views/api/v2/advisor_engine/host_details.json.rabl +3 -1
- data/app/views/api/v2/hosts/insights/base.rabl +2 -3
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +8 -13
- data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +26 -4
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +96 -0
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +2 -2
- data/lib/foreman_inventory_upload/generators/slice.rb +3 -3
- data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +49 -0
- data/lib/foreman_inventory_upload.rb +6 -6
- data/lib/foreman_rh_cloud/engine.rb +15 -34
- data/lib/foreman_rh_cloud/plugin.rb +13 -20
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +3 -3
- data/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +3 -3
- data/lib/inventory_sync/async/inventory_hosts_sync.rb +2 -0
- data/lib/tasks/rh_cloud_inventory.rake +31 -14
- data/locale/foreman_rh_cloud.pot +157 -261
- data/locale/fr/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/fr/foreman_rh_cloud.po +26 -79
- data/locale/ja/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ja/foreman_rh_cloud.po +26 -79
- data/locale/ka/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ka/foreman_rh_cloud.po +24 -77
- data/locale/ko/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ko/foreman_rh_cloud.po +25 -78
- data/locale/zh_CN/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/zh_CN/foreman_rh_cloud.po +25 -78
- data/package.json +1 -1
- data/test/controllers/accounts_controller_test.rb +1 -1
- data/test/controllers/insights_cloud/api/advisor_engine_controller_test.rb +1 -28
- data/test/controllers/insights_cloud/ui_requests_controller_test.rb +0 -26
- data/test/controllers/uploads_controller_test.rb +1 -1
- data/test/factories/insights_factories.rb +0 -29
- data/test/jobs/cloud_connector_announce_task_test.rb +2 -3
- data/test/jobs/connector_playbook_execution_reporter_task_test.rb +20 -32
- data/test/jobs/exponential_backoff_test.rb +8 -9
- data/test/jobs/insights_client_status_aging_test.rb +2 -3
- data/test/jobs/insights_full_sync_test.rb +7 -13
- data/test/jobs/insights_resolutions_sync_test.rb +5 -9
- data/test/jobs/insights_rules_sync_test.rb +3 -5
- data/test/jobs/inventory_full_sync_test.rb +5 -9
- data/test/jobs/inventory_hosts_sync_test.rb +6 -11
- data/test/jobs/inventory_scheduled_sync_test.rb +6 -10
- data/test/jobs/inventory_self_host_sync_test.rb +1 -1
- data/test/jobs/remove_insights_hosts_job_test.rb +15 -14
- data/test/jobs/upload_report_job_test.rb +36 -0
- data/test/unit/fact_helpers_test.rb +0 -47
- data/test/unit/services/foreman_rh_cloud/tags_auth_test.rb +0 -14
- data/test/unit/slice_generator_test.rb +0 -57
- data/webpack/ForemanColumnExtensions/index.js +0 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +17 -24
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +8 -178
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +36 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +1 -3
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +51 -69
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +1 -1
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +1 -1
- data/webpack/ForemanRhCloudFills.js +2 -6
- data/webpack/ForemanRhCloudHelpers.js +0 -4
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +3 -3
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +9 -3
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +4 -24
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +112 -0
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js +2 -2
- data/webpack/InsightsCloudSync/Components/ToolbarDropdown.js +3 -3
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +3 -3
- data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +0 -10
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -1
- data/webpack/InsightsHostDetailsTab/InsightsTab.scss +0 -4
- data/webpack/InsightsHostDetailsTab/InsightsTotalRiskChart.js +23 -59
- data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +23 -25
- data/webpack/InsightsVulnerabilityHostIndexExtensions/CVECountCell.js +2 -8
- data/webpack/InsightsVulnerabilityHostIndexExtensions/__tests__/CVECountCell.test.js +4 -105
- data/webpack/__mocks__/foremanReact/common/hooks/API/APIHooks.js +3 -0
- data/webpack/__tests__/ForemanRhCloudHelpers.test.js +1 -16
- data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +0 -6
- data/webpack/common/Hooks/ConfigHooks.js +16 -3
- metadata +12 -32
- data/app/controllers/concerns/foreman_rh_cloud/registration_manager_extensions.rb +0 -39
- data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +0 -36
- data/lib/foreman_inventory_upload/async/generate_host_report.rb +0 -20
- data/lib/foreman_inventory_upload/async/host_inventory_report_job.rb +0 -39
- data/lib/foreman_inventory_upload/async/single_host_report_job.rb +0 -20
- data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +0 -200
- data/test/jobs/create_missing_insights_facets_test.rb +0 -151
- data/test/jobs/generate_host_report_test.rb +0 -100
- data/test/jobs/generate_report_job_test.rb +0 -146
- data/test/jobs/host_inventory_report_job_test.rb +0 -244
- data/test/jobs/queue_for_upload_job_test.rb +0 -54
- data/test/jobs/single_host_report_job_test.rb +0 -155
- data/test/jobs/upload_report_direct_job_test.rb +0 -399
- data/test/unit/foreman_rh_cloud_iop_metadata_test.rb +0 -200
- data/test/unit/lib/foreman_rh_cloud/registration_manager_extensions_test.rb +0 -154
- data/test/unit/rh_cloud_host_test.rb +0 -345
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTotalRiskChart.test.js +0 -194
- data/webpack/InsightsHostDetailsTab/__tests__/NewHostDetailsTab.test.js +0 -154
|
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
|
|
|
2
2
|
require 'foreman_tasks/test_helpers'
|
|
3
3
|
|
|
4
4
|
class InsightsResolutionsSyncTest < ActiveSupport::TestCase
|
|
5
|
-
include
|
|
5
|
+
include ForemanTasks::TestHelpers::WithInThreadExecutor
|
|
6
6
|
include MockCerts
|
|
7
7
|
|
|
8
8
|
setup do
|
|
@@ -76,8 +76,7 @@ class InsightsResolutionsSyncTest < ActiveSupport::TestCase
|
|
|
76
76
|
Katello::UpstreamConnectionChecker.any_instance.stubs(:can_connect?).returns(true)
|
|
77
77
|
InsightsCloud::Async::InsightsResolutionsSync.any_instance.stubs(:query_insights_resolutions).returns(@resolutions)
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
run_action(action)
|
|
79
|
+
ForemanTasks.sync_task(InsightsCloud::Async::InsightsResolutionsSync)
|
|
81
80
|
@rule.reload
|
|
82
81
|
|
|
83
82
|
assert_equal 5, InsightsResolution.all.count
|
|
@@ -89,8 +88,7 @@ class InsightsResolutionsSyncTest < ActiveSupport::TestCase
|
|
|
89
88
|
Katello::UpstreamConnectionChecker.any_instance.stubs(:can_connect?).returns(false)
|
|
90
89
|
InsightsCloud::Async::InsightsResolutionsSync.any_instance.expects(:query_insights_resolutions).never
|
|
91
90
|
|
|
92
|
-
|
|
93
|
-
run_action(action)
|
|
91
|
+
ForemanTasks.sync_task(InsightsCloud::Async::InsightsResolutionsSync)
|
|
94
92
|
|
|
95
93
|
assert_equal 0, InsightsResolution.all.count
|
|
96
94
|
end
|
|
@@ -100,8 +98,7 @@ class InsightsResolutionsSyncTest < ActiveSupport::TestCase
|
|
|
100
98
|
Katello::UpstreamConnectionChecker.any_instance.stubs(:can_connect?).returns(true)
|
|
101
99
|
InsightsCloud::Async::InsightsResolutionsSync.any_instance.expects(:query_insights_resolutions).never
|
|
102
100
|
|
|
103
|
-
|
|
104
|
-
run_action(action)
|
|
101
|
+
ForemanTasks.sync_task(InsightsCloud::Async::InsightsResolutionsSync)
|
|
105
102
|
|
|
106
103
|
assert_equal 0, InsightsResolution.all.count
|
|
107
104
|
end
|
|
@@ -111,8 +108,7 @@ class InsightsResolutionsSyncTest < ActiveSupport::TestCase
|
|
|
111
108
|
InsightsCloud::Async::InsightsResolutionsSync.any_instance.expects(:query_insights_resolutions).never
|
|
112
109
|
InsightsRule.all.delete_all
|
|
113
110
|
|
|
114
|
-
|
|
115
|
-
run_action(action)
|
|
111
|
+
ForemanTasks.sync_task(InsightsCloud::Async::InsightsResolutionsSync)
|
|
116
112
|
|
|
117
113
|
assert_equal 0, InsightsResolution.all.count
|
|
118
114
|
end
|
|
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
|
|
|
2
2
|
require 'foreman_tasks/test_helpers'
|
|
3
3
|
|
|
4
4
|
class InsightsRulesSyncTest < ActiveSupport::TestCase
|
|
5
|
-
include
|
|
5
|
+
include ForemanTasks::TestHelpers::WithInThreadExecutor
|
|
6
6
|
|
|
7
7
|
setup do
|
|
8
8
|
rules_json = <<-'RULES_JSON'
|
|
@@ -119,8 +119,7 @@ class InsightsRulesSyncTest < ActiveSupport::TestCase
|
|
|
119
119
|
# do not cleanup unused rules for tests
|
|
120
120
|
InsightsCloud::Async::InsightsRulesSync.any_instance.stubs(:cleanup_rules)
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
run_action(action)
|
|
122
|
+
ForemanTasks.sync_task(InsightsCloud::Async::InsightsRulesSync, Organization.all)
|
|
124
123
|
@hit.reload
|
|
125
124
|
|
|
126
125
|
assert_equal 2, InsightsRule.all.count
|
|
@@ -202,8 +201,7 @@ class InsightsRulesSyncTest < ActiveSupport::TestCase
|
|
|
202
201
|
# do not cleanup unused rules for tests
|
|
203
202
|
InsightsCloud::Async::InsightsRulesSync.any_instance.stubs(:cleanup_rules)
|
|
204
203
|
|
|
205
|
-
|
|
206
|
-
run_action(action)
|
|
204
|
+
ForemanTasks.sync_task(InsightsCloud::Async::InsightsRulesSync, Organization.all)
|
|
207
205
|
|
|
208
206
|
assert_equal 3, InsightsRule.all.count
|
|
209
207
|
end
|
|
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
|
|
|
2
2
|
require 'foreman_tasks/test_helpers'
|
|
3
3
|
|
|
4
4
|
class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
5
|
-
include
|
|
5
|
+
include ForemanTasks::TestHelpers::WithInThreadExecutor
|
|
6
6
|
include MockCerts
|
|
7
7
|
include KatelloCVEHelper
|
|
8
8
|
|
|
@@ -265,8 +265,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
|
265
265
|
|
|
266
266
|
InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
|
|
267
267
|
|
|
268
|
-
|
|
269
|
-
run_action(action)
|
|
268
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host2.organization)
|
|
270
269
|
|
|
271
270
|
@host2.reload
|
|
272
271
|
|
|
@@ -281,8 +280,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
|
281
280
|
InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
|
|
282
281
|
FactoryBot.create(:fact_value, fact_name: fact_names['virt::uuid'], value: '1234', host: @host2)
|
|
283
282
|
|
|
284
|
-
|
|
285
|
-
run_action(action)
|
|
283
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host1.organization)
|
|
286
284
|
@host2.reload
|
|
287
285
|
|
|
288
286
|
assert_equal InventorySync::InventoryStatus::DISCONNECT, InventorySync::InventoryStatus.where(host_id: @host1.id).first.status
|
|
@@ -293,8 +291,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
|
293
291
|
|
|
294
292
|
InventorySync::Async::InventoryFullSync.any_instance.expects(:plan_self).never
|
|
295
293
|
|
|
296
|
-
|
|
297
|
-
run_action(action)
|
|
294
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host1.organization)
|
|
298
295
|
end
|
|
299
296
|
|
|
300
297
|
test 'Should skip hosts that are not returned in query' do
|
|
@@ -307,8 +304,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
|
307
304
|
InventorySync::Async::InventoryFullSync.any_instance.expects(:affected_host_ids).returns([@host1.id, @host2.id])
|
|
308
305
|
FactoryBot.create(:fact_value, fact_name: fact_names['virt::uuid'], value: '1234', host: @host2)
|
|
309
306
|
|
|
310
|
-
|
|
311
|
-
run_action(action)
|
|
307
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host1.organization)
|
|
312
308
|
@host2.reload
|
|
313
309
|
|
|
314
310
|
assert_nil InventorySync::InventoryStatus.where(host_id: @host3.id).first
|
|
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
|
|
|
2
2
|
require 'foreman_tasks/test_helpers'
|
|
3
3
|
|
|
4
4
|
class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
5
|
-
include
|
|
5
|
+
include ForemanTasks::TestHelpers::WithInThreadExecutor
|
|
6
6
|
include MockCerts
|
|
7
7
|
include KatelloCVEHelper
|
|
8
8
|
|
|
@@ -302,8 +302,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
|
302
302
|
|
|
303
303
|
@host2.build_insights.save
|
|
304
304
|
|
|
305
|
-
|
|
306
|
-
run_action(action)
|
|
305
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
|
|
307
306
|
|
|
308
307
|
@host2.reload
|
|
309
308
|
|
|
@@ -318,8 +317,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
|
318
317
|
InventorySync::Async::InventoryHostsSync.any_instance.stubs(:candlepin_id_cert)
|
|
319
318
|
end
|
|
320
319
|
|
|
321
|
-
|
|
322
|
-
run_action(action)
|
|
320
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
|
|
323
321
|
|
|
324
322
|
@host2.reload
|
|
325
323
|
|
|
@@ -338,8 +336,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
|
338
336
|
|
|
339
337
|
assert_nil @host2.insights
|
|
340
338
|
|
|
341
|
-
|
|
342
|
-
run_action(action)
|
|
339
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
|
|
343
340
|
|
|
344
341
|
@host2.reload
|
|
345
342
|
|
|
@@ -356,8 +353,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
|
356
353
|
InventorySync::Async::InventoryHostsSync.any_instance.stubs(:candlepin_id_cert)
|
|
357
354
|
end
|
|
358
355
|
|
|
359
|
-
|
|
360
|
-
run_action(action)
|
|
356
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [org])
|
|
361
357
|
|
|
362
358
|
assert_equal 3, InsightsMissingHost.count
|
|
363
359
|
end
|
|
@@ -374,8 +370,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
|
374
370
|
InventorySync::Async::InventoryHostsSync.any_instance.stubs(:candlepin_id_cert)
|
|
375
371
|
end
|
|
376
372
|
|
|
377
|
-
|
|
378
|
-
run_action(action)
|
|
373
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [org])
|
|
379
374
|
|
|
380
375
|
assert_equal 3, InsightsMissingHost.count
|
|
381
376
|
end
|
|
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
|
|
|
2
2
|
require 'foreman_tasks/test_helpers'
|
|
3
3
|
|
|
4
4
|
class InventoryScheduledSyncTest < ActiveSupport::TestCase
|
|
5
|
-
include
|
|
5
|
+
include ForemanTasks::TestHelpers::WithInThreadExecutor
|
|
6
6
|
|
|
7
7
|
test 'Schedules an execution if auto upload is enabled' do
|
|
8
8
|
Setting[:allow_auto_inventory_upload] = true
|
|
@@ -11,8 +11,7 @@ class InventoryScheduledSyncTest < ActiveSupport::TestCase
|
|
|
11
11
|
InventorySync::Async::InventoryScheduledSync.any_instance.expects(:plan_org_sync).times(Organization.unscoped.count)
|
|
12
12
|
InventorySync::Async::InventoryScheduledSync.any_instance.expects(:plan_remove_insights_hosts).times(Organization.unscoped.count)
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
run_action(action)
|
|
14
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryScheduledSync)
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
test 'Skips execution if with_iop_smart_proxy? is true' do
|
|
@@ -20,9 +19,8 @@ class InventoryScheduledSyncTest < ActiveSupport::TestCase
|
|
|
20
19
|
|
|
21
20
|
InventorySync::Async::InventoryScheduledSync.any_instance.expects(:plan_org_sync).never
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
status = action.output[:status].to_s
|
|
22
|
+
task = ForemanTasks.sync_task(InventorySync::Async::InventoryScheduledSync)
|
|
23
|
+
status = task.output[:status].to_s
|
|
26
24
|
assert_match(/Foreman is configured with a local IoP Smart Proxy/, status)
|
|
27
25
|
end
|
|
28
26
|
|
|
@@ -31,8 +29,7 @@ class InventoryScheduledSyncTest < ActiveSupport::TestCase
|
|
|
31
29
|
|
|
32
30
|
InventorySync::Async::InventoryScheduledSync.any_instance.expects(:plan_org_sync).never
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
run_action(action)
|
|
32
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryScheduledSync)
|
|
36
33
|
end
|
|
37
34
|
|
|
38
35
|
test 'Skips mismatch deletion if the setting is disabled' do
|
|
@@ -42,7 +39,6 @@ class InventoryScheduledSyncTest < ActiveSupport::TestCase
|
|
|
42
39
|
InventorySync::Async::InventoryScheduledSync.any_instance.expects(:plan_org_sync).times(Organization.unscoped.count)
|
|
43
40
|
InventorySync::Async::InventoryScheduledSync.any_instance.expects(:plan_remove_insights_hosts).never
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
run_action(action)
|
|
42
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryScheduledSync)
|
|
47
43
|
end
|
|
48
44
|
end
|
|
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
|
|
|
2
2
|
require 'foreman_tasks/test_helpers'
|
|
3
3
|
|
|
4
4
|
class RemoveInsightsHostJobTest < ActiveSupport::TestCase
|
|
5
|
-
include
|
|
5
|
+
include ForemanTasks::TestHelpers::WithInThreadExecutor
|
|
6
6
|
|
|
7
7
|
setup do
|
|
8
8
|
User.current = User.find_by(login: 'secret_admin')
|
|
@@ -18,10 +18,10 @@ class RemoveInsightsHostJobTest < ActiveSupport::TestCase
|
|
|
18
18
|
|
|
19
19
|
FactoryBot.create(:insights_missing_host, organization: @org)
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
run_action(action)
|
|
21
|
+
task = ForemanTasks.sync_task(ForemanInventoryUpload::Async::RemoveInsightsHostsJob, '', @org.id)
|
|
23
22
|
|
|
24
23
|
assert_equal 0, InsightsMissingHost.count
|
|
24
|
+
assert_equal 'success', task.result
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
test 'Does not delete hosts on cloud failure' do
|
|
@@ -31,13 +31,14 @@ class RemoveInsightsHostJobTest < ActiveSupport::TestCase
|
|
|
31
31
|
|
|
32
32
|
FactoryBot.create(:insights_missing_host, organization: @org)
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
begin
|
|
35
|
+
ForemanTasks.sync_task(ForemanInventoryUpload::Async::RemoveInsightsHostsJob, '', @org.id)
|
|
36
|
+
rescue ForemanTasks::TaskError => ex
|
|
37
|
+
task = ex.task
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
assert_equal 1, InsightsMissingHost.count
|
|
41
|
+
assert_equal 'error', task.result
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
test 'Paginates the hosts list' do
|
|
@@ -53,12 +54,12 @@ class RemoveInsightsHostJobTest < ActiveSupport::TestCase
|
|
|
53
54
|
FactoryBot.create(:insights_missing_host, organization: @org)
|
|
54
55
|
FactoryBot.create(:insights_missing_host, organization: @org)
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
action = run_action(action)
|
|
57
|
+
task = ForemanTasks.sync_task(ForemanInventoryUpload::Async::RemoveInsightsHostsJob, '', @org.id)
|
|
58
58
|
|
|
59
59
|
assert_equal 0, InsightsMissingHost.count
|
|
60
|
-
assert_equal '
|
|
61
|
-
assert_equal '
|
|
60
|
+
assert_equal 'success', task.result
|
|
61
|
+
assert_equal 'response1', task.output[:response_page1]
|
|
62
|
+
assert_equal 'response2', task.output[:response_page2]
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
test 'Uses scoped_search to select hosts' do
|
|
@@ -72,12 +73,12 @@ class RemoveInsightsHostJobTest < ActiveSupport::TestCase
|
|
|
72
73
|
FactoryBot.create(:insights_missing_host, name: 'test a', organization: @org)
|
|
73
74
|
FactoryBot.create(:insights_missing_host, name: 'test b', organization: @org)
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
action = run_action(action)
|
|
76
|
+
task = ForemanTasks.sync_task(ForemanInventoryUpload::Async::RemoveInsightsHostsJob, 'name ~ b', @org.id)
|
|
77
77
|
|
|
78
78
|
assert_equal 1, InsightsMissingHost.count
|
|
79
79
|
assert_equal 'test a', InsightsMissingHost.first.name
|
|
80
|
-
assert_equal '
|
|
80
|
+
assert_equal 'success', task.result
|
|
81
|
+
assert_equal 'response1', task.output[:response_page1]
|
|
81
82
|
end
|
|
82
83
|
|
|
83
84
|
def mock_response(code: 200, body: '')
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'test_plugin_helper'
|
|
2
|
+
require 'foreman_tasks/test_helpers'
|
|
3
|
+
|
|
4
|
+
class UploadReportJobTest < ActiveSupport::TestCase
|
|
5
|
+
include ForemanTasks::TestHelpers::WithInThreadExecutor
|
|
6
|
+
include FolderIsolation
|
|
7
|
+
|
|
8
|
+
test 'returns aborted state when disconnected' do
|
|
9
|
+
organization = FactoryBot.create(:organization)
|
|
10
|
+
Organization.any_instance.stubs(:owner_details).returns(
|
|
11
|
+
'upstreamConsumer' => {
|
|
12
|
+
'idCert' => 'TEST_CERT',
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
ForemanInventoryUpload::Async::UploadReportJob.any_instance.expects(:content_disconnected?).returns(true)
|
|
16
|
+
|
|
17
|
+
ForemanTasks.sync_task(ForemanInventoryUpload::Async::UploadReportJob, '', organization.id)
|
|
18
|
+
|
|
19
|
+
label = ForemanInventoryUpload::Async::UploadReportJob.output_label(organization.id)
|
|
20
|
+
progress_output = ForemanInventoryUpload::Async::ProgressOutput.get(label)
|
|
21
|
+
assert_match(/Upload canceled/, progress_output.full_output)
|
|
22
|
+
assert_match(/exit 1/, progress_output.status)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test 'returns aborted state when no certificate defined on organization' do
|
|
26
|
+
organization = FactoryBot.create(:organization)
|
|
27
|
+
Organization.any_instance.expects(:owner_details).returns(nil)
|
|
28
|
+
|
|
29
|
+
ForemanTasks.sync_task(ForemanInventoryUpload::Async::UploadReportJob, '', organization.id)
|
|
30
|
+
|
|
31
|
+
label = ForemanInventoryUpload::Async::UploadReportJob.output_label(organization.id)
|
|
32
|
+
progress_output = ForemanInventoryUpload::Async::ProgressOutput.get(label)
|
|
33
|
+
assert_match(/Skipping organization/, progress_output.full_output)
|
|
34
|
+
assert_match(/exit 1/, progress_output.status)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -313,51 +313,4 @@ class FactHelpersTest < ActiveSupport::TestCase
|
|
|
313
313
|
assert_equal '10.230.230.3', ip3
|
|
314
314
|
end
|
|
315
315
|
end
|
|
316
|
-
|
|
317
|
-
describe 'IoP smart proxy checks' do
|
|
318
|
-
test 'obfuscate_hostname? returns false when global setting is enabled but IoP is present' do
|
|
319
|
-
Setting.expects(:[]).with(:obfuscate_inventory_hostnames).returns(true)
|
|
320
|
-
ForemanRhCloud.expects(:with_iop_smart_proxy?).returns(true)
|
|
321
|
-
host = mock('host')
|
|
322
|
-
# When IoP is present, it falls back to checking host-specific facts
|
|
323
|
-
@instance.expects(:fact_value).with(host, 'insights_client::obfuscate_hostname_enabled').returns(nil)
|
|
324
|
-
|
|
325
|
-
result = @instance.obfuscate_hostname?(host)
|
|
326
|
-
|
|
327
|
-
refute result
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
test 'obfuscate_hostname? returns true when global setting is enabled and IoP is not present' do
|
|
331
|
-
Setting.expects(:[]).with(:obfuscate_inventory_hostnames).returns(true)
|
|
332
|
-
ForemanRhCloud.expects(:with_iop_smart_proxy?).returns(false)
|
|
333
|
-
host = mock('host')
|
|
334
|
-
|
|
335
|
-
result = @instance.obfuscate_hostname?(host)
|
|
336
|
-
|
|
337
|
-
assert result
|
|
338
|
-
end
|
|
339
|
-
|
|
340
|
-
test 'obfuscate_ips? returns false when global setting is enabled but IoP is present' do
|
|
341
|
-
Setting.expects(:[]).with(:obfuscate_inventory_ips).returns(true)
|
|
342
|
-
ForemanRhCloud.expects(:with_iop_smart_proxy?).returns(true)
|
|
343
|
-
host = mock('host')
|
|
344
|
-
# When IoP is present, it falls back to checking host-specific facts
|
|
345
|
-
@instance.expects(:fact_value).with(host, 'insights_client::obfuscate_ipv4_enabled').returns(nil)
|
|
346
|
-
@instance.expects(:fact_value).with(host, 'insights_client::obfuscate_ipv6_enabled').returns(nil)
|
|
347
|
-
|
|
348
|
-
result = @instance.obfuscate_ips?(host)
|
|
349
|
-
|
|
350
|
-
refute result
|
|
351
|
-
end
|
|
352
|
-
|
|
353
|
-
test 'obfuscate_ips? returns true when global setting is enabled and IoP is not present' do
|
|
354
|
-
Setting.expects(:[]).with(:obfuscate_inventory_ips).returns(true)
|
|
355
|
-
ForemanRhCloud.expects(:with_iop_smart_proxy?).returns(false)
|
|
356
|
-
host = mock('host')
|
|
357
|
-
|
|
358
|
-
result = @instance.obfuscate_ips?(host)
|
|
359
|
-
|
|
360
|
-
assert result
|
|
361
|
-
end
|
|
362
|
-
end
|
|
363
316
|
end
|
|
@@ -40,18 +40,4 @@ class TagsAuthTest < ActiveSupport::TestCase
|
|
|
40
40
|
|
|
41
41
|
@auth.update_tag
|
|
42
42
|
end
|
|
43
|
-
|
|
44
|
-
test 'Generates tags with wildcard location when location is nil' do
|
|
45
|
-
auth_with_nil_loc = ::ForemanRhCloud::TagsAuth.new(@user, @org, nil, @logger)
|
|
46
|
-
uuid1 = 'test_uuid1'
|
|
47
|
-
|
|
48
|
-
auth_with_nil_loc.expects(:allowed_hosts).returns([uuid1])
|
|
49
|
-
auth_with_nil_loc.expects(:execute_cloud_request).with do |actual_params|
|
|
50
|
-
actual = JSON.parse(actual_params[:payload])
|
|
51
|
-
assert_includes actual['host_id_list'], uuid1
|
|
52
|
-
assert_equal "U:\"#{@user.login}\"O:\"#{@org.name}\"L:\"*\"", actual['tags'].first['value']
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
auth_with_nil_loc.update_tag
|
|
56
|
-
end
|
|
57
43
|
end
|
|
@@ -107,36 +107,6 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
107
107
|
assert_equal 'test_nic1', actual_nic['name']
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
test 'does not generate a report with minimal data collection when iop is present' do
|
|
111
|
-
Setting[:insights_minimal_data_collection] = true
|
|
112
|
-
ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(true)
|
|
113
|
-
|
|
114
|
-
batch = Host.where(id: @host.id).in_batches.first
|
|
115
|
-
generator = create_generator(batch)
|
|
116
|
-
|
|
117
|
-
json_str = generator.render
|
|
118
|
-
actual = JSON.parse(json_str.join("\n"))
|
|
119
|
-
|
|
120
|
-
assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
|
|
121
|
-
assert_not_nil(actual_host = actual['hosts'].first)
|
|
122
|
-
assert_nil actual_host['ip_addresses']
|
|
123
|
-
assert_nil actual_host['mac_addresses']
|
|
124
|
-
assert_equal @host.fqdn, actual_host['fqdn']
|
|
125
|
-
assert_equal '1234', actual_host['account']
|
|
126
|
-
assert_equal 1, generator.hosts_count
|
|
127
|
-
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
|
128
|
-
assert_nil actual_system_profile['number_of_cpus']
|
|
129
|
-
assert_nil actual_system_profile['number_of_sockets']
|
|
130
|
-
assert_nil actual_system_profile['cores_per_socket']
|
|
131
|
-
assert_nil actual_system_profile['system_memory_bytes']
|
|
132
|
-
assert_nil actual_system_profile['os_release']
|
|
133
|
-
assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
|
|
134
|
-
assert_not_nil(actual_nic = actual_network_interfaces.first)
|
|
135
|
-
refute actual_nic.key?('mtu')
|
|
136
|
-
refute actual_nic.key?('mac_address')
|
|
137
|
-
assert_equal 'test_nic1', actual_nic['name']
|
|
138
|
-
end
|
|
139
|
-
|
|
140
110
|
test 'generates a report with minimal data collection' do
|
|
141
111
|
Setting[:insights_minimal_data_collection] = true
|
|
142
112
|
create_fact_values(@host,
|
|
@@ -960,33 +930,6 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
960
930
|
assert_equal 'alibaba', actual_profile['cloud_provider']
|
|
961
931
|
end
|
|
962
932
|
|
|
963
|
-
test 'do not exclude packages when iop is present' do
|
|
964
|
-
Setting[:exclude_installed_packages] = true
|
|
965
|
-
ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(true)
|
|
966
|
-
installed_package = ::Katello::InstalledPackage.create(name: 'test-package', nvrea: 'test-package-1.0.x86_64', nvra: 'test-package-1.0.x86_64')
|
|
967
|
-
|
|
968
|
-
another_host = FactoryBot.create(
|
|
969
|
-
:host,
|
|
970
|
-
:with_subscription,
|
|
971
|
-
:with_content,
|
|
972
|
-
content_view: @host.content_views.first,
|
|
973
|
-
lifecycle_environment: @host.lifecycle_environments.first,
|
|
974
|
-
organization: @host.organization,
|
|
975
|
-
installed_packages: [installed_package]
|
|
976
|
-
)
|
|
977
|
-
|
|
978
|
-
batch = Host.where(id: another_host.id).in_batches.first
|
|
979
|
-
generator = create_generator(batch)
|
|
980
|
-
|
|
981
|
-
json_str = generator.render
|
|
982
|
-
actual = JSON.parse(json_str.join("\n"))
|
|
983
|
-
|
|
984
|
-
assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
|
|
985
|
-
assert_not_nil(actual_host = actual['hosts'].first)
|
|
986
|
-
assert_not_nil(actual_profile = actual_host['system_profile'])
|
|
987
|
-
assert_not_nil(actual_profile['installed_packages'])
|
|
988
|
-
end
|
|
989
|
-
|
|
990
933
|
test 'include packages installed in the report' do
|
|
991
934
|
Setting[:exclude_installed_packages] = false
|
|
992
935
|
installed_package = ::Katello::InstalledPackage.create(name: 'test-package', nvrea: 'test-package-1.0.x86_64', nvra: 'test-package-1.0.x86_64')
|
|
@@ -6,33 +6,26 @@ import InventoryFilter from '../InventoryFilter';
|
|
|
6
6
|
import ToolbarButtons from './components/ToolbarButtons';
|
|
7
7
|
import SettingsWarning from './components/SettingsWarning';
|
|
8
8
|
import PageTitle from './PageTitle';
|
|
9
|
-
import { useIopConfig } from '../../../common/Hooks/ConfigHooks';
|
|
10
9
|
import './PageHeader.scss';
|
|
11
10
|
|
|
12
|
-
const PageHeader = () =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<div className="inventory-upload-header">
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
{!isIop && (
|
|
20
|
-
<div className="inventory-upload-header-description">
|
|
21
|
-
<InventorySettings />
|
|
22
|
-
<PageDescription />
|
|
23
|
-
</div>
|
|
24
|
-
)}
|
|
25
|
-
<Grid.Row>
|
|
26
|
-
<Grid.Col xs={4}>
|
|
27
|
-
<InventoryFilter />
|
|
28
|
-
</Grid.Col>
|
|
29
|
-
<Grid.Col xs={7} xsOffset={1}>
|
|
30
|
-
<ToolbarButtons />
|
|
31
|
-
</Grid.Col>
|
|
32
|
-
</Grid.Row>
|
|
11
|
+
const PageHeader = () => (
|
|
12
|
+
<div className="inventory-upload-header">
|
|
13
|
+
<SettingsWarning />
|
|
14
|
+
<PageTitle />
|
|
15
|
+
<div className="inventory-upload-header-description">
|
|
16
|
+
<InventorySettings />
|
|
17
|
+
<PageDescription />
|
|
33
18
|
</div>
|
|
34
|
-
|
|
35
|
-
}
|
|
19
|
+
<Grid.Row>
|
|
20
|
+
<Grid.Col xs={4}>
|
|
21
|
+
<InventoryFilter />
|
|
22
|
+
</Grid.Col>
|
|
23
|
+
<Grid.Col xs={7} xsOffset={1}>
|
|
24
|
+
<ToolbarButtons />
|
|
25
|
+
</Grid.Col>
|
|
26
|
+
</Grid.Row>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
36
29
|
|
|
37
30
|
PageHeader.propTypes = {};
|
|
38
31
|
|