foreman_rh_cloud 3.0.21.1 → 3.0.22

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +17 -7
  3. data/app/models/insights_client_report_status.rb +58 -0
  4. data/app/services/foreman_rh_cloud/cloud_auth.rb +12 -0
  5. data/app/services/foreman_rh_cloud/cloud_request.rb +14 -0
  6. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +1 -6
  7. data/app/services/foreman_rh_cloud/remediations_retriever.rb +1 -4
  8. data/app/subscribers/foreman_rh_cloud/insights_subscriber.rb +9 -0
  9. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +19 -0
  10. data/lib/foreman_inventory_upload/generators/slice.rb +6 -6
  11. data/lib/foreman_rh_cloud/engine.rb +4 -1
  12. data/lib/foreman_rh_cloud/version.rb +1 -1
  13. data/lib/insights_cloud/async/insights_full_sync.rb +4 -14
  14. data/lib/insights_cloud/async/insights_resolutions_sync.rb +1 -4
  15. data/lib/insights_cloud/async/insights_rules_sync.rb +2 -7
  16. data/lib/inventory_sync/async/inventory_full_sync.rb +2 -1
  17. data/lib/inventory_sync/async/inventory_scheduled_sync.rb +8 -0
  18. data/lib/inventory_sync/async/query_inventory_job.rb +1 -4
  19. data/lib/tasks/rh_cloud_inventory.rake +6 -0
  20. data/package.json +2 -2
  21. data/test/factories/inventory_upload_factories.rb +1 -1
  22. data/test/jobs/insights_full_sync_test.rb +3 -0
  23. data/test/jobs/insights_resolutions_sync_test.rb +3 -0
  24. data/test/jobs/insights_rules_sync_test.rb +3 -0
  25. data/test/jobs/inventory_full_sync_test.rb +3 -0
  26. data/test/models/insights_client_report_status_test.rb +77 -0
  27. data/test/unit/slice_generator_test.rb +66 -29
  28. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +1 -1
  29. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +1 -1
  30. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +14 -16
  31. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +28 -63
  32. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +2 -3
  33. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +1 -1
  34. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +1 -1
  35. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +2 -2
  36. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +25 -27
  37. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +19 -19
  38. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap +14 -14
  39. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediateButton.js +1 -0
  40. data/webpack/InsightsCloudSync/InsightsCloudSync.js +4 -1
  41. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +44 -20
  42. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +2 -0
  43. data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncActions.test.js.snap +11 -7
  44. data/webpack/common/ForemanTasks/ForemanTasksActions.js +64 -0
  45. data/webpack/common/ForemanTasks/ForemanTasksHelpers.js +7 -0
  46. data/webpack/common/ForemanTasks/index.js +1 -0
  47. metadata +10 -2
@@ -49,7 +49,7 @@ end
49
49
 
50
50
  FactoryBot.define do
51
51
  factory :katello_subscription_facets, :aliases => [:subscription_facet], :class => ::Katello::Host::SubscriptionFacet do
52
- sequence(:uuid) { |n| "uuid-#{n}-#{rand(500)}" }
52
+ sequence(:uuid) { |n| "00000000-%<n>04d-%<r>04d-0000-000000000000" % {n: n, r: rand(500)} }
53
53
  facts { { 'memory.memtotal' => "12 GB" } }
54
54
  end
55
55
  end
@@ -1,6 +1,9 @@
1
1
  require 'test_helper'
2
+ require 'foreman_tasks/test_helpers'
2
3
 
3
4
  class InsightsFullSyncTest < ActiveSupport::TestCase
5
+ include ForemanTasks::TestHelpers::WithInThreadExecutor
6
+
4
7
  setup do
5
8
  InsightsCloud::Async::InsightsFullSync.any_instance.stubs(:plan_rules_sync)
6
9
  InsightsCloud::Async::InsightsFullSync.any_instance.stubs(:plan_notifications)
@@ -1,6 +1,9 @@
1
1
  require 'test_helper'
2
+ require 'foreman_tasks/test_helpers'
2
3
 
3
4
  class InsightsResolutionsSyncTest < ActiveSupport::TestCase
5
+ include ForemanTasks::TestHelpers::WithInThreadExecutor
6
+
4
7
  setup do
5
8
  @resolutions = {
6
9
  "advisor:ansible_deprecated_repo|ANSIBLE_DEPRECATED_REPO" => {
@@ -1,6 +1,9 @@
1
1
  require 'test_helper'
2
+ require 'foreman_tasks/test_helpers'
2
3
 
3
4
  class InsightsRulesSyncTest < ActiveSupport::TestCase
5
+ include ForemanTasks::TestHelpers::WithInThreadExecutor
6
+
4
7
  setup do
5
8
  rules_json = <<-'RULES_JSON'
6
9
  {
@@ -1,6 +1,9 @@
1
1
  require 'test_plugin_helper'
2
+ require 'foreman_tasks/test_helpers'
2
3
 
3
4
  class InventoryFullSyncTest < ActiveSupport::TestCase
5
+ include ForemanTasks::TestHelpers::WithInThreadExecutor
6
+
4
7
  setup do
5
8
  User.current = User.find_by(login: 'secret_admin')
6
9
 
@@ -0,0 +1,77 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class InsightsClientReportStatusTest < ActiveSupport::TestCase
4
+ describe 'to_status' do
5
+ let(:host) { FactoryBot.create(:host, :managed) }
6
+
7
+ setup do
8
+ CommonParameter.where(name: 'host_registration_insights').destroy_all
9
+ end
10
+
11
+ test 'host_registration_insights = true & is getting data' do
12
+ FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: true)
13
+ host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
14
+
15
+ assert_equal 0, host_status.to_status(data: true)
16
+ end
17
+
18
+ test 'host_registration_insights = true & no data in less than 48 hours' do
19
+ FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: true)
20
+ host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
21
+ host_status.update(reported_at: 1.day.ago)
22
+ assert_equal 0, host_status.to_status
23
+ end
24
+
25
+ test 'host_registration_insights = true & no data in more than 48 hours' do
26
+ FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: true)
27
+ host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
28
+ host_status.update(reported_at: 3.days.ago)
29
+ assert_equal 1, host_status.to_status
30
+ end
31
+
32
+ test 'host_registration_insights = false & no data' do
33
+ FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: false)
34
+ host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
35
+ assert_equal 2, host_status.to_status
36
+ end
37
+
38
+ test 'host_registration_insights = false & getting data' do
39
+ FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: false)
40
+ host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
41
+ assert_equal 3, host_status.to_status(data: true)
42
+ end
43
+
44
+ test 'host_registration_insights = nil & is getting data' do
45
+ host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
46
+ assert_equal 3, host_status.to_status(data: true)
47
+ end
48
+
49
+ test 'host_registration_insights = nil & no data in less than 48 hours' do
50
+ host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
51
+ host_status.update(reported_at: 1.day.ago)
52
+ assert_equal 2, host_status.to_status
53
+ end
54
+
55
+ test 'host_registration_insights = nil & no data in more than 48 hours' do
56
+ host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
57
+ host_status.update(reported_at: 3.days.ago)
58
+ assert_equal 2, host_status.to_status
59
+ end
60
+
61
+ test 'override param on host level from `false` to `true`' do
62
+ FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: false)
63
+ FactoryBot.create(:host_parameter, name: 'host_registration_insights', key_type: 'boolean', value: true, host: host)
64
+
65
+ host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
66
+ assert_equal 0, host_status.to_status(data: true)
67
+ end
68
+
69
+ test 'override param on host level from `true` to `false`' do
70
+ FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: true)
71
+ FactoryBot.create(:host_parameter, name: 'host_registration_insights', key_type: 'boolean', value: false, host: host)
72
+
73
+ host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
74
+ assert_equal 2, host_status.to_status
75
+ end
76
+ end
77
+ end
@@ -71,7 +71,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
71
71
  json_str = generator.render
72
72
  actual = JSON.parse(json_str.join("\n"))
73
73
 
74
- assert_equal 'slice_123', actual['report_slice_id']
74
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
75
75
  assert_not_nil(actual_host = actual['hosts'].first)
76
76
  assert_nil actual_host['ip_addresses']
77
77
  assert_nil actual_host['mac_addresses']
@@ -102,7 +102,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
102
102
  json_str = generator.render
103
103
  actual = JSON.parse(json_str.join("\n"))
104
104
 
105
- assert_equal 'slice_123', actual['report_slice_id']
105
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
106
106
  assert_not_nil(actual_host = actual['hosts'].first)
107
107
  assert_not_nil(actual_system_profile = actual_host['system_profile'])
108
108
  assert_equal 4, actual_system_profile['number_of_cpus']
@@ -120,7 +120,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
120
120
  json_str = generator.render
121
121
  actual = JSON.parse(json_str.join("\n"))
122
122
 
123
- assert_equal 'slice_123', actual['report_slice_id']
123
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
124
124
  assert_not_nil(actual_host = actual['hosts'].first)
125
125
  assert_equal @host.interfaces.where.not(ip: nil).first.ip, actual_host['ip_addresses'].first
126
126
  assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
@@ -142,7 +142,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
142
142
  json_str = generator.render
143
143
  actual = JSON.parse(json_str.join("\n"))
144
144
 
145
- assert_equal 'slice_123', actual['report_slice_id']
145
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
146
146
  assert_not_nil(actual_host = actual['hosts'].first)
147
147
  assert_equal @host.interfaces.where.not(ip: nil).first.ip, actual_host['ip_addresses'].first
148
148
  assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
@@ -172,7 +172,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
172
172
  json_str = generator.render
173
173
  actual = JSON.parse(json_str.join("\n"))
174
174
 
175
- assert_equal 'slice_123', actual['report_slice_id']
175
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
176
176
  assert_not_nil(actual_host = actual['hosts'].first)
177
177
  assert_equal @host.interfaces.where.not(ip: nil).first.ip, actual_host['ip_addresses'].first
178
178
  assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
@@ -191,7 +191,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
191
191
  json_str = generator.render
192
192
  actual = JSON.parse(json_str.join("\n"))
193
193
 
194
- assert_equal 'slice_123', actual['report_slice_id']
194
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
195
195
  assert_not_nil(actual_host = actual['hosts'].first)
196
196
  assert_equal '10.230.230.1', actual_host['ip_addresses'].first
197
197
  assert_not_nil(actual_system_profile = actual_host['system_profile'])
@@ -221,7 +221,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
221
221
  json_str = generator.render
222
222
  actual = JSON.parse(json_str.join("\n"))
223
223
 
224
- assert_equal 'slice_123', actual['report_slice_id']
224
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
225
225
  assert_not_nil(actual_host = actual['hosts'].first)
226
226
  assert_equal '10.230.230.100', actual_host['ip_addresses'].first
227
227
  assert_not_nil(actual_system_profile = actual_host['system_profile'])
@@ -243,7 +243,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
243
243
  json_str = generator.render
244
244
  actual = JSON.parse(json_str.join("\n"))
245
245
 
246
- assert_equal 'slice_123', actual['report_slice_id']
246
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
247
247
  assert_not_nil(actual_host = actual['hosts'].first)
248
248
  assert_equal 'obfuscated_name', actual_host['fqdn']
249
249
  assert_equal '1234', actual_host['account']
@@ -263,7 +263,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
263
263
 
264
264
  obfuscated_fqdn = Digest::SHA1.hexdigest(@host.fqdn) + '.example.com'
265
265
 
266
- assert_equal 'slice_123', actual['report_slice_id']
266
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
267
267
  assert_not_nil(actual_host = actual['hosts'].first)
268
268
  assert_equal obfuscated_fqdn, actual_host['fqdn']
269
269
  assert_equal '1234', actual_host['account']
@@ -282,7 +282,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
282
282
  json_str = generator.render
283
283
  actual = JSON.parse(json_str.join("\n"))
284
284
 
285
- assert_equal 'slice_123', actual['report_slice_id']
285
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
286
286
  assert_not_nil(actual_host = actual['hosts'].first)
287
287
  assert_equal @host.fqdn, actual_host['fqdn']
288
288
  assert_equal '1234', actual_host['account']
@@ -296,6 +296,13 @@ class SliceGeneratorTest < ActiveSupport::TestCase
296
296
  @host.hostgroup = hostgroup
297
297
  @host.save!
298
298
 
299
+ ForemanInventoryUpload::Generators::Tags.any_instance.expects(:generate_parameters).returns(
300
+ [
301
+ ['bool_param', true],
302
+ ['int_param', 1],
303
+ ]
304
+ )
305
+
299
306
  Foreman.expects(:instance_id).twice.returns('satellite-id')
300
307
  batch = Host.where(id: @host.id).in_batches.first
301
308
  generator = create_generator(batch)
@@ -316,6 +323,8 @@ class SliceGeneratorTest < ActiveSupport::TestCase
316
323
  assert_tag(@host.location.name, actual_host, 'location')
317
324
  assert_tag(@host.organization.name, actual_host, 'organization')
318
325
  assert_tag(@host.hostgroup.name, actual_host, 'hostgroup')
326
+ assert_tag('true', actual_host, 'bool_param', 'satellite_parameter')
327
+ assert_tag('1', actual_host, 'int_param', 'satellite_parameter')
319
328
 
320
329
  assert_equal false, satellite_facts['is_hostname_obfuscated']
321
330
 
@@ -346,7 +355,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
346
355
  json_str = generator.render
347
356
  actual = JSON.parse(json_str.join("\n"))
348
357
 
349
- assert_equal 'slice_123', actual['report_slice_id']
358
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
350
359
  assert_not_nil(actual_host = actual['hosts'].first)
351
360
  assert_equal @host.fqdn, actual_host['fqdn']
352
361
  assert_not_nil(host_facts = actual_host['facts']&.first)
@@ -368,7 +377,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
368
377
  json_str = generator.render
369
378
  actual = JSON.parse(json_str.join("\n"))
370
379
 
371
- assert_equal 'slice_123', actual['report_slice_id']
380
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
372
381
  assert_not_nil(actual_host = actual['hosts'].first)
373
382
  assert_equal @host.fqdn, actual_host['fqdn']
374
383
  assert_not_nil(host_facts = actual_host['facts']&.first)
@@ -388,7 +397,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
388
397
  json_str = generator.render
389
398
  actual = JSON.parse(json_str.join("\n"))
390
399
 
391
- assert_equal 'slice_123', actual['report_slice_id']
400
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
392
401
  assert_not_nil(actual_host = actual['hosts'].first)
393
402
  assert_equal @host.fqdn, actual_host['fqdn']
394
403
  assert_equal '1234', actual_host['account']
@@ -408,7 +417,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
408
417
  json_str = generator.render
409
418
  actual = JSON.parse(json_str.join("\n"))
410
419
 
411
- assert_equal 'slice_123', actual['report_slice_id']
420
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
412
421
  assert_not_nil(actual_host = actual['hosts'].first)
413
422
  assert_equal @host.fqdn, actual_host['fqdn']
414
423
  assert_equal '1234', actual_host['account']
@@ -427,7 +436,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
427
436
  json_str = generator.render
428
437
  actual = JSON.parse(json_str.join("\n"))
429
438
 
430
- assert_equal 'slice_123', actual['report_slice_id']
439
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
431
440
  assert_equal 1, generator.hosts_count
432
441
  end
433
442
 
@@ -440,7 +449,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
440
449
  json_str = generator.render
441
450
  actual = JSON.parse(json_str.join("\n"))
442
451
 
443
- assert_equal 'slice_123', actual['report_slice_id']
452
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
444
453
  assert_not_nil(actual_host = actual['hosts'].first)
445
454
  assert_not_nil(actual_profile = actual_host['system_profile'])
446
455
  assert_equal 1024, actual_profile['system_memory_bytes']
@@ -466,7 +475,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
466
475
  json_str = generator.render
467
476
  actual = JSON.parse(json_str.join("\n"))
468
477
 
469
- assert_equal 'slice_123', actual['report_slice_id']
478
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
470
479
  assert_not_nil(actual_host = actual['hosts'].first)
471
480
  assert_not_nil(actual_host['account'])
472
481
  assert_not_empty(actual_host['account'])
@@ -483,7 +492,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
483
492
  json_str = generator.render
484
493
  actual = JSON.parse(json_str.join("\n"))
485
494
 
486
- assert_equal 'slice_123', actual['report_slice_id']
495
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
487
496
  assert_not_nil(actual_host = actual['hosts'].first)
488
497
  assert_not_nil(actual_profile = actual_host['system_profile'])
489
498
  assert_equal 'Red Hat Test Linux 7.1 (TestId)', actual_profile['os_release']
@@ -498,7 +507,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
498
507
  json_str = generator.render
499
508
  actual = JSON.parse(json_str.join("\n"))
500
509
 
501
- assert_equal 'slice_123', actual['report_slice_id']
510
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
502
511
  assert_not_nil(actual_host = actual['hosts'].first)
503
512
  assert_not_nil(actual_profile = actual_host['system_profile'])
504
513
  assert_equal 'virtual', actual_profile['infrastructure_type']
@@ -513,7 +522,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
513
522
  json_str = generator.render
514
523
  actual = JSON.parse(json_str.join("\n"))
515
524
 
516
- assert_equal 'slice_123', actual['report_slice_id']
525
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
517
526
  assert_not_nil(actual_host = actual['hosts'].first)
518
527
  assert_not_nil(actual_profile = actual_host['system_profile'])
519
528
  assert_equal 'physical', actual_profile['infrastructure_type']
@@ -528,7 +537,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
528
537
  json_str = generator.render
529
538
  actual = JSON.parse(json_str.join("\n"))
530
539
 
531
- assert_equal 'slice_123', actual['report_slice_id']
540
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
532
541
  assert_not_nil(actual_host = actual['hosts'].first)
533
542
  assert_not_nil(actual_profile = actual_host['system_profile'])
534
543
  assert_equal 'aws', actual_profile['cloud_provider']
@@ -543,7 +552,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
543
552
  json_str = generator.render
544
553
  actual = JSON.parse(json_str.join("\n"))
545
554
 
546
- assert_equal 'slice_123', actual['report_slice_id']
555
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
547
556
  assert_not_nil(actual_host = actual['hosts'].first)
548
557
  assert_not_nil(actual_profile = actual_host['system_profile'])
549
558
  assert_equal 'google', actual_profile['cloud_provider']
@@ -558,7 +567,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
558
567
  json_str = generator.render
559
568
  actual = JSON.parse(json_str.join("\n"))
560
569
 
561
- assert_equal 'slice_123', actual['report_slice_id']
570
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
562
571
  assert_not_nil(actual_host = actual['hosts'].first)
563
572
  assert_not_nil(actual_profile = actual_host['system_profile'])
564
573
  assert_equal 'azure', actual_profile['cloud_provider']
@@ -573,7 +582,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
573
582
  json_str = generator.render
574
583
  actual = JSON.parse(json_str.join("\n"))
575
584
 
576
- assert_equal 'slice_123', actual['report_slice_id']
585
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
577
586
  assert_not_nil(actual_host = actual['hosts'].first)
578
587
  assert_not_nil(actual_profile = actual_host['system_profile'])
579
588
  assert_equal 'alibaba', actual_profile['cloud_provider']
@@ -588,7 +597,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
588
597
  json_str = generator.render
589
598
  actual = JSON.parse(json_str.join("\n"))
590
599
 
591
- assert_equal 'slice_123', actual['report_slice_id']
600
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
592
601
  assert_not_nil(actual_host = actual['hosts'].first)
593
602
  assert_not_nil(actual_profile = actual_host['system_profile'])
594
603
  assert_equal 'alibaba', actual_profile['cloud_provider']
@@ -614,15 +623,43 @@ class SliceGeneratorTest < ActiveSupport::TestCase
614
623
  json_str = generator.render
615
624
  actual = JSON.parse(json_str.join("\n"))
616
625
 
617
- assert_equal 'slice_123', actual['report_slice_id']
626
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
618
627
  assert_not_nil(actual_host = actual['hosts'].first)
619
628
  assert_not_nil(actual_profile = actual_host['system_profile'])
620
629
  assert_not_nil(actual_profile['installed_packages'])
621
630
  end
622
631
 
632
+ test 'omits malformed bios_uuid field' do
633
+ FactoryBot.create(:fact_value, fact_name: fact_names['dmi::system::uuid'], value: 'test value', host: @host)
634
+
635
+ batch = Host.where(id: @host.id).in_batches.first
636
+ generator = create_generator(batch)
637
+
638
+ json_str = generator.render
639
+ actual = JSON.parse(json_str.join("\n"))
640
+
641
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
642
+ assert_not_nil(actual_host = actual['hosts'].first)
643
+ assert_nil actual_host['bios_uuid']
644
+ end
645
+
646
+ test 'passes valid bios_uuid field' do
647
+ FactoryBot.create(:fact_value, fact_name: fact_names['dmi::system::uuid'], value: 'D30B0B42-7824-2635-C62D-491394DE43F7', host: @host)
648
+
649
+ batch = Host.where(id: @host.id).in_batches.first
650
+ generator = create_generator(batch)
651
+
652
+ json_str = generator.render
653
+ actual = JSON.parse(json_str.join("\n"))
654
+
655
+ assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
656
+ assert_not_nil(actual_host = actual['hosts'].first)
657
+ assert_not_nil actual_host['bios_uuid']
658
+ end
659
+
623
660
  private
624
661
 
625
- def create_generator(batch, name = 'slice_123')
662
+ def create_generator(batch, name = '00000000-0000-0000-0000-000000000000')
626
663
  generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], name)
627
664
  if block_given?
628
665
  yield(generator)
@@ -632,8 +669,8 @@ class SliceGeneratorTest < ActiveSupport::TestCase
632
669
  generator
633
670
  end
634
671
 
635
- def assert_tag(expected_value, host, tag_id)
636
- actual_tag = host['tags'].find { |tag| tag['namespace'] == 'satellite' && tag['key'] == tag_id }
672
+ def assert_tag(expected_value, host, tag_id, namespace = 'satellite')
673
+ actual_tag = host['tags'].find { |tag| tag['namespace'] == namespace && tag['key'] == tag_id }
637
674
  assert_not_nil actual_tag
638
675
  assert_equal expected_value, actual_tag['value']
639
676
  end
@@ -12,7 +12,7 @@ const FullScreenModal = ({
12
12
  terminalProps,
13
13
  }) => (
14
14
  <Modal
15
- id="full-screen-terminal"
15
+ id="rh-cloud-inventory-full-screen-terminal"
16
16
  show={showFullScreen}
17
17
  onHide={toggleFullScreen}
18
18
  >
@@ -8,7 +8,7 @@ exports[`FullScreenModal rendering render without Props 1`] = `
8
8
  bsClass="modal"
9
9
  dialogComponentClass={[Function]}
10
10
  enforceFocus={true}
11
- id="full-screen-terminal"
11
+ id="rh-cloud-inventory-full-screen-terminal"
12
12
  keyboard={true}
13
13
  manager={
14
14
  ModalManager {
@@ -1,21 +1,19 @@
1
- .rh-cloud-inventory-page {
2
- #full-screen-terminal {
3
- .modal-dialog {
4
- width: 95%;
5
- height: 95%;
6
- margin: 30px 0 0 30px;
1
+ #rh-cloud-inventory-full-screen-terminal {
2
+ .modal-dialog {
3
+ width: 95%;
4
+ height: 95%;
5
+ margin: 30px 0 0 30px;
7
6
 
8
- .modal-body {
9
- padding: 0;
10
- display: flex;
11
- height: -webkit-fill-available;
12
- height: -moz-available;
13
- height: fill-available;
7
+ .modal-body {
8
+ padding: 0;
9
+ display: flex;
10
+ height: -webkit-fill-available;
11
+ height: -moz-available;
12
+ height: fill-available;
14
13
 
15
- .terminal {
16
- margin: 0 -20px;
17
- height: 100%;
18
- }
14
+ .rh-cloud-inventory-terminal {
15
+ margin: 0 -20px;
16
+ height: 100%;
19
17
  }
20
18
  }
21
19
  }