foreman_rh_cloud 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +1 -0
  3. data/app/controllers/foreman_inventory_upload/tasks_controller.rb +25 -0
  4. data/app/controllers/insights_cloud/settings_controller.rb +24 -0
  5. data/app/controllers/insights_cloud/tasks_controller.rb +1 -2
  6. data/app/helpers/foreman_inventory_upload_host_helper.rb +10 -1
  7. data/app/models/insights_facet.rb +5 -1
  8. data/app/models/inventory_sync/inventory_status.rb +30 -0
  9. data/app/models/setting/rh_cloud.rb +1 -0
  10. data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +1 -1
  11. data/config/routes.rb +3 -0
  12. data/db/migrate/20200727111529_add_uuid_column_to_insights_facets.foreman_rh_cloud.rb +5 -0
  13. data/lib/foreman_inventory_upload.rb +4 -0
  14. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +1 -1
  15. data/lib/foreman_inventory_upload/generators/slice.rb +25 -3
  16. data/lib/foreman_rh_cloud.rb +13 -0
  17. data/lib/foreman_rh_cloud/engine.rb +7 -1
  18. data/lib/foreman_rh_cloud/version.rb +1 -1
  19. data/lib/insights_cloud.rb +8 -8
  20. data/lib/insights_cloud/async/insights_full_sync.rb +17 -10
  21. data/lib/insights_cloud/async/insights_scheduled_sync.rb +23 -0
  22. data/lib/inventory_sync/async/host_result.rb +50 -0
  23. data/lib/inventory_sync/async/inventory_full_sync.rb +99 -0
  24. data/test/controllers/insights_sync/settings_controller_test.rb +30 -0
  25. data/test/factories/insights_factories.rb +31 -0
  26. data/test/jobs/insights_full_sync_test.rb +4 -2
  27. data/test/jobs/inventory_full_sync_test.rb +91 -0
  28. data/test/unit/insights_facet_test.rb +16 -0
  29. data/test/unit/slice_generator_test.rb +15 -7
  30. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +3 -1
  31. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +2 -1
  32. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +2 -0
  33. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +2 -0
  34. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +2 -0
  35. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +1 -0
  36. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +1 -0
  37. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +5 -1
  38. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +1 -0
  39. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +15 -13
  40. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +6 -0
  41. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +1 -1
  42. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +3 -3
  43. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/DocsButton.js +1 -0
  44. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/__snapshots__/DocsButton.test.js.snap +1 -0
  45. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/HistoryButton.js +1 -0
  46. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/__snapshots__/HistoryButton.test.js.snap +1 -0
  47. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +52 -0
  48. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +59 -0
  49. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +3 -0
  50. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +36 -0
  51. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonSelectors.js +13 -0
  52. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +13 -0
  53. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +13 -0
  54. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonFixtures.js +9 -0
  55. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +33 -0
  56. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +36 -0
  57. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +26 -0
  58. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +36 -0
  59. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +25 -0
  60. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +18 -0
  61. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +63 -0
  62. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +41 -0
  63. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +20 -0
  64. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +22 -0
  65. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +2 -0
  66. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +1 -0
  67. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +6 -1
  68. data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +3 -1
  69. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +2 -0
  70. data/webpack/ForemanRhCloudPages.js +7 -0
  71. data/webpack/ForemanRhCloudTestHelpers.js +12 -3
  72. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +33 -0
  73. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +60 -0
  74. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsConstants.js +10 -0
  75. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsReducer.js +28 -0
  76. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsSelectors.js +6 -0
  77. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +18 -0
  78. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +46 -0
  79. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +56 -0
  80. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsSelectors.test.js +21 -0
  81. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettings.test.js.snap +15 -0
  82. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +31 -0
  83. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +33 -0
  84. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsSelectors.test.js.snap +9 -0
  85. data/webpack/InsightsCloudSync/Components/InsightsSettings/index.js +21 -0
  86. data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +16 -0
  87. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.fixtures.js +1 -0
  88. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.js +45 -0
  89. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +17 -0
  90. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/__snapshots__/InsightsSyncSwitcher.test.js.snap +38 -0
  91. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/index.js +1 -0
  92. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/insightsSyncSwitcher.scss +3 -0
  93. data/webpack/InsightsCloudSync/InsightsCloudSync.js +32 -28
  94. data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +7 -2
  95. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +49 -44
  96. data/webpack/InsightsCloudSync/index.js +2 -1
  97. data/webpack/__mocks__/foremanReact/constants.js +5 -0
  98. data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +8 -0
  99. data/webpack/__tests__/ForemanRhCloudSelectors.test.js +4 -1
  100. data/webpack/__tests__/ForemanRhCloudTestHelpers.test.js +12 -2
  101. data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +9 -9
  102. data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +24 -2
  103. data/webpack/index.js +2 -12
  104. metadata +59 -2
@@ -0,0 +1,99 @@
1
+ require 'rest-client'
2
+
3
+ module InventorySync
4
+ module Async
5
+ class InventoryFullSync < ::ApplicationJob
6
+ def perform(organization)
7
+ @organization = organization
8
+ @subscribed_hosts_ids = Set.new(
9
+ ForemanInventoryUpload::Generators::Queries.for_slice(
10
+ Host.unscoped.where(organization: organization)
11
+ ).pluck(:id)
12
+ )
13
+ @host_statuses = {
14
+ sync: 0,
15
+ disconnect: 0,
16
+ }
17
+
18
+ InventorySync::InventoryStatus.transaction do
19
+ InventorySync::InventoryStatus.where(host_id: @subscribed_hosts_ids).delete_all
20
+ page = 1
21
+ loop do
22
+ api_response = query_inventory(page)
23
+ results = HostResult.new(api_response)
24
+ logger.debug("Downloading cloud inventory data: #{results.percentage}%")
25
+ update_hosts_status(results.status_hashes, results.touched)
26
+ @host_statuses[:sync] += results.touched.size
27
+ page += 1
28
+ break if results.last?
29
+ end
30
+ add_missing_hosts_statuses(@subscribed_hosts_ids)
31
+ @host_statuses[:disconnect] += @subscribed_hosts_ids.size
32
+ end
33
+
34
+ logger.debug("Synced hosts amount: #{@host_statuses[:sync]}")
35
+ logger.debug("Disconnected hosts amount: #{@host_statuses[:disconnect]}")
36
+
37
+ @host_statuses
38
+ end
39
+
40
+ def rh_credentials
41
+ @rh_credentials ||= query_refresh_token
42
+ end
43
+
44
+ private
45
+
46
+ def update_hosts_status(status_hashes, touched)
47
+ InventorySync::InventoryStatus.create(status_hashes)
48
+ @subscribed_hosts_ids.subtract(touched)
49
+ end
50
+
51
+ def add_missing_hosts_statuses(hosts_ids)
52
+ InventorySync::InventoryStatus.create(
53
+ hosts_ids.map do |host_id|
54
+ {
55
+ host_id: host_id,
56
+ status: InventorySync::InventoryStatus::DISCONNECT,
57
+ reported_at: Time.current,
58
+ }
59
+ end
60
+ )
61
+ end
62
+
63
+ def query_inventory(page = 1)
64
+ hosts_inventory_response = RestClient::Request.execute(
65
+ method: :get,
66
+ url: ForemanInventoryUpload.inventory_export_url,
67
+ verify_ssl: ForemanRhCloud.verify_ssl_method,
68
+ headers: {
69
+ Authorization: "Bearer #{rh_credentials}",
70
+ params: {
71
+ per_page: 100,
72
+ page: page,
73
+ },
74
+ }
75
+ )
76
+
77
+ JSON.parse(hosts_inventory_response)
78
+ end
79
+
80
+ def query_refresh_token
81
+ token_response = RestClient::Request.execute(
82
+ method: :post,
83
+ url: ForemanRhCloud.authentication_url,
84
+ verify_ssl: ForemanRhCloud.verify_ssl_method,
85
+ payload: {
86
+ grant_type: 'refresh_token',
87
+ client_id: 'rhsm-api',
88
+ refresh_token: Setting[:rh_cloud_token],
89
+ }
90
+ )
91
+
92
+ JSON.parse(token_response)['access_token']
93
+ rescue RestClient::ExceptionWithResponse => e
94
+ Foreman::Logging.exception('Unable to authenticate using rh_cloud_token setting', e)
95
+ raise ::Foreman::WrappedException.new(e, N_('Unable to authenticate using rh_cloud_token setting'))
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,30 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class SettingsControllerTest < ActionController::TestCase
4
+ tests InsightsCloud::SettingsController
5
+
6
+ test 'should return allow_auto_insights_sync setting' do
7
+ FactoryBot.create(:setting, :name => 'allow_auto_insights_sync', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => false)
8
+
9
+ assert_equal false, Setting[:allow_auto_insights_sync]
10
+
11
+ get :show, session: set_session_user
12
+
13
+ assert_response :success
14
+ actual = JSON.parse(response.body)
15
+ assert_equal false, actual['insightsSyncEnabled']
16
+ end
17
+
18
+ test 'should update allow_auto_insights_sync setting' do
19
+ FactoryBot.create(:setting, :name => 'allow_auto_insights_sync', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => false)
20
+
21
+ assert_equal false, Setting[:allow_auto_insights_sync]
22
+
23
+ patch :update, params: { insightsSyncEnabled: true }, session: set_session_user
24
+
25
+ assert_response :success
26
+ actual = JSON.parse(response.body)
27
+ assert_equal true, actual['insightsSyncEnabled']
28
+ assert_equal true, Setting[:allow_auto_insights_sync]
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ FactoryBot.define do
2
+ factory :insights_facet do
3
+ # sequence(:uuid) { |n| "uuid-#{n}" }
4
+
5
+ trait :with_hits do
6
+ hits do
7
+ Array.new(1) { association(:insights_hit, host_id: host_id) }
8
+ end
9
+ end
10
+ end
11
+
12
+ factory :insights_hit do
13
+ last_seen { Date.yesterday }
14
+ sequence(:title) { |n| "hit title #{n}" }
15
+ sequence(:solution_url) { |n| "http://example.com/solutions/#{n}" }
16
+ total_risk { 1 }
17
+ likelihood { 2 }
18
+ publish_date { Time.now }
19
+ sequence(:results_url) { |n| "http://example.com/results/#{n}" }
20
+ end
21
+ end
22
+
23
+ FactoryBot.modify do
24
+ factory :host do
25
+ trait :with_insights_hits do
26
+ after(:create) do |host, _evaluator|
27
+ host.insights = FactoryBot.create(:insights_facet, :with_hits, host_id: host.id)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -51,13 +51,15 @@ class InsightsFullSyncTest < ActiveJob::TestCase
51
51
  test 'Hits data is replaced with data from cloud' do
52
52
  InsightsCloud::Async::InsightsFullSync.any_instance.expects(:query_insights_hits).returns(@hits)
53
53
 
54
- InsightsCloud::Async::InsightsFullSync.perform_now(@host1.organization)
54
+ InsightsCloud::Async::InsightsFullSync.perform_now()
55
55
 
56
56
  @host1.reload
57
57
  @host2.reload
58
58
 
59
59
  assert_equal 2, @host1.insights.hits.count
60
60
  assert_equal 1, @host2.insights.hits.count
61
+ assert_equal 'accdf444-5628-451d-bf3e-cf909ad72756', @host1.insights.uuid
62
+ assert_equal 'accdf444-5628-451d-bf3e-cf909ad72757', @host2.insights.uuid
61
63
  end
62
64
 
63
65
  test 'Hits ignoring non-existent hosts' do
@@ -81,7 +83,7 @@ class InsightsFullSyncTest < ActiveJob::TestCase
81
83
 
82
84
  InsightsCloud::Async::InsightsFullSync.any_instance.expects(:query_insights_hits).returns(hits)
83
85
 
84
- InsightsCloud::Async::InsightsFullSync.perform_now(@host1.organization)
86
+ InsightsCloud::Async::InsightsFullSync.perform_now()
85
87
 
86
88
  @host1.reload
87
89
  @host2.reload
@@ -0,0 +1,91 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class InventoryFullSyncTest < ActiveJob::TestCase
4
+ setup do
5
+ @host1 = FactoryBot.create(:host, :managed, name: 'host1')
6
+
7
+ User.current = User.find_by(login: 'secret_admin')
8
+
9
+ env = FactoryBot.create(:katello_k_t_environment)
10
+ cv = env.content_views << FactoryBot.create(:katello_content_view, organization: env.organization)
11
+
12
+ # this host would pass our plugin queries, so it could be uploaded to the cloud.
13
+ @host2 = FactoryBot.create(
14
+ :host,
15
+ :with_subscription,
16
+ :with_content,
17
+ content_view: cv.first,
18
+ lifecycle_environment: env,
19
+ organization: env.organization
20
+ )
21
+
22
+ @host2.subscription_facet.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
23
+
24
+ ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
25
+
26
+ inventory_json = <<-INVENTORY_JSON
27
+ {
28
+ "total": 3,
29
+ "count": 3,
30
+ "page": 1,
31
+ "per_page": 50,
32
+ "results": [{"fqdn": "#{@host1.fqdn}"}]
33
+ }
34
+ INVENTORY_JSON
35
+ @inventory = JSON.parse(inventory_json)
36
+ end
37
+
38
+ def interesting_facts
39
+ [
40
+ 'dmi::system::uuid',
41
+ 'virt::uuid',
42
+ 'cpu::cpu(s)',
43
+ 'cpu::cpu_socket(s)',
44
+ 'cpu::core(s)_per_socket',
45
+ 'memory::memtotal',
46
+ 'dmi::bios::vendor',
47
+ 'dmi::bios::version',
48
+ 'dmi::bios::relase_date',
49
+ 'uname::release',
50
+ 'lscpu::flags',
51
+ 'distribution::name',
52
+ 'distribution::version',
53
+ 'distribution::id',
54
+ 'virt::is_guest',
55
+ 'dmi::system::manufacturer',
56
+ 'dmi::system::product_name',
57
+ 'dmi::chassis::asset_tag',
58
+ 'insights_client::obfuscate_hostname_enabled',
59
+ 'insights_client::hostname',
60
+ ]
61
+ end
62
+
63
+ def fact_names
64
+ @fact_names ||= Hash[
65
+ interesting_facts.map do |fact|
66
+ [fact, FactoryBot.create(:fact_name, name: fact, type: 'Katello::RhsmFactName')]
67
+ end
68
+ ]
69
+ end
70
+
71
+ test 'Host status should be SYNC for inventory hosts' do
72
+ InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
73
+
74
+ InventorySync::Async::InventoryFullSync.perform_now(@host1.organization)
75
+
76
+ @host1.reload
77
+
78
+ assert_equal InventorySync::InventoryStatus::SYNC, InventorySync::InventoryStatus.where(host_id: @host1.id).first.status
79
+ end
80
+
81
+ test 'Host status should be DISCONNECT for hosts that are not returned from cloud' do
82
+ InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
83
+ FactoryBot.create(:fact_value, fact_name: fact_names['virt::uuid'], value: '1234', host: @host2)
84
+
85
+ InventorySync::Async::InventoryFullSync.perform_now(@host2.organization)
86
+
87
+ @host2.reload
88
+
89
+ assert_equal InventorySync::InventoryStatus::DISCONNECT, InventorySync::InventoryStatus.where(host_id: @host2.id).first.status
90
+ end
91
+ end
@@ -0,0 +1,16 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class InsightsFacetTest < ActiveSupport::TestCase
4
+ setup do
5
+ @host = FactoryBot.create(:host, :with_insights_hits)
6
+ end
7
+
8
+ test 'host with hits can be deleted' do
9
+ assert_equal 1, @host.insights.hits.count
10
+
11
+ host_id = @host.id
12
+ @host.destroy
13
+ actual_host = Host.find_by_id(host_id)
14
+ assert_nil actual_host
15
+ end
16
+ end
@@ -115,7 +115,7 @@ class ReportGeneratorTest < ActiveSupport::TestCase
115
115
  json_str = generator.render
116
116
  actual = JSON.parse(json_str.join("\n"))
117
117
 
118
- obfuscated_fqdn = Digest::SHA1.hexdigest(@host.fqdn)
118
+ obfuscated_fqdn = Digest::SHA1.hexdigest(@host.fqdn) + '.example.com'
119
119
 
120
120
  assert_equal 'slice_123', actual['report_slice_id']
121
121
  assert_not_nil(actual_host = actual['hosts'].first)
@@ -159,13 +159,13 @@ class ReportGeneratorTest < ActiveSupport::TestCase
159
159
  assert_equal 'satellite-id', satellite_facts['satellite_instance_id']
160
160
  assert_equal @host.organization_id, satellite_facts['organization_id']
161
161
 
162
- instance_id_tag = actual['hosts'].first['tags'].find { |tag| tag['namespace'] == 'satellite' && tag['key'] == 'satellite_instance_id'}
163
- assert_not_nil instance_id_tag
164
- assert_equal 'satellite-id', instance_id_tag['value']
162
+ actual_host = actual['hosts'].first
163
+ assert_tag('satellite-id', actual_host, 'satellite_instance_id')
164
+ assert_tag(@host.organization_id.to_s, actual_host, 'organization_id')
165
+ assert_tag(@host.content_view.name, actual_host, 'content_view')
166
+ assert_tag(@host.location.name, actual_host, 'location')
167
+ assert_tag(@host.organization.name, actual_host, 'organization')
165
168
 
166
- org_id_tag = actual['hosts'].first['tags'].find { |tag| tag['namespace'] == 'satellite' && tag['key'] == 'organization_id'}
167
- assert_not_nil org_id_tag
168
- assert_equal @host.organization_id.to_s, org_id_tag['value']
169
169
  assert_equal false, satellite_facts['is_hostname_obfuscated']
170
170
 
171
171
  version = satellite_facts['satellite_version']
@@ -208,6 +208,7 @@ class ReportGeneratorTest < ActiveSupport::TestCase
208
208
  test 'generates a report with system purpose' do
209
209
  @host.subscription_facet.purpose_usage = 'test_usage'
210
210
  @host.subscription_facet.purpose_role = 'test_role'
211
+ @host.subscription_facet.service_level = 'test_sla'
211
212
  @host.subscription_facet.save!
212
213
 
213
214
  batch = Host.where(id: @host.id).in_batches.first
@@ -224,6 +225,7 @@ class ReportGeneratorTest < ActiveSupport::TestCase
224
225
  assert_not_nil(fact_values = host_facts['facts'])
225
226
  assert_equal 'test_usage', fact_values['system_purpose_usage']
226
227
  assert_equal 'test_role', fact_values['system_purpose_role']
228
+ assert_equal 'test_sla', fact_values['system_purpose_sla']
227
229
  end
228
230
 
229
231
  test 'generates a report for a golden ticket' do
@@ -436,4 +438,10 @@ class ReportGeneratorTest < ActiveSupport::TestCase
436
438
  end
437
439
  generator
438
440
  end
441
+
442
+ def assert_tag(expected_value, host, tag_id)
443
+ actual_tag = host['tags'].find { |tag| tag['namespace'] == 'satellite' && tag['key'] == tag_id }
444
+ assert_not_nil actual_tag
445
+ assert_equal expected_value, actual_tag['value']
446
+ end
439
447
  end
@@ -36,6 +36,8 @@ export const hostObfuscationEnabled = true;
36
36
 
37
37
  export const filterTerm = 'some_filter';
38
38
 
39
+ export const cloudToken = 'some-cloud-token';
40
+
39
41
  export const props = {
40
42
  accounts,
41
43
  fetchAccountsStatus: noop,
@@ -45,5 +47,5 @@ export const props = {
45
47
  };
46
48
 
47
49
  export const fetchAccountsStatusResponse = {
48
- data: { accounts, autoUploadEnabled, hostObfuscationEnabled },
50
+ data: { accounts, autoUploadEnabled, hostObfuscationEnabled, cloudToken },
49
51
  };
@@ -11,7 +11,7 @@ import {
11
11
  export const fetchAccountsStatus = () => async dispatch => {
12
12
  try {
13
13
  const {
14
- data: { accounts, autoUploadEnabled, hostObfuscationEnabled },
14
+ data: { accounts, autoUploadEnabled, hostObfuscationEnabled, cloudToken },
15
15
  } = await API.get(inventoryUrl('accounts'));
16
16
  dispatch({
17
17
  type: INVENTORY_ACCOUNT_STATUS_POLLING,
@@ -19,6 +19,7 @@ export const fetchAccountsStatus = () => async dispatch => {
19
19
  accounts,
20
20
  autoUploadEnabled,
21
21
  hostObfuscationEnabled,
22
+ cloudToken,
22
23
  },
23
24
  });
24
25
  } catch (error) {
@@ -24,6 +24,7 @@ export default (state = initialState, action) => {
24
24
  processStatusName,
25
25
  autoUploadEnabled,
26
26
  hostObfuscationEnabled,
27
+ cloudToken,
27
28
  } = {},
28
29
  } = action;
29
30
 
@@ -34,6 +35,7 @@ export default (state = initialState, action) => {
34
35
  accounts,
35
36
  autoUploadEnabled,
36
37
  hostObfuscationEnabled,
38
+ cloudToken,
37
39
  error: null,
38
40
  });
39
41
  case INVENTORY_ACCOUNT_STATUS_POLLING_ERROR:
@@ -15,3 +15,5 @@ export const selectAutoUploadEnabled = state =>
15
15
 
16
16
  export const selectHostObfuscationEnabled = state =>
17
17
  selectAccountsList(state).hostObfuscationEnabled;
18
+
19
+ export const selectCloudToken = state => selectAccountsList(state).cloudToken;
@@ -16,6 +16,7 @@ import {
16
16
  processStatusName,
17
17
  autoUploadEnabled,
18
18
  hostObfuscationEnabled,
19
+ cloudToken,
19
20
  } from '../AccountList.fixtures';
20
21
  import { AUTO_UPLOAD_TOGGLE } from '../../AutoUploadSwitcher/AutoUploadSwitcherConstants';
21
22
  import { HOST_OBFUSCATION_TOGGLE } from '../../HostObfuscationSwitcher/HostObfuscationSwitcherConstants';
@@ -29,6 +30,7 @@ const fixtures = {
29
30
  accounts,
30
31
  autoUploadEnabled,
31
32
  hostObfuscationEnabled,
33
+ cloudToken,
32
34
  },
33
35
  },
34
36
  },
@@ -23,6 +23,7 @@ Array [
23
23
  },
24
24
  },
25
25
  "autoUploadEnabled": true,
26
+ "cloudToken": "some-cloud-token",
26
27
  "hostObfuscationEnabled": true,
27
28
  },
28
29
  "type": "INVENTORY_ACCOUNT_STATUS_POLLING",
@@ -38,6 +38,7 @@ Object {
38
38
  },
39
39
  },
40
40
  "autoUploadEnabled": true,
41
+ "cloudToken": "some-cloud-token",
41
42
  "error": null,
42
43
  "hostObfuscationEnabled": true,
43
44
  "pollingProcessID": 0,
@@ -10,7 +10,11 @@ const FullScreenModal = ({
10
10
  toggleFullScreen,
11
11
  terminalProps,
12
12
  }) => (
13
- <Modal show={showFullScreen} onHide={toggleFullScreen}>
13
+ <Modal
14
+ id="full-screen-terminal"
15
+ show={showFullScreen}
16
+ onHide={toggleFullScreen}
17
+ >
14
18
  <Modal.Header>
15
19
  <button
16
20
  className="close"