foreman_rh_cloud 13.0.9 → 13.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/inventory_upload/report_actions.rb +8 -1
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +82 -7
- data/app/controllers/foreman_inventory_upload/api/tasks_controller.rb +110 -0
- data/app/controllers/foreman_inventory_upload/reports_controller.rb +41 -17
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +0 -9
- data/config/routes.rb +4 -2
- data/db/migrate/20251209163012_drop_task_output_tables.foreman_rh_cloud.rb +24 -0
- data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +1 -1
- data/lib/foreman_inventory_upload/async/host_inventory_report_job.rb +39 -0
- data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +28 -57
- data/lib/foreman_rh_cloud/plugin.rb +1 -0
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/tasks/rh_cloud_inventory.rake +4 -2
- data/package.json +1 -1
- data/test/controllers/accounts_controller_test.rb +10 -11
- data/test/controllers/insights_cloud/api/cloud_request_controller_test.rb +1 -2
- data/test/jobs/host_inventory_report_job_test.rb +161 -97
- data/test/jobs/single_host_report_job_test.rb +36 -54
- data/test/jobs/upload_report_direct_job_test.rb +132 -132
- data/test/unit/rh_cloud_permissions_test.rb +2 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +6 -6
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +49 -34
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +15 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +6 -5
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.fixtures.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +10 -14
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +9 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +4 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +15 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +7 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +6 -6
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +12 -12
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +36 -132
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +60 -17
- data/webpack/ForemanInventoryUpload/Components/Dashboard/index.js +1 -34
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +0 -1
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.js +1 -26
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +2 -2
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +22 -9
- data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +67 -4
- data/webpack/ForemanInventoryUpload/Components/TaskHistory/TaskHistory.js +140 -0
- data/webpack/ForemanInventoryUpload/Components/TaskHistory/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TaskHistory/taskHistory.scss +40 -0
- data/webpack/ForemanInventoryUpload/Components/TaskProgress/TaskProgress.js +340 -0
- data/webpack/ForemanInventoryUpload/Components/TaskProgress/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TaskProgress/taskProgress.scss +8 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +2 -2
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +0 -2
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +1 -1
- data/webpack/ForemanRhCloudPages.js +0 -1
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationHelpers.js +1 -2
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js +2 -4
- data/webpack/__mocks__/foremanReact/components/common/dates/RelativeDateTime.js +14 -0
- data/webpack/__tests__/ForemanRhCloudHelpers.test.js +5 -1
- metadata +10 -61
- data/app/models/task_output_line.rb +0 -2
- data/app/models/task_output_status.rb +0 -2
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +0 -61
- data/lib/foreman_inventory_upload/async/progress_output.rb +0 -38
- data/lib/foreman_inventory_upload/async/shell_process.rb +0 -77
- data/test/controllers/reports_controller_test.rb +0 -21
- data/test/controllers/uploads_controller_test.rb +0 -21
- data/test/jobs/generate_report_job_test.rb +0 -146
- data/test/unit/shell_process_job_test.rb +0 -29
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +0 -88
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardConstants.js +0 -9
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js +0 -68
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +0 -17
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +0 -51
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +0 -17
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +0 -64
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +0 -46
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/Dashboard.test.js.snap +0 -36
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardActions.test.js.snap +0 -76
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardReducer.test.js.snap +0 -44
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardSelectors.test.js.snap +0 -42
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +0 -55
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModalHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +0 -65
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +0 -20
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +0 -18
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +0 -65
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerateHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/__snapshots__/ReportGenerate.test.js.snap +0 -47
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/reportGenerate.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +0 -18
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +0 -46
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUploadHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/__snapshots__/ReportUpload.test.js.snap +0 -47
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/reportUpload.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.js +0 -31
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBodyHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +0 -19
- data/webpack/ForemanInventoryUpload/Components/TabBody/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +0 -5
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.fixtures.js +0 -10
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +0 -110
- data/webpack/ForemanInventoryUpload/Components/Terminal/TerminalHelper.js +0 -6
- data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +0 -34
- data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +0 -98
- data/webpack/ForemanInventoryUpload/Components/Terminal/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +0 -32
|
@@ -29,8 +29,7 @@ module InsightsCloud::Api
|
|
|
29
29
|
mock_composer = mock('composer')
|
|
30
30
|
::JobInvocationComposer.expects(:for_feature).with do |feature, host_ids, params|
|
|
31
31
|
feature == :rh_cloud_connector_run_playbook &&
|
|
32
|
-
host_ids.
|
|
33
|
-
host_ids.last == host2.id
|
|
32
|
+
host_ids.sort == [host1.id, host2.id].sort
|
|
34
33
|
end.returns(mock_composer)
|
|
35
34
|
mock_composer.expects(:trigger!)
|
|
36
35
|
mock_composer.expects(:job_invocation)
|
|
@@ -15,13 +15,9 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
test 'plan schedules GenerateHostReport action' do
|
|
18
|
-
action =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
organization.id,
|
|
22
|
-
hosts_filter,
|
|
23
|
-
upload
|
|
24
|
-
)
|
|
18
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
19
|
+
action.expects(:action_subject).with(organization)
|
|
20
|
+
plan_action(action, base_folder, organization.id, hosts_filter, upload)
|
|
25
21
|
|
|
26
22
|
assert_action_planned_with(
|
|
27
23
|
action,
|
|
@@ -35,13 +31,9 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
35
31
|
test 'plan schedules QueueForUploadJob when upload is true' do
|
|
36
32
|
expected_archive_name = ForemanInventoryUpload.facts_archive_name(organization.id, hosts_filter)
|
|
37
33
|
|
|
38
|
-
action =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
organization.id,
|
|
42
|
-
hosts_filter,
|
|
43
|
-
true
|
|
44
|
-
)
|
|
34
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
35
|
+
action.expects(:action_subject).with(organization)
|
|
36
|
+
plan_action(action, base_folder, organization.id, hosts_filter, true)
|
|
45
37
|
|
|
46
38
|
assert_action_planned_with(
|
|
47
39
|
action,
|
|
@@ -53,24 +45,17 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
53
45
|
end
|
|
54
46
|
|
|
55
47
|
test 'plan skips QueueForUploadJob when upload is false' do
|
|
56
|
-
action =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
organization.id,
|
|
60
|
-
hosts_filter,
|
|
61
|
-
false
|
|
62
|
-
)
|
|
48
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
49
|
+
action.expects(:action_subject).with(organization)
|
|
50
|
+
plan_action(action, base_folder, organization.id, hosts_filter, false)
|
|
63
51
|
|
|
64
52
|
refute_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
|
|
65
53
|
end
|
|
66
54
|
|
|
67
55
|
test 'plan defaults upload to true when not specified' do
|
|
68
|
-
action =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
organization.id,
|
|
72
|
-
hosts_filter
|
|
73
|
-
)
|
|
56
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
57
|
+
action.expects(:action_subject).with(organization)
|
|
58
|
+
plan_action(action, base_folder, organization.id, hosts_filter)
|
|
74
59
|
|
|
75
60
|
assert_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
|
|
76
61
|
end
|
|
@@ -78,13 +63,9 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
78
63
|
test 'plan schedules CreateMissingInsightsFacets when IoP is enabled' do
|
|
79
64
|
ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(true)
|
|
80
65
|
|
|
81
|
-
action =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
organization.id,
|
|
85
|
-
hosts_filter,
|
|
86
|
-
upload
|
|
87
|
-
)
|
|
66
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
67
|
+
action.expects(:action_subject).with(organization)
|
|
68
|
+
plan_action(action, base_folder, organization.id, hosts_filter, upload)
|
|
88
69
|
|
|
89
70
|
assert_action_planned_with(
|
|
90
71
|
action,
|
|
@@ -96,13 +77,9 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
96
77
|
test 'plan skips CreateMissingInsightsFacets when IoP is disabled' do
|
|
97
78
|
ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(false)
|
|
98
79
|
|
|
99
|
-
action =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
organization.id,
|
|
103
|
-
hosts_filter,
|
|
104
|
-
upload
|
|
105
|
-
)
|
|
80
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
81
|
+
action.expects(:action_subject).with(organization)
|
|
82
|
+
plan_action(action, base_folder, organization.id, hosts_filter, upload)
|
|
106
83
|
|
|
107
84
|
refute_action_planned(action, ForemanInventoryUpload::Async::CreateMissingInsightsFacets)
|
|
108
85
|
end
|
|
@@ -110,13 +87,9 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
110
87
|
test 'plan schedules all three actions with IoP enabled and upload true' do
|
|
111
88
|
ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(true)
|
|
112
89
|
|
|
113
|
-
action =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
organization.id,
|
|
117
|
-
hosts_filter,
|
|
118
|
-
true
|
|
119
|
-
)
|
|
90
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
91
|
+
action.expects(:action_subject).with(organization)
|
|
92
|
+
plan_action(action, base_folder, organization.id, hosts_filter, true)
|
|
120
93
|
|
|
121
94
|
assert_action_planned(action, ForemanInventoryUpload::Async::GenerateHostReport)
|
|
122
95
|
assert_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
|
|
@@ -126,13 +99,9 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
126
99
|
test 'plan schedules only generation and facets with IoP enabled and upload false' do
|
|
127
100
|
ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(true)
|
|
128
101
|
|
|
129
|
-
action =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
organization.id,
|
|
133
|
-
hosts_filter,
|
|
134
|
-
false
|
|
135
|
-
)
|
|
102
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
103
|
+
action.expects(:action_subject).with(organization)
|
|
104
|
+
plan_action(action, base_folder, organization.id, hosts_filter, false)
|
|
136
105
|
|
|
137
106
|
assert_action_planned(action, ForemanInventoryUpload::Async::GenerateHostReport)
|
|
138
107
|
refute_action_planned(action, ForemanInventoryUpload::Async::QueueForUploadJob)
|
|
@@ -140,25 +109,17 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
140
109
|
end
|
|
141
110
|
|
|
142
111
|
test 'humanized_name returns correct string' do
|
|
143
|
-
action =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
organization.id,
|
|
147
|
-
hosts_filter,
|
|
148
|
-
upload
|
|
149
|
-
)
|
|
112
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
113
|
+
action.expects(:action_subject).with(organization)
|
|
114
|
+
plan_action(action, base_folder, organization.id, hosts_filter, upload)
|
|
150
115
|
|
|
151
116
|
assert_equal 'Host inventory report job', action.humanized_name
|
|
152
117
|
end
|
|
153
118
|
|
|
154
119
|
test 'handles empty hosts_filter parameter' do
|
|
155
|
-
action =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
organization.id,
|
|
159
|
-
'',
|
|
160
|
-
upload
|
|
161
|
-
)
|
|
120
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
121
|
+
action.expects(:action_subject).with(organization)
|
|
122
|
+
plan_action(action, base_folder, organization.id, '', upload)
|
|
162
123
|
|
|
163
124
|
assert_action_planned_with(
|
|
164
125
|
action,
|
|
@@ -173,13 +134,9 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
173
134
|
custom_filter = 'name~production'
|
|
174
135
|
expected_archive_name = ForemanInventoryUpload.facts_archive_name(organization.id, custom_filter)
|
|
175
136
|
|
|
176
|
-
action =
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
organization.id,
|
|
180
|
-
custom_filter,
|
|
181
|
-
upload
|
|
182
|
-
)
|
|
137
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
138
|
+
action.expects(:action_subject).with(organization)
|
|
139
|
+
plan_action(action, base_folder, organization.id, custom_filter, upload)
|
|
183
140
|
|
|
184
141
|
assert_action_planned_with(
|
|
185
142
|
action,
|
|
@@ -200,13 +157,9 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
200
157
|
test 'handles invalid hosts_filter parameter' do
|
|
201
158
|
invalid_filter = 'name~~'
|
|
202
159
|
|
|
203
|
-
action =
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
organization.id,
|
|
207
|
-
invalid_filter,
|
|
208
|
-
upload
|
|
209
|
-
)
|
|
160
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
161
|
+
action.expects(:action_subject).with(organization)
|
|
162
|
+
plan_action(action, base_folder, organization.id, invalid_filter, upload)
|
|
210
163
|
|
|
211
164
|
# Job should still plan even with invalid filter syntax
|
|
212
165
|
assert_action_planned(action, ForemanInventoryUpload::Async::GenerateHostReport)
|
|
@@ -215,13 +168,9 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
215
168
|
test 'handles potentially malicious hosts_filter parameter' do
|
|
216
169
|
malicious_filter = "'; DROP TABLE hosts; --"
|
|
217
170
|
|
|
218
|
-
action =
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
organization.id,
|
|
222
|
-
malicious_filter,
|
|
223
|
-
upload
|
|
224
|
-
)
|
|
171
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
172
|
+
action.expects(:action_subject).with(organization)
|
|
173
|
+
plan_action(action, base_folder, organization.id, malicious_filter, upload)
|
|
225
174
|
|
|
226
175
|
# Job should handle malicious input safely (filter is parameterized)
|
|
227
176
|
assert_action_planned(action, ForemanInventoryUpload::Async::GenerateHostReport)
|
|
@@ -230,15 +179,130 @@ class HostInventoryReportJobTest < ActiveSupport::TestCase
|
|
|
230
179
|
test 'handles non-matching hosts_filter parameter' do
|
|
231
180
|
non_matching_filter = 'name~doesnotexist'
|
|
232
181
|
|
|
233
|
-
action =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
organization.id,
|
|
237
|
-
non_matching_filter,
|
|
238
|
-
upload
|
|
239
|
-
)
|
|
182
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
183
|
+
action.expects(:action_subject).with(organization)
|
|
184
|
+
plan_action(action, base_folder, organization.id, non_matching_filter, upload)
|
|
240
185
|
|
|
241
186
|
# Job should plan successfully even if filter matches no hosts
|
|
242
187
|
assert_action_planned(action, ForemanInventoryUpload::Async::GenerateHostReport)
|
|
243
188
|
end
|
|
189
|
+
|
|
190
|
+
test 'organization returns correct Organization from input' do
|
|
191
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
192
|
+
action.expects(:action_subject).with(organization)
|
|
193
|
+
plan_action(action, base_folder, organization.id, hosts_filter, upload)
|
|
194
|
+
|
|
195
|
+
assert_equal organization.id, action.organization.id
|
|
196
|
+
assert_instance_of Organization, action.organization
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
test 'resource_locks returns :link' do
|
|
200
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
201
|
+
|
|
202
|
+
assert_equal :link, action.resource_locks
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
test 'report_file_path returns nil when no file exists' do
|
|
206
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
207
|
+
action.expects(:action_subject).with(organization)
|
|
208
|
+
plan_action(action, base_folder, organization.id, hosts_filter, true)
|
|
209
|
+
|
|
210
|
+
assert_nil action.report_file_path
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
test 'report_file_path finds file in done folder for upload tasks' do
|
|
214
|
+
filename = ForemanInventoryUpload.facts_archive_name(organization.id, hosts_filter)
|
|
215
|
+
done_path = ForemanInventoryUpload.done_file_path(filename)
|
|
216
|
+
|
|
217
|
+
# Create the done file
|
|
218
|
+
FileUtils.mkdir_p(File.dirname(done_path))
|
|
219
|
+
FileUtils.touch(done_path)
|
|
220
|
+
|
|
221
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
222
|
+
action.expects(:action_subject).with(organization)
|
|
223
|
+
plan_action(action, base_folder, organization.id, hosts_filter, true)
|
|
224
|
+
|
|
225
|
+
assert_equal done_path, action.report_file_path
|
|
226
|
+
|
|
227
|
+
# Cleanup
|
|
228
|
+
FileUtils.rm_f(done_path)
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
test 'report_file_path finds file in uploads folder for upload tasks' do
|
|
232
|
+
filename = ForemanInventoryUpload.facts_archive_name(organization.id, hosts_filter)
|
|
233
|
+
uploads_path = ForemanInventoryUpload.uploads_file_path(filename)
|
|
234
|
+
|
|
235
|
+
# Create the uploads file
|
|
236
|
+
FileUtils.mkdir_p(File.dirname(uploads_path))
|
|
237
|
+
FileUtils.touch(uploads_path)
|
|
238
|
+
|
|
239
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
240
|
+
action.expects(:action_subject).with(organization)
|
|
241
|
+
plan_action(action, base_folder, organization.id, hosts_filter, true)
|
|
242
|
+
|
|
243
|
+
assert_equal uploads_path, action.report_file_path
|
|
244
|
+
|
|
245
|
+
# Cleanup
|
|
246
|
+
FileUtils.rm_f(uploads_path)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
test 'report_file_path finds file in generated_reports folder for upload tasks' do
|
|
250
|
+
filename = ForemanInventoryUpload.facts_archive_name(organization.id, hosts_filter)
|
|
251
|
+
generated_path = File.join(base_folder, filename)
|
|
252
|
+
|
|
253
|
+
# Create the generated file
|
|
254
|
+
FileUtils.mkdir_p(base_folder)
|
|
255
|
+
FileUtils.touch(generated_path)
|
|
256
|
+
|
|
257
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
258
|
+
action.expects(:action_subject).with(organization)
|
|
259
|
+
plan_action(action, base_folder, organization.id, hosts_filter, true)
|
|
260
|
+
|
|
261
|
+
assert_equal generated_path, action.report_file_path
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
test 'report_file_path only checks generated_reports folder for non-upload tasks' do
|
|
265
|
+
filename = ForemanInventoryUpload.facts_archive_name(organization.id, hosts_filter)
|
|
266
|
+
generated_path = File.join(base_folder, filename)
|
|
267
|
+
done_path = ForemanInventoryUpload.done_file_path(filename)
|
|
268
|
+
|
|
269
|
+
# Create files in both locations
|
|
270
|
+
FileUtils.mkdir_p(base_folder)
|
|
271
|
+
FileUtils.touch(generated_path)
|
|
272
|
+
FileUtils.mkdir_p(File.dirname(done_path))
|
|
273
|
+
FileUtils.touch(done_path)
|
|
274
|
+
|
|
275
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
276
|
+
action.expects(:action_subject).with(organization)
|
|
277
|
+
plan_action(action, base_folder, organization.id, hosts_filter, false)
|
|
278
|
+
|
|
279
|
+
# Should return the generated_path, not the done_path (since upload=false)
|
|
280
|
+
assert_equal generated_path, action.report_file_path
|
|
281
|
+
|
|
282
|
+
# Cleanup
|
|
283
|
+
FileUtils.rm_f(done_path)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
test 'report_file_path prioritizes done folder over uploads folder' do
|
|
287
|
+
filename = ForemanInventoryUpload.facts_archive_name(organization.id, hosts_filter)
|
|
288
|
+
done_path = ForemanInventoryUpload.done_file_path(filename)
|
|
289
|
+
uploads_path = ForemanInventoryUpload.uploads_file_path(filename)
|
|
290
|
+
|
|
291
|
+
# Create files in both locations
|
|
292
|
+
FileUtils.mkdir_p(File.dirname(done_path))
|
|
293
|
+
FileUtils.touch(done_path)
|
|
294
|
+
FileUtils.mkdir_p(File.dirname(uploads_path))
|
|
295
|
+
FileUtils.touch(uploads_path)
|
|
296
|
+
|
|
297
|
+
action = create_action(ForemanInventoryUpload::Async::HostInventoryReportJob)
|
|
298
|
+
action.expects(:action_subject).with(organization)
|
|
299
|
+
plan_action(action, base_folder, organization.id, hosts_filter, true)
|
|
300
|
+
|
|
301
|
+
# Should prefer done_path (uploaded) over uploads_path (queued)
|
|
302
|
+
assert_equal done_path, action.report_file_path
|
|
303
|
+
|
|
304
|
+
# Cleanup
|
|
305
|
+
FileUtils.rm_f(done_path)
|
|
306
|
+
FileUtils.rm_f(uploads_path)
|
|
307
|
+
end
|
|
244
308
|
end
|
|
@@ -28,12 +28,10 @@ class SingleHostReportJobTest < ActiveSupport::TestCase
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
test 'plan sets host_id in input' do
|
|
31
|
-
action =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@host.id
|
|
36
|
-
)
|
|
31
|
+
action = create_action(ForemanInventoryUpload::Async::SingleHostReportJob)
|
|
32
|
+
organization = Organization.find(@host.organization_id)
|
|
33
|
+
action.expects(:action_subject).with(organization)
|
|
34
|
+
plan_action(action, base_folder, @host.organization_id, @host.id)
|
|
37
35
|
|
|
38
36
|
assert_equal @host.id, action.input[:host_id]
|
|
39
37
|
end
|
|
@@ -41,12 +39,10 @@ class SingleHostReportJobTest < ActiveSupport::TestCase
|
|
|
41
39
|
test 'plan calls super with id filter' do
|
|
42
40
|
expected_filter = "id=#{@host.id}"
|
|
43
41
|
|
|
44
|
-
action =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
@host.id
|
|
49
|
-
)
|
|
42
|
+
action = create_action(ForemanInventoryUpload::Async::SingleHostReportJob)
|
|
43
|
+
organization = Organization.find(@host.organization_id)
|
|
44
|
+
action.expects(:action_subject).with(organization)
|
|
45
|
+
plan_action(action, base_folder, @host.organization_id, @host.id)
|
|
50
46
|
|
|
51
47
|
assert_action_planned_with(
|
|
52
48
|
action,
|
|
@@ -58,12 +54,10 @@ class SingleHostReportJobTest < ActiveSupport::TestCase
|
|
|
58
54
|
end
|
|
59
55
|
|
|
60
56
|
test 'inherits behavior from HostInventoryReportJob' do
|
|
61
|
-
action =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
@host.id
|
|
66
|
-
)
|
|
57
|
+
action = create_action(ForemanInventoryUpload::Async::SingleHostReportJob)
|
|
58
|
+
organization = Organization.find(@host.organization_id)
|
|
59
|
+
action.expects(:action_subject).with(organization)
|
|
60
|
+
plan_action(action, base_folder, @host.organization_id, @host.id)
|
|
67
61
|
|
|
68
62
|
# Should schedule all parent actions
|
|
69
63
|
assert_action_planned(action, ForemanInventoryUpload::Async::GenerateHostReport)
|
|
@@ -71,12 +65,10 @@ class SingleHostReportJobTest < ActiveSupport::TestCase
|
|
|
71
65
|
end
|
|
72
66
|
|
|
73
67
|
test 'humanized_name includes hostname' do
|
|
74
|
-
action =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
@host.id
|
|
79
|
-
)
|
|
68
|
+
action = create_action(ForemanInventoryUpload::Async::SingleHostReportJob)
|
|
69
|
+
organization = Organization.find(@host.organization_id)
|
|
70
|
+
action.expects(:action_subject).with(organization)
|
|
71
|
+
plan_action(action, base_folder, @host.organization_id, @host.id)
|
|
80
72
|
|
|
81
73
|
assert_equal "Single-host report job for host #{@host.name}", action.humanized_name
|
|
82
74
|
end
|
|
@@ -84,34 +76,28 @@ class SingleHostReportJobTest < ActiveSupport::TestCase
|
|
|
84
76
|
test 'humanized_name handles missing host' do
|
|
85
77
|
non_existent_host_id = 999_999
|
|
86
78
|
|
|
87
|
-
action =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
non_existent_host_id
|
|
92
|
-
)
|
|
79
|
+
action = create_action(ForemanInventoryUpload::Async::SingleHostReportJob)
|
|
80
|
+
organization = Organization.find(@host.organization_id)
|
|
81
|
+
action.expects(:action_subject).with(organization)
|
|
82
|
+
plan_action(action, base_folder, @host.organization_id, non_existent_host_id)
|
|
93
83
|
|
|
94
84
|
assert_equal 'Single-host report job', action.humanized_name
|
|
95
85
|
end
|
|
96
86
|
|
|
97
87
|
test 'hostname method returns correct name' do
|
|
98
|
-
action =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
@host.id
|
|
103
|
-
)
|
|
88
|
+
action = create_action(ForemanInventoryUpload::Async::SingleHostReportJob)
|
|
89
|
+
organization = Organization.find(@host.organization_id)
|
|
90
|
+
action.expects(:action_subject).with(organization)
|
|
91
|
+
plan_action(action, base_folder, @host.organization_id, @host.id)
|
|
104
92
|
|
|
105
93
|
assert_equal @host.name, action.hostname(@host.id)
|
|
106
94
|
end
|
|
107
95
|
|
|
108
96
|
test 'hostname method handles nil gracefully' do
|
|
109
|
-
action =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
@host.id
|
|
114
|
-
)
|
|
97
|
+
action = create_action(ForemanInventoryUpload::Async::SingleHostReportJob)
|
|
98
|
+
organization = Organization.find(@host.organization_id)
|
|
99
|
+
action.expects(:action_subject).with(organization)
|
|
100
|
+
plan_action(action, base_folder, @host.organization_id, @host.id)
|
|
115
101
|
|
|
116
102
|
assert_nil action.hostname(999_999)
|
|
117
103
|
end
|
|
@@ -120,12 +106,10 @@ class SingleHostReportJobTest < ActiveSupport::TestCase
|
|
|
120
106
|
expected_filter = "id=#{@host.id}"
|
|
121
107
|
expected_archive_name = ForemanInventoryUpload.facts_archive_name(@host.organization_id, expected_filter)
|
|
122
108
|
|
|
123
|
-
action =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
@host.id
|
|
128
|
-
)
|
|
109
|
+
action = create_action(ForemanInventoryUpload::Async::SingleHostReportJob)
|
|
110
|
+
organization = Organization.find(@host.organization_id)
|
|
111
|
+
action.expects(:action_subject).with(organization)
|
|
112
|
+
plan_action(action, base_folder, @host.organization_id, @host.id)
|
|
129
113
|
|
|
130
114
|
assert_action_planned_with(
|
|
131
115
|
action,
|
|
@@ -139,12 +123,10 @@ class SingleHostReportJobTest < ActiveSupport::TestCase
|
|
|
139
123
|
test 'respects IoP mode for facet creation' do
|
|
140
124
|
ForemanRhCloud.stubs(:with_iop_smart_proxy?).returns(true)
|
|
141
125
|
|
|
142
|
-
action =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
@host.id
|
|
147
|
-
)
|
|
126
|
+
action = create_action(ForemanInventoryUpload::Async::SingleHostReportJob)
|
|
127
|
+
organization = Organization.find(@host.organization_id)
|
|
128
|
+
action.expects(:action_subject).with(organization)
|
|
129
|
+
plan_action(action, base_folder, @host.organization_id, @host.id)
|
|
148
130
|
|
|
149
131
|
assert_action_planned_with(
|
|
150
132
|
action,
|