foreman_rh_cloud 3.0.21 → 4.0.23

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/rh_cloud/inventory_controller.rb +50 -0
  3. data/app/controllers/concerns/inventory_upload/report_actions.rb +26 -0
  4. data/app/controllers/concerns/inventory_upload/task_actions.rb +25 -0
  5. data/app/controllers/foreman_inventory_upload/reports_controller.rb +3 -1
  6. data/app/controllers/foreman_inventory_upload/tasks_controller.rb +5 -13
  7. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +4 -4
  8. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +1 -0
  9. data/app/controllers/insights_cloud/hits_controller.rb +7 -3
  10. data/app/helpers/foreman_insights_host_helper.rb +19 -0
  11. data/app/services/foreman_rh_cloud/cloud_auth.rb +12 -0
  12. data/app/services/foreman_rh_cloud/cloud_request.rb +14 -0
  13. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +1 -6
  14. data/app/services/foreman_rh_cloud/remediations_retriever.rb +1 -4
  15. data/config/package-lock.json.plugin +30931 -0
  16. data/config/routes.rb +19 -0
  17. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +19 -0
  18. data/lib/foreman_inventory_upload/generators/slice.rb +6 -6
  19. data/lib/foreman_rh_cloud/engine.rb +13 -7
  20. data/lib/foreman_rh_cloud/version.rb +1 -1
  21. data/lib/insights_cloud/async/insights_full_sync.rb +4 -14
  22. data/lib/insights_cloud/async/insights_resolutions_sync.rb +1 -4
  23. data/lib/insights_cloud/async/insights_rules_sync.rb +2 -7
  24. data/lib/inventory_sync/async/inventory_full_sync.rb +2 -1
  25. data/lib/inventory_sync/async/inventory_hosts_sync.rb +6 -2
  26. data/lib/inventory_sync/async/inventory_scheduled_sync.rb +12 -0
  27. data/lib/inventory_sync/async/query_inventory_job.rb +1 -4
  28. data/lib/tasks/rh_cloud_inventory.rake +8 -1
  29. data/package.json +1 -1
  30. data/test/controllers/inventory_upload/api/inventory_controller_test.rb +53 -0
  31. data/test/factories/inventory_upload_factories.rb +1 -1
  32. data/test/jobs/insights_full_sync_test.rb +3 -0
  33. data/test/jobs/insights_resolutions_sync_test.rb +3 -0
  34. data/test/jobs/insights_rules_sync_test.rb +3 -0
  35. data/test/jobs/inventory_full_sync_test.rb +3 -0
  36. data/test/jobs/inventory_hosts_sync_test.rb +265 -0
  37. data/test/jobs/inventory_scheduled_sync_test.rb +22 -0
  38. data/test/test_plugin_helper.rb +2 -1
  39. data/test/unit/slice_generator_test.rb +66 -29
  40. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +1 -1
  41. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +1 -1
  42. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +14 -16
  43. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +11 -0
  44. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +11 -0
  45. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +28 -63
  46. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +2 -3
  47. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +1 -1
  48. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +1 -1
  49. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +2 -2
  50. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +25 -27
  51. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +19 -19
  52. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +0 -2
  53. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap +14 -14
  54. data/webpack/InsightsCloudSync/InsightsCloudSync.js +4 -1
  55. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +44 -20
  56. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +2 -0
  57. data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncActions.test.js.snap +11 -7
  58. data/webpack/common/ForemanTasks/ForemanTasksActions.js +64 -0
  59. data/webpack/common/ForemanTasks/ForemanTasksHelpers.js +7 -0
  60. data/webpack/common/ForemanTasks/index.js +1 -0
  61. metadata +17 -2
@@ -0,0 +1,22 @@
1
+ require 'test_plugin_helper'
2
+ require 'foreman_tasks/test_helpers'
3
+
4
+ class InventoryScheduledSyncTest < ActiveSupport::TestCase
5
+ include ForemanTasks::TestHelpers::WithInThreadExecutor
6
+
7
+ test 'Schedules an execution if auto upload is enabled' do
8
+ FactoryBot.create(:setting, :name => 'allow_auto_inventory_upload', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => true)
9
+
10
+ InventorySync::Async::InventoryScheduledSync.any_instance.expects(:plan_org_sync).times(Organization.unscoped.count)
11
+
12
+ ForemanTasks.sync_task(InventorySync::Async::InventoryScheduledSync)
13
+ end
14
+
15
+ test 'Skips execution if auto upload is disabled' do
16
+ FactoryBot.create(:setting, :name => 'allow_auto_inventory_upload', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => false)
17
+
18
+ InventorySync::Async::InventoryScheduledSync.any_instance.expects(:plan_org_sync).never
19
+
20
+ ForemanTasks.sync_task(InventorySync::Async::InventoryScheduledSync)
21
+ end
22
+ end
@@ -2,6 +2,8 @@
2
2
  require 'test_helper'
3
3
 
4
4
  # Add plugin to FactoryBot's paths
5
+ FactoryBot.definition_file_paths << "#{ForemanTasks::Engine.root}/test/factories"
6
+ FactoryBot.definition_file_paths << "#{ForemanRemoteExecution::Engine.root}/test/factories"
5
7
  FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
8
  # FactoryBot.definition_file_paths << "#{Katello::Engine.root}/test/factories"
7
9
  FactoryBot.reload
@@ -33,7 +35,6 @@ module KatelloLocationFix
33
35
  FactoryBot.create(:setting, name: 'default_location_subscribed_hosts')
34
36
  FactoryBot.create(:setting, name: 'default_location_puppet_content')
35
37
  Setting[:default_location_subscribed_hosts] = Location.first.title
36
- Setting[:default_location_puppet_content] = Location.first.title
37
38
  end
38
39
  end
39
40
  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
  }
@@ -31,6 +31,17 @@ export const PageDescription = () => (
31
31
  About subscription watch
32
32
  </a>
33
33
  </p>
34
+ <p>
35
+ {__('For more information about Insights and Cloud Connector read')}
36
+ &nbsp;
37
+ <a
38
+ href="https://console.redhat.com/security/insights/"
39
+ target="_blank"
40
+ rel="noopener noreferrer"
41
+ >
42
+ Red Hat Insights Data and Application Security
43
+ </a>
44
+ </p>
34
45
  </div>
35
46
  );
36
47
 
@@ -24,5 +24,16 @@ exports[`PageDescription rendering render without Props 1`] = `
24
24
  About subscription watch
25
25
  </a>
26
26
  </p>
27
+ <p>
28
+ For more information about Insights and Cloud Connector read
29
+  
30
+ <a
31
+ href="https://console.redhat.com/security/insights/"
32
+ rel="noopener noreferrer"
33
+ target="_blank"
34
+ >
35
+ Red Hat Insights Data and Application Security
36
+ </a>
37
+ </p>
27
38
  </div>
28
39
  `;
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { get, post } from 'foremanReact/redux/API';
3
- import { withInterval } from 'foremanReact/redux/middlewares/IntervalMiddleware';
2
+ import { post } from 'foremanReact/redux/API';
4
3
  import { addToast } from 'foremanReact/redux/actions/toasts';
5
4
  import { translate as __ } from 'foremanReact/common/I18n';
6
5
  import { inventoryUrl } from '../../../../ForemanInventoryHelpers';
@@ -9,7 +8,10 @@ import {
9
8
  INVENTORY_SYNC,
10
9
  INVENTORY_SYNC_TASK_UPDATE,
11
10
  } from './SyncButtonConstants';
12
- import { foremanUrl } from '../../../../../ForemanRhCloudHelpers';
11
+ import {
12
+ setupTaskPolling,
13
+ taskRelatedToast,
14
+ } from '../../../../../common/ForemanTasks';
13
15
 
14
16
  export const handleSync = () => dispatch => {
15
17
  dispatch(
@@ -21,9 +23,9 @@ export const handleSync = () => dispatch => {
21
23
  task: { id },
22
24
  },
23
25
  }) => {
24
- dispatch(getSyncTaskInterval(id));
26
+ dispatch(setupInventorySyncTaskPolling(id, dispatch));
25
27
  return dispatch(
26
- taskPageRefererToast(id, 'info', __('Inventory sync has started:'))
28
+ taskRelatedToast(id, 'info', __('Inventory sync has started:'))
27
29
  );
28
30
  },
29
31
  errorToast: inventorySyncErrorToast,
@@ -31,62 +33,25 @@ export const handleSync = () => dispatch => {
31
33
  );
32
34
  };
33
35
 
34
- export const getSyncTaskInterval = id => dispatch => {
35
- dispatch(
36
- withInterval(
37
- get({
38
- key: INVENTORY_SYNC_TASK_UPDATE,
39
- url: inventoryUrl(`tasks/${id}`),
40
- handleSuccess: ({ data: { result, output } }, stopTaskInterval) => {
41
- if (result === 'success') {
42
- const {
43
- host_statuses: { sync, disconnect },
44
- } = output;
45
- dispatch(
46
- addToast({
47
- sticky: true,
48
- type: 'success',
49
- message: (
50
- <Toast syncHosts={sync} disconnectHosts={disconnect} />
51
- ),
52
- })
53
- );
54
- }
55
- if (result === 'error') {
56
- dispatch(
57
- taskPageRefererToast(
58
- id,
59
- 'error',
60
- __('Inventory sync has failed:'),
61
- true
62
- )
63
- );
64
- }
65
- stopTaskInterval();
66
- },
67
- errorToast: inventorySyncErrorToast,
68
- })
69
- )
70
- );
71
- };
72
-
73
- const inventorySyncErrorToast = ({ message, response }) =>
74
- `${__('Inventory sync has failed: ')} ${response.data?.message || message}`;
75
-
76
- const taskPageRefererToast = (taskID, toastType, prefix, sticky = false) =>
77
- addToast({
78
- sticky,
79
- type: toastType,
80
- message: (
81
- <span>
82
- {prefix}{' '}
83
- <a
84
- target="_blank"
85
- rel="noopener noreferrer"
86
- href={foremanUrl(`/foreman_tasks/tasks/${taskID}`)}
87
- >
88
- {__('view the task page for more details')}
89
- </a>
90
- </span>
91
- ),
36
+ export const setupInventorySyncTaskPolling = (id, dispatch) =>
37
+ setupTaskPolling({
38
+ taskId: id,
39
+ key: INVENTORY_SYNC_TASK_UPDATE,
40
+ onTaskSuccess: ({
41
+ output: {
42
+ host_statuses: { sync, disconnect },
43
+ },
44
+ }) =>
45
+ dispatch(
46
+ addToast({
47
+ sticky: true,
48
+ type: 'success',
49
+ message: <Toast syncHosts={sync} disconnectHosts={disconnect} />,
50
+ })
51
+ ),
52
+ dispatch,
92
53
  });
54
+
55
+ const inventorySyncErrorToast = message =>
56
+ `${__('Inventory sync has failed: ')} ${message.response?.data?.message ||
57
+ message}`;