foreman_rh_cloud 13.2.12 → 14.0.1
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 +61 -61
- data/app/assets/javascripts/foreman_rh_cloud/locale/ja/foreman_rh_cloud.js +68 -68
- data/app/assets/javascripts/foreman_rh_cloud/locale/ka/foreman_rh_cloud.js +9 -9
- data/app/assets/javascripts/foreman_rh_cloud/locale/ko/foreman_rh_cloud.js +60 -60
- data/app/assets/javascripts/foreman_rh_cloud/locale/zh_CN/foreman_rh_cloud.js +60 -60
- data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +0 -9
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +10 -13
- data/app/controllers/insights_cloud/ui_requests_controller.rb +7 -3
- data/app/models/concerns/rh_cloud_host.rb +4 -71
- data/app/models/insights_client_report_status.rb +1 -9
- data/app/models/inventory_sync/inventory_status.rb +4 -16
- data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +5 -12
- data/app/services/foreman_rh_cloud/tags_auth.rb +13 -28
- data/app/services/foreman_rh_cloud/url_remediations_retriever.rb +5 -19
- data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +2 -8
- data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +0 -2
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +4 -34
- data/lib/foreman_inventory_upload/generators/queries.rb +1 -1
- data/lib/foreman_inventory_upload/generators/slice.rb +1 -1
- data/lib/foreman_inventory_upload.rb +1 -8
- data/lib/foreman_rh_cloud/engine.rb +0 -1
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +9 -36
- data/lib/insights_cloud/async/insights_generate_notifications.rb +1 -10
- data/lib/insights_cloud/async/vmaas_reposcan_sync.rb +8 -23
- data/lib/inventory_sync/async/inventory_full_sync.rb +3 -39
- data/lib/inventory_sync/async/inventory_self_host_sync.rb +2 -12
- data/locale/fr/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/fr/foreman_rh_cloud.edit.po +1032 -0
- data/locale/fr/foreman_rh_cloud.po +65 -66
- data/locale/fr/foreman_rh_cloud.po.time_stamp +0 -0
- data/locale/ja/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ja/foreman_rh_cloud.edit.po +1026 -0
- data/locale/ja/foreman_rh_cloud.po +70 -72
- data/locale/ja/foreman_rh_cloud.po.time_stamp +0 -0
- data/locale/ka/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ka/foreman_rh_cloud.edit.po +1025 -0
- data/locale/ka/foreman_rh_cloud.po +10 -11
- data/locale/ka/foreman_rh_cloud.po.time_stamp +0 -0
- data/locale/ko/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ko/foreman_rh_cloud.edit.po +1029 -0
- data/locale/ko/foreman_rh_cloud.po +63 -64
- data/locale/ko/foreman_rh_cloud.po.time_stamp +0 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/zh_CN/foreman_rh_cloud.edit.po +1031 -0
- data/locale/zh_CN/foreman_rh_cloud.po +64 -65
- data/locale/zh_CN/foreman_rh_cloud.po.time_stamp +0 -0
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +3 -57
- data/test/controllers/insights_cloud/ui_requests_controller_test.rb +2 -16
- data/test/jobs/insights_client_status_aging_test.rb +0 -40
- data/test/jobs/inventory_full_sync_test.rb +4 -219
- data/test/jobs/inventory_hosts_sync_test.rb +5 -7
- data/test/jobs/inventory_self_host_sync_test.rb +1 -10
- data/test/jobs/upload_report_direct_job_test.rb +0 -29
- data/test/models/insights_client_report_status_test.rb +0 -109
- data/test/unit/archived_report_generator_test.rb +1 -2
- data/test/unit/fact_helpers_test.rb +0 -16
- data/test/unit/foreman_rh_cloud_self_host_test.rb +2 -50
- data/test/unit/insights_facet_test.rb +0 -5
- data/test/unit/lib/insights_cloud/async/vmaas_reposcan_sync_test.rb +25 -80
- data/test/unit/metadata_generator_test.rb +1 -24
- data/test/unit/rh_cloud_host_test.rb +0 -282
- data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +1 -1
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +1 -1
- data/test/unit/services/foreman_rh_cloud/tags_auth_test.rb +0 -26
- data/test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb +5 -82
- data/test/unit/slice_generator_test.rb +2 -21
- data/webpack/CVEsHostDetailsTab/CVEsHostDetailsTab.js +3 -30
- data/webpack/CVEsHostDetailsTab/__tests__/CVEsHostDetailsTab.test.js +10 -112
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +9 -10
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +9 -13
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +9 -20
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/__snapshots__/ErrorState.test.js.snap +20 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +8 -31
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +47 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +10 -26
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +59 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +9 -33
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +34 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +35 -55
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +25 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +49 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +86 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +75 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +46 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +9 -13
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +26 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +15 -12
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +28 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +21 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +21 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +17 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +19 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +9 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +43 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +12 -32
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/AdvancedSettingActions.test.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/__snapshots__/AdvancedSettingActions.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettingsActions.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettingsActions.test.js.snap +26 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageTitle.test.js +7 -15
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +68 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorActions.test.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js +18 -47
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorActions.test.js.snap +11 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +59 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +1 -3
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.test.js +15 -58
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/__snapshots__/SettingsWarning.test.js.snap +32 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +2 -8
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +9 -23
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +17 -19
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +15 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +3 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +57 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js +36 -25
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +17 -43
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +8 -28
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +23 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +8 -25
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +74 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +9 -11
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/__snapshots__/TabContainer.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +9 -11
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/__snapshots__/TabFooter.test.js.snap +12 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +1 -8
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +12 -33
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +96 -0
- data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +8 -36
- data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryUpload.test.js +10 -0
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +5 -0
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +14 -0
- data/webpack/ForemanRhCloudHelpers.js +0 -22
- data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +15 -71
- metadata +57 -18
- data/app/controllers/concerns/insights_cloud/candlepin_proxies_extensions.rb +0 -23
- data/test/controllers/insights_cloud/candlepin_proxies_extensions_test.rb +0 -70
- data/test/jobs/insights_generate_notifications_test.rb +0 -26
- data/test/models/inventory_sync/inventory_status_test.rb +0 -85
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/__tests__/Toast.test.js +0 -82
- data/webpack/InsightsHostDetailsTab/__tests__/NewHostDetailsTab.test.js +0 -266
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module InsightsCloud
|
|
2
|
-
module CandlepinProxiesExtensions
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
|
|
5
|
-
included do
|
|
6
|
-
# Update insights client status when hosts check in via subscription-manager facts upload
|
|
7
|
-
# rubocop:disable Rails/LexicallyScopedActionFilter
|
|
8
|
-
after_action :update_insights_client_status, only: [:facts]
|
|
9
|
-
# rubocop:enable Rails/LexicallyScopedActionFilter
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def update_insights_client_status
|
|
13
|
-
# Update InsightsClientReportStatus whenever host checks in via subscription-manager
|
|
14
|
-
# This ensures USER_OMITTED status gets set even when insights-client isn't installed
|
|
15
|
-
# (parameter=false means insights-client won't be installed, so it won't hit MachineTelemetriesController)
|
|
16
|
-
hoststatus = @host.get_status(InsightsClientReportStatus)
|
|
17
|
-
Rails.logger.debug "Current status: #{hoststatus.to_label}"
|
|
18
|
-
@host.get_status(InsightsClientReportStatus).refresh!
|
|
19
|
-
@host.refresh_global_status!
|
|
20
|
-
Rails.logger.debug "New status: #{hoststatus.to_label}"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require 'test_plugin_helper'
|
|
2
|
-
|
|
3
|
-
module InsightsCloud
|
|
4
|
-
class CandlepinProxiesExtensionsTest < ActiveSupport::TestCase
|
|
5
|
-
setup do
|
|
6
|
-
@organization = FactoryBot.create(:organization)
|
|
7
|
-
@host = FactoryBot.create(:host, :with_subscription, :managed, organization: @organization)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
test 'updates InsightsClientReportStatus to USER_OMITTED when parameter is false' do
|
|
11
|
-
# Set parameter to false so status should be USER_OMITTED
|
|
12
|
-
FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: false)
|
|
13
|
-
|
|
14
|
-
# Simulate what the callback does
|
|
15
|
-
@host.get_status(InsightsClientReportStatus).refresh!
|
|
16
|
-
@host.refresh_global_status!
|
|
17
|
-
|
|
18
|
-
# Verify the status was updated
|
|
19
|
-
@host.reload
|
|
20
|
-
insights_status = @host.get_status(InsightsClientReportStatus)
|
|
21
|
-
assert insights_status.persisted?, 'InsightsClientReportStatus should be persisted'
|
|
22
|
-
assert_equal InsightsClientReportStatus::USER_OMITTED, insights_status.status,
|
|
23
|
-
'Status should be USER_OMITTED when host_registration_insights=false'
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
test 'sets USER_OMITTED status when parameter is inherited from hostgroup' do
|
|
27
|
-
# Create hostgroup with parameter
|
|
28
|
-
hostgroup = FactoryBot.create(:hostgroup)
|
|
29
|
-
hostgroup.group_parameters << GroupParameter.create(
|
|
30
|
-
name: 'host_registration_insights',
|
|
31
|
-
value: 'false',
|
|
32
|
-
key_type: 'boolean'
|
|
33
|
-
)
|
|
34
|
-
hostgroup.save!
|
|
35
|
-
|
|
36
|
-
@host.hostgroup = hostgroup
|
|
37
|
-
@host.save!
|
|
38
|
-
|
|
39
|
-
# Simulate what the callback does
|
|
40
|
-
@host.get_status(InsightsClientReportStatus).refresh!
|
|
41
|
-
@host.refresh_global_status!
|
|
42
|
-
|
|
43
|
-
# Verify status respects inherited parameter
|
|
44
|
-
@host.reload
|
|
45
|
-
insights_status = @host.get_status(InsightsClientReportStatus)
|
|
46
|
-
assert_equal InsightsClientReportStatus::USER_OMITTED, insights_status.status,
|
|
47
|
-
'Status should be USER_OMITTED when host_registration_insights=false is inherited from hostgroup'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
test 'refreshes global status' do
|
|
51
|
-
FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: true)
|
|
52
|
-
|
|
53
|
-
# Simulate what the callback does
|
|
54
|
-
@host.get_status(InsightsClientReportStatus).refresh!
|
|
55
|
-
@host.refresh_global_status!
|
|
56
|
-
|
|
57
|
-
# Verify global status was updated
|
|
58
|
-
@host.reload
|
|
59
|
-
assert_not_nil @host.global_status, 'Global status should be set'
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
test 'CandlepinProxiesController includes the update_insights_client_status method' do
|
|
63
|
-
# Verify the concern is included and method is available
|
|
64
|
-
controller = Katello::Api::Rhsm::CandlepinProxiesController.new
|
|
65
|
-
|
|
66
|
-
assert_respond_to controller, :update_insights_client_status,
|
|
67
|
-
'CandlepinProxiesController should have update_insights_client_status method from concern'
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require 'test_plugin_helper'
|
|
2
|
-
require 'foreman_tasks/test_helpers'
|
|
3
|
-
|
|
4
|
-
class InsightsGenerateNotificationsTest < ActiveSupport::TestCase
|
|
5
|
-
include Dynflow::Testing::Factories
|
|
6
|
-
|
|
7
|
-
setup do
|
|
8
|
-
User.current = User.find_by(login: 'secret_admin')
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
test 'skips notifications when foreman_host is nil' do
|
|
12
|
-
ForemanRhCloud.stubs(:foreman_host).returns(nil)
|
|
13
|
-
|
|
14
|
-
# Ensure blueprint exists or create it
|
|
15
|
-
NotificationBlueprint.find_or_create_by(name: 'insights_satellite_hits') do |bp|
|
|
16
|
-
bp.message = 'Test message'
|
|
17
|
-
bp.level = 'info'
|
|
18
|
-
bp.expires_in = 7.days
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
plan = ForemanTasks.sync_task(InsightsCloud::Async::InsightsGenerateNotifications)
|
|
22
|
-
|
|
23
|
-
# Should not raise an error, task completes successfully
|
|
24
|
-
assert_includes ['success', 'stopped'], plan.state, "Task should complete without error"
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
require 'test_plugin_helper'
|
|
2
|
-
|
|
3
|
-
module InventorySync
|
|
4
|
-
class InventoryStatusTest < ActiveSupport::TestCase
|
|
5
|
-
setup do
|
|
6
|
-
@host = FactoryBot.create(:host, :managed)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
test 'status constants are defined correctly' do
|
|
10
|
-
assert_equal 0, InventorySync::InventoryStatus::DISCONNECT
|
|
11
|
-
assert_equal 1, InventorySync::InventoryStatus::SYNC
|
|
12
|
-
assert_equal 2, InventorySync::InventoryStatus::USER_OMITTED
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
test 'to_global returns OK for USER_OMITTED status' do
|
|
16
|
-
status = @host.get_status(InventorySync::InventoryStatus)
|
|
17
|
-
status.status = InventorySync::InventoryStatus::USER_OMITTED
|
|
18
|
-
status.save!
|
|
19
|
-
|
|
20
|
-
assert_equal HostStatus::Global::OK, status.to_global
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
test 'to_global returns WARN for DISCONNECT status' do
|
|
24
|
-
status = @host.get_status(InventorySync::InventoryStatus)
|
|
25
|
-
status.status = InventorySync::InventoryStatus::DISCONNECT
|
|
26
|
-
status.save!
|
|
27
|
-
|
|
28
|
-
assert_equal HostStatus::Global::WARN, status.to_global
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
test 'to_global returns OK for SYNC status' do
|
|
32
|
-
status = @host.get_status(InventorySync::InventoryStatus)
|
|
33
|
-
status.status = InventorySync::InventoryStatus::SYNC
|
|
34
|
-
status.save!
|
|
35
|
-
|
|
36
|
-
assert_equal HostStatus::Global::OK, status.to_global
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
test 'to_label returns appropriate messages for each status' do
|
|
40
|
-
status = @host.get_status(InventorySync::InventoryStatus)
|
|
41
|
-
|
|
42
|
-
# Test DISCONNECT label
|
|
43
|
-
status.status = InventorySync::InventoryStatus::DISCONNECT
|
|
44
|
-
status.save!
|
|
45
|
-
label = status.to_label
|
|
46
|
-
assert_match(/not present/, label.downcase)
|
|
47
|
-
assert_match(/console\.redhat\.com/, label)
|
|
48
|
-
|
|
49
|
-
# Test SYNC label
|
|
50
|
-
status.status = InventorySync::InventoryStatus::SYNC
|
|
51
|
-
status.save!
|
|
52
|
-
label = status.to_label
|
|
53
|
-
assert_match(/uploaded.*present/, label.downcase)
|
|
54
|
-
assert_match(/console\.redhat\.com/, label)
|
|
55
|
-
|
|
56
|
-
# Test USER_OMITTED label
|
|
57
|
-
status.status = InventorySync::InventoryStatus::USER_OMITTED
|
|
58
|
-
status.save!
|
|
59
|
-
label = status.to_label
|
|
60
|
-
assert_match(/excluded/, label.downcase)
|
|
61
|
-
assert_match(/host parameter/, label.downcase)
|
|
62
|
-
assert_match(/console\.redhat\.com/, label)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
test 'relevant? returns true in regular (non-IoP) mode' do
|
|
66
|
-
ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(false)
|
|
67
|
-
|
|
68
|
-
status = @host.get_status(InventorySync::InventoryStatus)
|
|
69
|
-
status.status = InventorySync::InventoryStatus::SYNC
|
|
70
|
-
status.save!
|
|
71
|
-
|
|
72
|
-
assert status.relevant?, 'Inventory status should be relevant in regular mode'
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
test 'relevant? returns false in IoP mode' do
|
|
76
|
-
ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(true)
|
|
77
|
-
|
|
78
|
-
status = @host.get_status(InventorySync::InventoryStatus)
|
|
79
|
-
status.status = InventorySync::InventoryStatus::SYNC
|
|
80
|
-
status.save!
|
|
81
|
-
|
|
82
|
-
refute status.relevant?, 'Inventory status should NOT be relevant in IoP mode'
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from '@theforeman/test';
|
|
3
|
-
import Toast from '../Toast';
|
|
4
|
-
|
|
5
|
-
describe('Toast', () => {
|
|
6
|
-
it('renders with all three status counts including user_omitted', () => {
|
|
7
|
-
const wrapper = shallow(
|
|
8
|
-
<Toast syncHosts={5} disconnectHosts={3} userOmittedHosts={2} />
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
const links = wrapper.find('HostsWithStatusLink');
|
|
12
|
-
expect(links).toHaveLength(3);
|
|
13
|
-
|
|
14
|
-
// Check the children (numbers) of each link
|
|
15
|
-
expect(
|
|
16
|
-
links
|
|
17
|
-
.at(0)
|
|
18
|
-
.children()
|
|
19
|
-
.text()
|
|
20
|
-
).toBe('5');
|
|
21
|
-
expect(
|
|
22
|
-
links
|
|
23
|
-
.at(1)
|
|
24
|
-
.children()
|
|
25
|
-
.text()
|
|
26
|
-
).toBe('3');
|
|
27
|
-
expect(
|
|
28
|
-
links
|
|
29
|
-
.at(2)
|
|
30
|
-
.children()
|
|
31
|
-
.text()
|
|
32
|
-
).toBe('2');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('does not render user_omitted section when count is 0', () => {
|
|
36
|
-
const wrapper = shallow(
|
|
37
|
-
<Toast syncHosts={5} disconnectHosts={3} userOmittedHosts={0} />
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
// Should have only 2 HostsWithStatusLink components (sync and disconnect)
|
|
41
|
-
const links = wrapper.find('HostsWithStatusLink');
|
|
42
|
-
expect(links).toHaveLength(2);
|
|
43
|
-
|
|
44
|
-
// Should not contain the user_omitted explanation text
|
|
45
|
-
expect(wrapper.text()).not.toContain(
|
|
46
|
-
'host_registration_insights_inventory parameter value is false'
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('renders without crashing when userOmittedHosts is not provided (default)', () => {
|
|
51
|
-
const wrapper = shallow(<Toast syncHosts={5} disconnectHosts={3} />);
|
|
52
|
-
|
|
53
|
-
// Should use default value of 0, so only 2 links
|
|
54
|
-
const links = wrapper.find('HostsWithStatusLink');
|
|
55
|
-
expect(links).toHaveLength(2);
|
|
56
|
-
|
|
57
|
-
// Verify the count values
|
|
58
|
-
expect(
|
|
59
|
-
links
|
|
60
|
-
.at(0)
|
|
61
|
-
.children()
|
|
62
|
-
.text()
|
|
63
|
-
).toBe('5');
|
|
64
|
-
expect(
|
|
65
|
-
links
|
|
66
|
-
.at(1)
|
|
67
|
-
.children()
|
|
68
|
-
.text()
|
|
69
|
-
).toBe('3');
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('renders correct status links for each category', () => {
|
|
73
|
-
const wrapper = shallow(
|
|
74
|
-
<Toast syncHosts={5} disconnectHosts={3} userOmittedHosts={2} />
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const links = wrapper.find('HostsWithStatusLink');
|
|
78
|
-
expect(links.at(0).prop('statusName')).toBe('sync');
|
|
79
|
-
expect(links.at(1).prop('statusName')).toBe('disconnect');
|
|
80
|
-
expect(links.at(2).prop('statusName')).toBe('user_omitted');
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { Provider } from 'react-redux';
|
|
5
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
6
|
-
import configureMockStore from 'redux-mock-store';
|
|
7
|
-
import thunk from 'redux-thunk';
|
|
8
|
-
import NewHostDetailsTab from '../NewHostDetailsTab';
|
|
9
|
-
import { OVERVIEW_TAB_PATH } from '../../ForemanRhCloudHelpers';
|
|
10
|
-
|
|
11
|
-
const mockHistoryReplace = jest.fn();
|
|
12
|
-
|
|
13
|
-
jest.mock('react-router-dom', () => ({
|
|
14
|
-
...jest.requireActual('react-router-dom'),
|
|
15
|
-
useHistory: () => ({
|
|
16
|
-
replace: mockHistoryReplace,
|
|
17
|
-
}),
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
jest.mock('../../common/Hooks/ConfigHooks', () => ({
|
|
21
|
-
useIopConfig: jest.fn(() => false),
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
jest.mock('foremanReact/common/I18n', () => ({
|
|
25
|
-
translate: jest.fn(str => str),
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
jest.mock(
|
|
29
|
-
'foremanReact/components/SearchBar',
|
|
30
|
-
() => () => <div>SearchBar</div>,
|
|
31
|
-
{ virtual: true }
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
jest.mock('../../InsightsCloudSync/Components/InsightsTable', () => () => (
|
|
35
|
-
<div>InsightsTable</div>
|
|
36
|
-
));
|
|
37
|
-
|
|
38
|
-
jest.mock('../../InsightsCloudSync/Components/RemediationModal', () => () => (
|
|
39
|
-
<div>RemediationModal</div>
|
|
40
|
-
));
|
|
41
|
-
|
|
42
|
-
jest.mock(
|
|
43
|
-
'../../InsightsCloudSync/Components/InsightsTable/Pagination',
|
|
44
|
-
() => () => <div>Pagination</div>
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const mockStore = configureMockStore([thunk]);
|
|
48
|
-
|
|
49
|
-
const defaultResponse = {
|
|
50
|
-
id: 1,
|
|
51
|
-
operatingsystem_name: 'Red Hat Enterprise Linux 8',
|
|
52
|
-
insights_attributes: { uuid: 'test-uuid' },
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
describe('NewHostDetailsTab', () => {
|
|
56
|
-
let store;
|
|
57
|
-
let mockRouter;
|
|
58
|
-
|
|
59
|
-
beforeEach(() => {
|
|
60
|
-
mockRouter = {
|
|
61
|
-
push: jest.fn(),
|
|
62
|
-
replace: jest.fn(),
|
|
63
|
-
location: {
|
|
64
|
-
pathname: '/new/hosts/test-host.example.com',
|
|
65
|
-
search: '?page=1&per_page=20',
|
|
66
|
-
hash: '#/Insights',
|
|
67
|
-
query: { page: '1', per_page: '20' },
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
store = mockStore({
|
|
72
|
-
API: {},
|
|
73
|
-
ForemanRhCloud: {
|
|
74
|
-
InsightsCloudSync: {
|
|
75
|
-
table: {
|
|
76
|
-
selectedIds: {},
|
|
77
|
-
isAllSelected: false,
|
|
78
|
-
showSelectAllAlert: false,
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
insightsHostDetailsTab: {
|
|
83
|
-
query: '',
|
|
84
|
-
hits: [],
|
|
85
|
-
selectedIds: {},
|
|
86
|
-
error: null,
|
|
87
|
-
},
|
|
88
|
-
router: {
|
|
89
|
-
location: {
|
|
90
|
-
pathname: '/new/hosts/test-host.example.com',
|
|
91
|
-
search: '?page=1&per_page=20',
|
|
92
|
-
hash: '#/Insights',
|
|
93
|
-
query: { page: '1', per_page: '20' },
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
afterEach(() => {
|
|
100
|
-
jest.clearAllMocks();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
describe('cleanup effect', () => {
|
|
104
|
-
it('should preserve hash when clearing search params on unmount', () => {
|
|
105
|
-
const { unmount } = render(
|
|
106
|
-
<Provider store={store}>
|
|
107
|
-
<MemoryRouter>
|
|
108
|
-
<NewHostDetailsTab
|
|
109
|
-
hostName="test-host.example.com"
|
|
110
|
-
router={mockRouter}
|
|
111
|
-
response={defaultResponse}
|
|
112
|
-
/>
|
|
113
|
-
</MemoryRouter>
|
|
114
|
-
</Provider>
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
unmount();
|
|
118
|
-
|
|
119
|
-
expect(mockRouter.replace).toHaveBeenCalledWith({
|
|
120
|
-
search: null,
|
|
121
|
-
hash: '#/Insights',
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('should only clear search params when no hash exists', () => {
|
|
126
|
-
mockRouter.location.hash = '';
|
|
127
|
-
|
|
128
|
-
const { unmount } = render(
|
|
129
|
-
<Provider store={store}>
|
|
130
|
-
<MemoryRouter>
|
|
131
|
-
<NewHostDetailsTab
|
|
132
|
-
hostName="test-host.example.com"
|
|
133
|
-
router={mockRouter}
|
|
134
|
-
response={defaultResponse}
|
|
135
|
-
/>
|
|
136
|
-
</MemoryRouter>
|
|
137
|
-
</Provider>
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
unmount();
|
|
141
|
-
|
|
142
|
-
expect(mockRouter.replace).toHaveBeenCalledWith({
|
|
143
|
-
search: null,
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('should handle router.location being undefined gracefully', () => {
|
|
148
|
-
const routerWithoutLocation = {
|
|
149
|
-
push: jest.fn(),
|
|
150
|
-
replace: jest.fn(),
|
|
151
|
-
location: undefined,
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const { unmount } = render(
|
|
155
|
-
<Provider store={store}>
|
|
156
|
-
<MemoryRouter>
|
|
157
|
-
<NewHostDetailsTab
|
|
158
|
-
hostName="test-host.example.com"
|
|
159
|
-
router={routerWithoutLocation}
|
|
160
|
-
response={defaultResponse}
|
|
161
|
-
/>
|
|
162
|
-
</MemoryRouter>
|
|
163
|
-
</Provider>
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
unmount();
|
|
167
|
-
|
|
168
|
-
expect(routerWithoutLocation.replace).toHaveBeenCalledWith({
|
|
169
|
-
search: null,
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('should use the latest hash value at unmount time, not a stale captured value', () => {
|
|
174
|
-
const { unmount } = render(
|
|
175
|
-
<Provider store={store}>
|
|
176
|
-
<MemoryRouter>
|
|
177
|
-
<NewHostDetailsTab
|
|
178
|
-
hostName="test-host.example.com"
|
|
179
|
-
router={mockRouter}
|
|
180
|
-
response={defaultResponse}
|
|
181
|
-
/>
|
|
182
|
-
</MemoryRouter>
|
|
183
|
-
</Provider>
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
mockRouter.location.hash = '#/Overview';
|
|
187
|
-
|
|
188
|
-
unmount();
|
|
189
|
-
|
|
190
|
-
expect(mockRouter.replace).toHaveBeenCalledWith({
|
|
191
|
-
search: null,
|
|
192
|
-
hash: '#/Overview',
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
describe('tab visibility', () => {
|
|
198
|
-
it('should redirect to Overview when host is not RHEL', () => {
|
|
199
|
-
const nonRhelResponse = {
|
|
200
|
-
id: 2,
|
|
201
|
-
operatingsystem_name: 'Ubuntu 20.04',
|
|
202
|
-
insights_attributes: { uuid: 'test-uuid' },
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
render(
|
|
206
|
-
<Provider store={store}>
|
|
207
|
-
<MemoryRouter>
|
|
208
|
-
<NewHostDetailsTab
|
|
209
|
-
hostName="test-host.example.com"
|
|
210
|
-
response={nonRhelResponse}
|
|
211
|
-
/>
|
|
212
|
-
</MemoryRouter>
|
|
213
|
-
</Provider>
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
expect(mockHistoryReplace).toHaveBeenCalledWith(OVERVIEW_TAB_PATH);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('should redirect to Overview when insights facet is missing', () => {
|
|
220
|
-
const responseWithoutInsights = {
|
|
221
|
-
id: 3,
|
|
222
|
-
operatingsystem_name: 'Red Hat Enterprise Linux 8',
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
render(
|
|
226
|
-
<Provider store={store}>
|
|
227
|
-
<MemoryRouter>
|
|
228
|
-
<NewHostDetailsTab
|
|
229
|
-
hostName="test-host.example.com"
|
|
230
|
-
response={responseWithoutInsights}
|
|
231
|
-
/>
|
|
232
|
-
</MemoryRouter>
|
|
233
|
-
</Provider>
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
expect(mockHistoryReplace).toHaveBeenCalledWith(OVERVIEW_TAB_PATH);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it('should not redirect when host is valid RHEL with insights facet', () => {
|
|
240
|
-
render(
|
|
241
|
-
<Provider store={store}>
|
|
242
|
-
<MemoryRouter>
|
|
243
|
-
<NewHostDetailsTab
|
|
244
|
-
hostName="test-host.example.com"
|
|
245
|
-
response={defaultResponse}
|
|
246
|
-
/>
|
|
247
|
-
</MemoryRouter>
|
|
248
|
-
</Provider>
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
expect(mockHistoryReplace).not.toHaveBeenCalled();
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('should not redirect when host data is not yet loaded', () => {
|
|
255
|
-
render(
|
|
256
|
-
<Provider store={store}>
|
|
257
|
-
<MemoryRouter>
|
|
258
|
-
<NewHostDetailsTab hostName="test-host.example.com" response={{}} />
|
|
259
|
-
</MemoryRouter>
|
|
260
|
-
</Provider>
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
expect(mockHistoryReplace).not.toHaveBeenCalled();
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
});
|