foreman_rh_cloud 13.0.6 → 13.0.8

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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/foreman_rh_cloud/registration_manager_extensions.rb +39 -0
  3. data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +3 -2
  4. data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +1 -1
  5. data/lib/foreman_inventory_upload.rb +6 -2
  6. data/lib/foreman_rh_cloud/engine.rb +1 -0
  7. data/lib/foreman_rh_cloud/plugin.rb +4 -0
  8. data/lib/foreman_rh_cloud/version.rb +1 -1
  9. data/lib/tasks/rh_cloud_inventory.rake +11 -1
  10. data/package.json +1 -1
  11. data/test/jobs/cloud_connector_announce_task_test.rb +3 -2
  12. data/test/jobs/connector_playbook_execution_reporter_task_test.rb +32 -20
  13. data/test/jobs/create_missing_insights_facets_test.rb +151 -0
  14. data/test/jobs/exponential_backoff_test.rb +9 -8
  15. data/test/jobs/generate_host_report_test.rb +100 -0
  16. data/test/jobs/generate_report_job_test.rb +146 -0
  17. data/test/jobs/host_inventory_report_job_test.rb +244 -0
  18. data/test/jobs/insights_client_status_aging_test.rb +3 -2
  19. data/test/jobs/insights_full_sync_test.rb +13 -7
  20. data/test/jobs/insights_resolutions_sync_test.rb +9 -5
  21. data/test/jobs/insights_rules_sync_test.rb +5 -3
  22. data/test/jobs/inventory_full_sync_test.rb +9 -5
  23. data/test/jobs/inventory_hosts_sync_test.rb +11 -6
  24. data/test/jobs/inventory_scheduled_sync_test.rb +10 -6
  25. data/test/jobs/inventory_self_host_sync_test.rb +1 -1
  26. data/test/jobs/queue_for_upload_job_test.rb +9 -7
  27. data/test/jobs/remove_insights_hosts_job_test.rb +14 -15
  28. data/test/jobs/single_host_report_job_test.rb +155 -0
  29. data/test/jobs/upload_report_job_test.rb +5 -4
  30. data/test/unit/lib/foreman_rh_cloud/registration_manager_extensions_test.rb +192 -0
  31. data/webpack/ForemanColumnExtensions/index.js +2 -0
  32. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +3 -3
  33. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +3 -9
  34. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +13 -0
  35. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js +2 -2
  36. data/webpack/InsightsCloudSync/Components/ToolbarDropdown.js +3 -3
  37. data/webpack/InsightsCloudSync/InsightsCloudSync.js +3 -3
  38. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +10 -0
  39. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -1
  40. data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +5 -5
  41. data/webpack/InsightsVulnerabilityHostIndexExtensions/CVECountCell.js +2 -2
  42. data/webpack/InsightsVulnerabilityHostIndexExtensions/__tests__/CVECountCell.test.js +7 -7
  43. data/webpack/common/Hooks/ConfigHooks.js +3 -16
  44. metadata +14 -1
@@ -0,0 +1,146 @@
1
+ require 'test_plugin_helper'
2
+ require 'foreman_tasks/test_helpers'
3
+
4
+ class GenerateReportJobTest < ActiveSupport::TestCase
5
+ include Dynflow::Testing::Factories
6
+ include Dynflow::Testing::Assertions
7
+
8
+ let(:organization) { FactoryBot.create(:organization) }
9
+ let(:base_folder) { Dir.mktmpdir }
10
+
11
+ setup do
12
+ # Stub settings
13
+ Setting.stubs(:[]).with(:subscription_connection_enabled).returns(true)
14
+ Setting.stubs(:[]).with("foreman_tasks_sync_task_timeout").returns(120)
15
+ Setting.stubs(:[]).with(:content_default_http_proxy).returns(nil)
16
+ Setting.stubs(:[]).with(:http_proxy).returns(nil)
17
+ end
18
+
19
+ teardown do
20
+ FileUtils.remove_entry base_folder if Dir.exist?(base_folder)
21
+ end
22
+
23
+ test 'disconnected parameter defaults to false' do
24
+ # When disconnected defaults to false and subscription_connection is enabled,
25
+ # QueueForUploadJob should be scheduled
26
+ action = create_and_plan_action(
27
+ ForemanInventoryUpload::Async::GenerateReportJob,
28
+ base_folder,
29
+ organization.id
30
+ )
31
+
32
+ assert_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
33
+ end
34
+
35
+ test 'disconnected parameter can be set to true explicitly' do
36
+ # When disconnected is explicitly true, QueueForUploadJob should NOT be scheduled
37
+ action = create_and_plan_action(
38
+ ForemanInventoryUpload::Async::GenerateReportJob,
39
+ base_folder,
40
+ organization.id,
41
+ true
42
+ )
43
+
44
+ refute_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
45
+ end
46
+
47
+ test 'disconnected parameter can be set to false explicitly' do
48
+ # When disconnected is explicitly false and subscription_connection is enabled,
49
+ # QueueForUploadJob should be scheduled
50
+ action = create_and_plan_action(
51
+ ForemanInventoryUpload::Async::GenerateReportJob,
52
+ base_folder,
53
+ organization.id,
54
+ false
55
+ )
56
+
57
+ assert_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
58
+ end
59
+
60
+ test 'skips upload when subscription_connection_enabled is false' do
61
+ Setting.stubs(:[]).with(:subscription_connection_enabled).returns(false)
62
+
63
+ action = create_and_plan_action(
64
+ ForemanInventoryUpload::Async::GenerateReportJob,
65
+ base_folder,
66
+ organization.id,
67
+ false
68
+ )
69
+
70
+ refute_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
71
+ end
72
+
73
+ test 'schedules upload when disconnected is false and subscription_connection is enabled' do
74
+ Setting.stubs(:[]).with(:subscription_connection_enabled).returns(true)
75
+
76
+ expected_archive_name = ForemanInventoryUpload.facts_archive_name(organization.id, nil)
77
+ action = create_and_plan_action(
78
+ ForemanInventoryUpload::Async::GenerateReportJob,
79
+ base_folder,
80
+ organization.id,
81
+ false
82
+ )
83
+
84
+ assert_action_planned_with(
85
+ action,
86
+ ForemanInventoryUpload::Async::QueueForUploadJob,
87
+ base_folder,
88
+ expected_archive_name,
89
+ organization.id
90
+ )
91
+ end
92
+
93
+ test 'handles hosts_filter parameter' do
94
+ hosts_filter = 'name~test'
95
+ expected_archive_name = ForemanInventoryUpload.facts_archive_name(organization.id, hosts_filter)
96
+
97
+ action = create_and_plan_action(
98
+ ForemanInventoryUpload::Async::GenerateReportJob,
99
+ base_folder,
100
+ organization.id,
101
+ false,
102
+ hosts_filter
103
+ )
104
+
105
+ assert_action_planned_with(
106
+ action,
107
+ ForemanInventoryUpload::Async::QueueForUploadJob,
108
+ base_folder,
109
+ expected_archive_name,
110
+ organization.id
111
+ )
112
+ end
113
+
114
+ test 'output_label generates correct label' do
115
+ label = ForemanInventoryUpload::Async::GenerateReportJob.output_label('test_org')
116
+ assert_equal 'report_for_test_org', label
117
+ end
118
+
119
+ test 'output_label with filter includes parameterized filter' do
120
+ action = create_and_plan_action(
121
+ ForemanInventoryUpload::Async::GenerateReportJob,
122
+ base_folder,
123
+ organization.id,
124
+ false,
125
+ 'name~production'
126
+ )
127
+
128
+ # The output label should include organization id and parameterized filter
129
+ expected_label = "report_for_#{organization.id}[name-production]"
130
+ assert_equal expected_label, action.input[:instance_label]
131
+ end
132
+
133
+ test 'output_label without filter includes only organization id' do
134
+ action = create_and_plan_action(
135
+ ForemanInventoryUpload::Async::GenerateReportJob,
136
+ base_folder,
137
+ organization.id,
138
+ false,
139
+ ''
140
+ )
141
+
142
+ # The output label should include only organization id when filter is empty
143
+ expected_label = "report_for_#{organization.id}"
144
+ assert_equal expected_label, action.input[:instance_label]
145
+ end
146
+ end
@@ -0,0 +1,244 @@
1
+ require 'test_plugin_helper'
2
+ require 'foreman_tasks/test_helpers'
3
+
4
+ class HostInventoryReportJobTest < ActiveSupport::TestCase
5
+ include Dynflow::Testing::Factories
6
+ include Dynflow::Testing::Assertions
7
+
8
+ let(:organization) { FactoryBot.create(:organization) }
9
+ let(:base_folder) { Dir.mktmpdir }
10
+ let(:hosts_filter) { '' }
11
+ let(:upload) { true }
12
+
13
+ teardown do
14
+ FileUtils.remove_entry base_folder if Dir.exist?(base_folder)
15
+ end
16
+
17
+ test 'plan schedules GenerateHostReport action' do
18
+ action = create_and_plan_action(
19
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
20
+ base_folder,
21
+ organization.id,
22
+ hosts_filter,
23
+ upload
24
+ )
25
+
26
+ assert_action_planned_with(
27
+ action,
28
+ ForemanInventoryUpload::Async::GenerateHostReport,
29
+ base_folder,
30
+ organization.id,
31
+ hosts_filter
32
+ )
33
+ end
34
+
35
+ test 'plan schedules QueueForUploadJob when upload is true' do
36
+ expected_archive_name = ForemanInventoryUpload.facts_archive_name(organization.id, hosts_filter)
37
+
38
+ action = create_and_plan_action(
39
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
40
+ base_folder,
41
+ organization.id,
42
+ hosts_filter,
43
+ true
44
+ )
45
+
46
+ assert_action_planned_with(
47
+ action,
48
+ ForemanInventoryUpload::Async::QueueForUploadJob,
49
+ base_folder,
50
+ expected_archive_name,
51
+ organization.id
52
+ )
53
+ end
54
+
55
+ test 'plan skips QueueForUploadJob when upload is false' do
56
+ action = create_and_plan_action(
57
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
58
+ base_folder,
59
+ organization.id,
60
+ hosts_filter,
61
+ false
62
+ )
63
+
64
+ refute_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
65
+ end
66
+
67
+ test 'plan defaults upload to true when not specified' do
68
+ action = create_and_plan_action(
69
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
70
+ base_folder,
71
+ organization.id,
72
+ hosts_filter
73
+ )
74
+
75
+ assert_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
76
+ end
77
+
78
+ test 'plan schedules CreateMissingInsightsFacets when IoP is enabled' do
79
+ ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(true)
80
+
81
+ action = create_and_plan_action(
82
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
83
+ base_folder,
84
+ organization.id,
85
+ hosts_filter,
86
+ upload
87
+ )
88
+
89
+ assert_action_planned_with(
90
+ action,
91
+ ForemanInventoryUpload::Async::CreateMissingInsightsFacets,
92
+ organization.id
93
+ )
94
+ end
95
+
96
+ test 'plan skips CreateMissingInsightsFacets when IoP is disabled' do
97
+ ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(false)
98
+
99
+ action = create_and_plan_action(
100
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
101
+ base_folder,
102
+ organization.id,
103
+ hosts_filter,
104
+ upload
105
+ )
106
+
107
+ refute_action_planned(action, ForemanInventoryUpload::Async::CreateMissingInsightsFacets)
108
+ end
109
+
110
+ test 'plan schedules all three actions with IoP enabled and upload true' do
111
+ ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(true)
112
+
113
+ action = create_and_plan_action(
114
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
115
+ base_folder,
116
+ organization.id,
117
+ hosts_filter,
118
+ true
119
+ )
120
+
121
+ assert_action_planned(action, ForemanInventoryUpload::Async::GenerateHostReport)
122
+ assert_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
123
+ assert_action_planned(action, ForemanInventoryUpload::Async::CreateMissingInsightsFacets)
124
+ end
125
+
126
+ test 'plan schedules only generation and facets with IoP enabled and upload false' do
127
+ ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(true)
128
+
129
+ action = create_and_plan_action(
130
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
131
+ base_folder,
132
+ organization.id,
133
+ hosts_filter,
134
+ false
135
+ )
136
+
137
+ assert_action_planned(action, ForemanInventoryUpload::Async::GenerateHostReport)
138
+ refute_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
139
+ assert_action_planned(action, ForemanInventoryUpload::Async::CreateMissingInsightsFacets)
140
+ end
141
+
142
+ test 'humanized_name returns correct string' do
143
+ action = create_and_plan_action(
144
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
145
+ base_folder,
146
+ organization.id,
147
+ hosts_filter,
148
+ upload
149
+ )
150
+
151
+ assert_equal 'Host inventory report job', action.humanized_name
152
+ end
153
+
154
+ test 'handles empty hosts_filter parameter' do
155
+ action = create_and_plan_action(
156
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
157
+ base_folder,
158
+ organization.id,
159
+ '',
160
+ upload
161
+ )
162
+
163
+ assert_action_planned_with(
164
+ action,
165
+ ForemanInventoryUpload::Async::GenerateHostReport,
166
+ base_folder,
167
+ organization.id,
168
+ ''
169
+ )
170
+ end
171
+
172
+ test 'handles custom hosts_filter parameter' do
173
+ custom_filter = 'name~production'
174
+ expected_archive_name = ForemanInventoryUpload.facts_archive_name(organization.id, custom_filter)
175
+
176
+ action = create_and_plan_action(
177
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
178
+ base_folder,
179
+ organization.id,
180
+ custom_filter,
181
+ upload
182
+ )
183
+
184
+ assert_action_planned_with(
185
+ action,
186
+ ForemanInventoryUpload::Async::GenerateHostReport,
187
+ base_folder,
188
+ organization.id,
189
+ custom_filter
190
+ )
191
+ assert_action_planned_with(
192
+ action,
193
+ ForemanInventoryUpload::Async::QueueForUploadJob,
194
+ base_folder,
195
+ expected_archive_name,
196
+ organization.id
197
+ )
198
+ end
199
+
200
+ test 'handles invalid hosts_filter parameter' do
201
+ invalid_filter = 'name~~'
202
+
203
+ action = create_and_plan_action(
204
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
205
+ base_folder,
206
+ organization.id,
207
+ invalid_filter,
208
+ upload
209
+ )
210
+
211
+ # Job should still plan even with invalid filter syntax
212
+ assert_action_planned(action, ForemanInventoryUpload::Async::GenerateHostReport)
213
+ end
214
+
215
+ test 'handles potentially malicious hosts_filter parameter' do
216
+ malicious_filter = "'; DROP TABLE hosts; --"
217
+
218
+ action = create_and_plan_action(
219
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
220
+ base_folder,
221
+ organization.id,
222
+ malicious_filter,
223
+ upload
224
+ )
225
+
226
+ # Job should handle malicious input safely (filter is parameterized)
227
+ assert_action_planned(action, ForemanInventoryUpload::Async::GenerateHostReport)
228
+ end
229
+
230
+ test 'handles non-matching hosts_filter parameter' do
231
+ non_matching_filter = 'name~doesnotexist'
232
+
233
+ action = create_and_plan_action(
234
+ ForemanInventoryUpload::Async::HostInventoryReportJob,
235
+ base_folder,
236
+ organization.id,
237
+ non_matching_filter,
238
+ upload
239
+ )
240
+
241
+ # Job should plan successfully even if filter matches no hosts
242
+ assert_action_planned(action, ForemanInventoryUpload::Async::GenerateHostReport)
243
+ end
244
+ end
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
  require 'foreman_tasks/test_helpers'
3
3
 
4
4
  class InsightsClientStatusAgingTest < ActiveSupport::TestCase
5
- include ForemanTasks::TestHelpers::WithInThreadExecutor
5
+ include Dynflow::Testing::Factories
6
6
 
7
7
  setup do
8
8
  User.current = User.find_by(login: 'secret_admin')
@@ -21,7 +21,8 @@ class InsightsClientStatusAgingTest < ActiveSupport::TestCase
21
21
  InsightsClientReportStatus.find_or_initialize_by(host_id: @host3.id).update(status: InsightsClientReportStatus::REPORTING, reported_at: Time.now - InsightsClientReportStatus::REPORT_INTERVAL - 1.day)
22
22
  InsightsClientReportStatus.find_or_initialize_by(host_id: @host4.id).update(status: InsightsClientReportStatus::NO_REPORT, reported_at: Time.now - InsightsClientReportStatus::REPORT_INTERVAL - 1.day)
23
23
 
24
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsClientStatusAging)
24
+ action = create_and_plan_action(InsightsCloud::Async::InsightsClientStatusAging)
25
+ run_action(action)
25
26
 
26
27
  @hosts.each(&:reload)
27
28
 
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
  require 'foreman_tasks/test_helpers'
3
3
 
4
4
  class InsightsFullSyncTest < ActiveSupport::TestCase
5
- include ForemanTasks::TestHelpers::WithInThreadExecutor
5
+ include Dynflow::Testing::Factories
6
6
  include MockCerts
7
7
 
8
8
  setup do
@@ -72,7 +72,8 @@ class InsightsFullSyncTest < ActiveSupport::TestCase
72
72
  InsightsCloud::Async::InsightsFullSync.any_instance.expects(:plan_hosts_sync)
73
73
  InsightsCloud::Async::InsightsFullSync.any_instance.expects(:plan_rules_sync)
74
74
  InsightsCloud::Async::InsightsFullSync.any_instance.expects(:plan_notifications)
75
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsFullSync, [@host1.organization, @host2.organization])
75
+ action = create_and_plan_action(InsightsCloud::Async::InsightsFullSync, [@host1.organization, @host2.organization])
76
+ run_action(action)
76
77
 
77
78
  @host1.reload
78
79
  @host2.reload
@@ -89,7 +90,8 @@ class InsightsFullSyncTest < ActiveSupport::TestCase
89
90
  InsightsCloud::Async::InsightsFullSync.any_instance.expects(:plan_hosts_sync).never
90
91
  InsightsCloud::Async::InsightsFullSync.any_instance.expects(:plan_self).never
91
92
 
92
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsFullSync, [@host1.organization])
93
+ action = create_and_plan_action(InsightsCloud::Async::InsightsFullSync, [@host1.organization])
94
+ run_action(action)
93
95
  end
94
96
 
95
97
  test 'Manifest is deleted do not run task steps' do
@@ -100,7 +102,8 @@ class InsightsFullSyncTest < ActiveSupport::TestCase
100
102
  InsightsCloud::Async::InsightsFullSync.any_instance.expects(:plan_hosts_sync).never
101
103
  InsightsCloud::Async::InsightsFullSync.any_instance.expects(:plan_self).never
102
104
 
103
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsFullSync, [@host1.organization])
105
+ action = create_and_plan_action(InsightsCloud::Async::InsightsFullSync, [@host1.organization])
106
+ run_action(action)
104
107
  end
105
108
 
106
109
  test 'Hits counters are reset correctly' do
@@ -110,9 +113,11 @@ class InsightsFullSyncTest < ActiveSupport::TestCase
110
113
 
111
114
  InsightsCloud::Async::InsightsFullSync.any_instance.stubs(:plan_hosts_sync)
112
115
 
113
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsFullSync, [@host1.organization, @host2.organization])
116
+ action = create_and_plan_action(InsightsCloud::Async::InsightsFullSync, [@host1.organization, @host2.organization])
117
+ run_action(action)
114
118
  # Invoke again
115
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsFullSync, [@host1.organization, @host2.organization])
119
+ action = create_and_plan_action(InsightsCloud::Async::InsightsFullSync, [@host1.organization, @host2.organization])
120
+ run_action(action)
116
121
 
117
122
  @host1.reload
118
123
  @host2.reload
@@ -146,7 +151,8 @@ class InsightsFullSyncTest < ActiveSupport::TestCase
146
151
  InsightsCloud::Async::InsightsFullSync.any_instance.stubs(:plan_hosts_sync)
147
152
  InsightsCloud::Async::InsightsFullSync.any_instance.expects(:query_insights_hits).returns(hits)
148
153
 
149
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsFullSync, [@host1.organization, @host2.organization])
154
+ action = create_and_plan_action(InsightsCloud::Async::InsightsFullSync, [@host1.organization, @host2.organization])
155
+ run_action(action)
150
156
 
151
157
  @host1.reload
152
158
  @host2.reload
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
  require 'foreman_tasks/test_helpers'
3
3
 
4
4
  class InsightsResolutionsSyncTest < ActiveSupport::TestCase
5
- include ForemanTasks::TestHelpers::WithInThreadExecutor
5
+ include Dynflow::Testing::Factories
6
6
  include MockCerts
7
7
 
8
8
  setup do
@@ -76,7 +76,8 @@ class InsightsResolutionsSyncTest < ActiveSupport::TestCase
76
76
  Katello::UpstreamConnectionChecker.any_instance.stubs(:can_connect?).returns(true)
77
77
  InsightsCloud::Async::InsightsResolutionsSync.any_instance.stubs(:query_insights_resolutions).returns(@resolutions)
78
78
 
79
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsResolutionsSync)
79
+ action = create_and_plan_action(InsightsCloud::Async::InsightsResolutionsSync)
80
+ run_action(action)
80
81
  @rule.reload
81
82
 
82
83
  assert_equal 5, InsightsResolution.all.count
@@ -88,7 +89,8 @@ class InsightsResolutionsSyncTest < ActiveSupport::TestCase
88
89
  Katello::UpstreamConnectionChecker.any_instance.stubs(:can_connect?).returns(false)
89
90
  InsightsCloud::Async::InsightsResolutionsSync.any_instance.expects(:query_insights_resolutions).never
90
91
 
91
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsResolutionsSync)
92
+ action = create_and_plan_action(InsightsCloud::Async::InsightsResolutionsSync)
93
+ run_action(action)
92
94
 
93
95
  assert_equal 0, InsightsResolution.all.count
94
96
  end
@@ -98,7 +100,8 @@ class InsightsResolutionsSyncTest < ActiveSupport::TestCase
98
100
  Katello::UpstreamConnectionChecker.any_instance.stubs(:can_connect?).returns(true)
99
101
  InsightsCloud::Async::InsightsResolutionsSync.any_instance.expects(:query_insights_resolutions).never
100
102
 
101
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsResolutionsSync)
103
+ action = create_and_plan_action(InsightsCloud::Async::InsightsResolutionsSync)
104
+ run_action(action)
102
105
 
103
106
  assert_equal 0, InsightsResolution.all.count
104
107
  end
@@ -108,7 +111,8 @@ class InsightsResolutionsSyncTest < ActiveSupport::TestCase
108
111
  InsightsCloud::Async::InsightsResolutionsSync.any_instance.expects(:query_insights_resolutions).never
109
112
  InsightsRule.all.delete_all
110
113
 
111
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsResolutionsSync)
114
+ action = create_and_plan_action(InsightsCloud::Async::InsightsResolutionsSync)
115
+ run_action(action)
112
116
 
113
117
  assert_equal 0, InsightsResolution.all.count
114
118
  end
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
  require 'foreman_tasks/test_helpers'
3
3
 
4
4
  class InsightsRulesSyncTest < ActiveSupport::TestCase
5
- include ForemanTasks::TestHelpers::WithInThreadExecutor
5
+ include Dynflow::Testing::Factories
6
6
 
7
7
  setup do
8
8
  rules_json = <<-'RULES_JSON'
@@ -119,7 +119,8 @@ class InsightsRulesSyncTest < ActiveSupport::TestCase
119
119
  # do not cleanup unused rules for tests
120
120
  InsightsCloud::Async::InsightsRulesSync.any_instance.stubs(:cleanup_rules)
121
121
 
122
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsRulesSync, Organization.all)
122
+ action = create_and_plan_action(InsightsCloud::Async::InsightsRulesSync, Organization.all)
123
+ run_action(action)
123
124
  @hit.reload
124
125
 
125
126
  assert_equal 2, InsightsRule.all.count
@@ -201,7 +202,8 @@ class InsightsRulesSyncTest < ActiveSupport::TestCase
201
202
  # do not cleanup unused rules for tests
202
203
  InsightsCloud::Async::InsightsRulesSync.any_instance.stubs(:cleanup_rules)
203
204
 
204
- ForemanTasks.sync_task(InsightsCloud::Async::InsightsRulesSync, Organization.all)
205
+ action = create_and_plan_action(InsightsCloud::Async::InsightsRulesSync, Organization.all)
206
+ run_action(action)
205
207
 
206
208
  assert_equal 3, InsightsRule.all.count
207
209
  end
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
  require 'foreman_tasks/test_helpers'
3
3
 
4
4
  class InventoryFullSyncTest < ActiveSupport::TestCase
5
- include ForemanTasks::TestHelpers::WithInThreadExecutor
5
+ include Dynflow::Testing::Factories
6
6
  include MockCerts
7
7
  include KatelloCVEHelper
8
8
 
@@ -265,7 +265,8 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
265
265
 
266
266
  InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
267
267
 
268
- ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host2.organization)
268
+ action = create_and_plan_action(InventorySync::Async::InventoryFullSync, @host2.organization)
269
+ run_action(action)
269
270
 
270
271
  @host2.reload
271
272
 
@@ -280,7 +281,8 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
280
281
  InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
281
282
  FactoryBot.create(:fact_value, fact_name: fact_names['virt::uuid'], value: '1234', host: @host2)
282
283
 
283
- ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host1.organization)
284
+ action = create_and_plan_action(InventorySync::Async::InventoryFullSync, @host1.organization)
285
+ run_action(action)
284
286
  @host2.reload
285
287
 
286
288
  assert_equal InventorySync::InventoryStatus::DISCONNECT, InventorySync::InventoryStatus.where(host_id: @host1.id).first.status
@@ -291,7 +293,8 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
291
293
 
292
294
  InventorySync::Async::InventoryFullSync.any_instance.expects(:plan_self).never
293
295
 
294
- ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host1.organization)
296
+ action = create_and_plan_action(InventorySync::Async::InventoryFullSync, @host1.organization)
297
+ run_action(action)
295
298
  end
296
299
 
297
300
  test 'Should skip hosts that are not returned in query' do
@@ -304,7 +307,8 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
304
307
  InventorySync::Async::InventoryFullSync.any_instance.expects(:affected_host_ids).returns([@host1.id, @host2.id])
305
308
  FactoryBot.create(:fact_value, fact_name: fact_names['virt::uuid'], value: '1234', host: @host2)
306
309
 
307
- ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host1.organization)
310
+ action = create_and_plan_action(InventorySync::Async::InventoryFullSync, @host1.organization)
311
+ run_action(action)
308
312
  @host2.reload
309
313
 
310
314
  assert_nil InventorySync::InventoryStatus.where(host_id: @host3.id).first
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
  require 'foreman_tasks/test_helpers'
3
3
 
4
4
  class InventoryHostsSyncTest < ActiveSupport::TestCase
5
- include ForemanTasks::TestHelpers::WithInThreadExecutor
5
+ include Dynflow::Testing::Factories
6
6
  include MockCerts
7
7
  include KatelloCVEHelper
8
8
 
@@ -302,7 +302,8 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
302
302
 
303
303
  @host2.build_insights.save
304
304
 
305
- ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
305
+ action = create_and_plan_action(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
306
+ run_action(action)
306
307
 
307
308
  @host2.reload
308
309
 
@@ -317,7 +318,8 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
317
318
  InventorySync::Async::InventoryHostsSync.any_instance.stubs(:candlepin_id_cert)
318
319
  end
319
320
 
320
- ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
321
+ action = create_and_plan_action(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
322
+ run_action(action)
321
323
 
322
324
  @host2.reload
323
325
 
@@ -336,7 +338,8 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
336
338
 
337
339
  assert_nil @host2.insights
338
340
 
339
- ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
341
+ action = create_and_plan_action(InventorySync::Async::InventoryHostsSync, [@host1.organization, @host2.organization])
342
+ run_action(action)
340
343
 
341
344
  @host2.reload
342
345
 
@@ -353,7 +356,8 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
353
356
  InventorySync::Async::InventoryHostsSync.any_instance.stubs(:candlepin_id_cert)
354
357
  end
355
358
 
356
- ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [org])
359
+ action = create_and_plan_action(InventorySync::Async::InventoryHostsSync, [org])
360
+ run_action(action)
357
361
 
358
362
  assert_equal 3, InsightsMissingHost.count
359
363
  end
@@ -370,7 +374,8 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
370
374
  InventorySync::Async::InventoryHostsSync.any_instance.stubs(:candlepin_id_cert)
371
375
  end
372
376
 
373
- ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [org])
377
+ action = create_and_plan_action(InventorySync::Async::InventoryHostsSync, [org])
378
+ run_action(action)
374
379
 
375
380
  assert_equal 3, InsightsMissingHost.count
376
381
  end