foreman_remote_execution 12.0.7 → 13.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/js_ci.yml +1 -1
- data/.github/workflows/ruby_ci.yml +16 -81
- data/.packit.yaml +8 -3
- data/app/assets/javascripts/foreman_remote_execution/locale/de/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/en/foreman_remote_execution.js +22 -4
- data/app/assets/javascripts/foreman_remote_execution/locale/en_GB/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/es/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/fr/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/ja/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/ka/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/ko/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/pt_BR/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/ru/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/zh_CN/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/zh_TW/foreman_remote_execution.js +23 -14
- data/app/controllers/ui_job_wizard_controller.rb +1 -1
- data/app/helpers/job_invocations_helper.rb +1 -1
- data/app/helpers/remote_execution_helper.rb +2 -2
- data/app/lib/actions/remote_execution/proxy_action.rb +1 -1
- data/app/lib/actions/remote_execution/run_host_job.rb +9 -3
- data/app/lib/actions/remote_execution/run_hosts_job.rb +0 -1
- data/app/models/host_status/execution_status.rb +2 -2
- data/app/views/job_invocations/_preview_hosts_list.html.erb +1 -1
- data/app/views/job_invocations/show.html.erb +12 -5
- data/app/views/job_invocations/show.js.erb +8 -1
- data/app/views/job_invocations/welcome.html.erb +1 -1
- data/app/views/template_invocations/_refresh.js.erb +10 -4
- data/app/views/template_invocations/show.html.erb +2 -2
- data/app/views/templates/script/convert2rhel_analyze.erb +12 -1
- data/lib/foreman_remote_execution/engine.rb +1 -1
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/locale/de/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/de/foreman_remote_execution.po +24 -6
- data/locale/en/foreman_remote_execution.po +24 -6
- data/locale/en_GB/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/en_GB/foreman_remote_execution.po +24 -6
- data/locale/es/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/es/foreman_remote_execution.po +24 -6
- data/locale/foreman_remote_execution.pot +170 -142
- data/locale/fr/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/fr/foreman_remote_execution.po +24 -6
- data/locale/ja/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ja/foreman_remote_execution.po +24 -6
- data/locale/ka/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ka/foreman_remote_execution.po +24 -6
- data/locale/ko/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ko/foreman_remote_execution.po +24 -6
- data/locale/pt_BR/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/pt_BR/foreman_remote_execution.po +24 -6
- data/locale/ru/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ru/foreman_remote_execution.po +24 -6
- data/locale/zh_CN/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/zh_CN/foreman_remote_execution.po +24 -6
- data/locale/zh_TW/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/zh_TW/foreman_remote_execution.po +24 -6
- data/package.json +1 -5
- data/test/functional/api/v2/job_invocations_controller_test.rb +7 -7
- data/test/functional/api/v2/template_invocations_controller_test.rb +3 -3
- data/test/helpers/remote_execution_helper_test.rb +8 -7
- data/test/unit/actions/run_host_job_test.rb +1 -1
- data/test/unit/actions/run_hosts_job_test.rb +11 -11
- data/test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb +5 -5
- data/test/unit/concerns/host_extensions_test.rb +34 -34
- data/test/unit/concerns/nic_extensions_test.rb +1 -1
- data/test/unit/execution_task_status_mapper_test.rb +10 -10
- data/test/unit/input_template_renderer_test.rb +53 -49
- data/test/unit/job_invocation_composer_test.rb +78 -78
- data/test/unit/job_invocation_test.rb +25 -25
- data/test/unit/job_template_effective_user_test.rb +3 -3
- data/test/unit/job_template_test.rb +28 -28
- data/test/unit/remote_execution_feature_test.rb +14 -14
- data/test/unit/remote_execution_provider_test.rb +39 -39
- data/test/unit/renderer_scope_input_test.rb +6 -6
- data/test/unit/targeting_test.rb +32 -32
- data/webpack/JobWizard/JobWizardConstants.js +4 -0
- data/webpack/JobWizard/JobWizardSelectors.js +31 -3
- data/webpack/JobWizard/PermissionDenied.js +64 -0
- data/webpack/JobWizard/__tests__/fixtures.js +3 -3
- data/webpack/JobWizard/autofill.js +8 -4
- data/webpack/JobWizard/index.js +40 -1
- data/webpack/JobWizard/steps/CategoryAndTemplate/CategoryAndTemplate.js +26 -5
- data/webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js +3 -3
- data/webpack/JobWizard/steps/HostsAndInputs/SelectGQL.js +1 -0
- data/webpack/JobWizard/steps/HostsAndInputs/SelectedChips.js +13 -6
- data/webpack/JobWizard/steps/HostsAndInputs/hosts.gql +1 -0
- data/webpack/JobWizard/steps/HostsAndInputs/index.js +21 -1
- data/webpack/JobWizard/steps/ReviewDetails/index.js +3 -2
- data/webpack/JobWizard/steps/form/SearchSelect.js +3 -1
- data/webpack/JobWizard/steps/form/__tests__/SelectSearch.test.js +2 -0
- metadata +7 -6
@@ -75,13 +75,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
75
75
|
describe '#available_templates_for(job_category)' do
|
76
76
|
it 'find the templates only for a given job name' do
|
77
77
|
results = composer.available_templates_for(trying_job_template_1.job_category)
|
78
|
-
|
79
|
-
|
78
|
+
assert_includes results, trying_job_template_1
|
79
|
+
refute_includes results, trying_job_template_2
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'it respects view permissions' do
|
83
83
|
results = composer.available_templates_for(trying_job_template_1.job_category)
|
84
|
-
|
84
|
+
refute_includes results, unauthorized_job_template_1
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -89,13 +89,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
89
89
|
let(:job_categories) { composer.available_job_categories }
|
90
90
|
|
91
91
|
it 'find only job names that user is granted to view' do
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
assert_includes job_categories, trying_job_template_1.job_category
|
93
|
+
assert_includes job_categories, trying_job_template_2.job_category
|
94
|
+
refute_includes job_categories, unauthorized_job_template_2.job_category
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'every job name is listed just once' do
|
98
|
-
|
98
|
+
assert_equal job_categories.uniq, job_categories
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -104,13 +104,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
104
104
|
|
105
105
|
it 'finds only providers which user is granted to view' do
|
106
106
|
composer.job_invocation.job_category = 'trying_job_template_1'
|
107
|
-
|
108
|
-
|
109
|
-
|
107
|
+
assert_includes provider_types, 'SSH'
|
108
|
+
refute_includes provider_types, 'Mcollective'
|
109
|
+
refute_includes provider_types, 'Ansible'
|
110
110
|
end
|
111
111
|
|
112
112
|
it 'every provider type is listed just once' do
|
113
|
-
|
113
|
+
assert_equal provider_types.uniq, provider_types
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
@@ -122,9 +122,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'returns only authorized inputs based on templates' do
|
125
|
-
|
126
|
-
|
127
|
-
|
125
|
+
assert_includes composer.available_template_inputs, input1
|
126
|
+
assert_includes composer.available_template_inputs, input2
|
127
|
+
refute_includes composer.available_template_inputs, unauthorized_input1
|
128
128
|
end
|
129
129
|
|
130
130
|
context 'params contains job template ids' do
|
@@ -134,9 +134,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
134
134
|
let(:params) { { :job_invocation => providers_params }.with_indifferent_access }
|
135
135
|
|
136
136
|
it 'finds the inputs only specified job templates' do
|
137
|
-
|
138
|
-
|
139
|
-
|
137
|
+
assert_includes composer.available_template_inputs, input1
|
138
|
+
refute_includes composer.available_template_inputs, input2
|
139
|
+
refute_includes composer.available_template_inputs, unauthorized_input1
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
@@ -149,7 +149,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
149
149
|
|
150
150
|
it 'returns false if there is one provider' do
|
151
151
|
composer.stubs(:available_provider_types => [ 'SSH' ])
|
152
|
-
|
152
|
+
refute composer.needs_provider_type_selection?
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
@@ -161,40 +161,40 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
161
161
|
it 'returns all templates for a given provider respecting template permissions' do
|
162
162
|
trying_job_template_4 = FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying4', :provider_type => 'Ansible')
|
163
163
|
result = composer.templates_for_provider('SSH')
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
164
|
+
assert_includes result, trying_job_template_1
|
165
|
+
assert_includes result, trying_job_template_3
|
166
|
+
refute_includes result, unauthorized_job_template_1
|
167
|
+
refute_includes result, trying_job_template_4
|
168
168
|
|
169
169
|
result = composer.templates_for_provider('Ansible')
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
170
|
+
refute_includes result, trying_job_template_1
|
171
|
+
refute_includes result, trying_job_template_3
|
172
|
+
refute_includes result, unauthorized_job_template_2
|
173
|
+
assert_includes result, trying_job_template_4
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
177
|
describe '#rerun_possible?' do
|
178
178
|
it 'is true when not rerunning' do
|
179
|
-
|
179
|
+
assert_predicate composer, :rerun_possible?
|
180
180
|
end
|
181
181
|
|
182
182
|
it 'is true when rerunning with pattern tempalte invocations' do
|
183
183
|
composer.expects(:reruns).returns(1)
|
184
184
|
composer.job_invocation.expects(:pattern_template_invocations).returns([1])
|
185
|
-
|
185
|
+
assert_predicate composer, :rerun_possible?
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'is false when rerunning without pattern template invocations' do
|
189
189
|
composer.expects(:reruns).returns(1)
|
190
190
|
composer.job_invocation.expects(:pattern_template_invocations).returns([])
|
191
|
-
|
191
|
+
refute_predicate composer, :rerun_possible?
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
195
|
describe '#selected_job_templates' do
|
196
196
|
it 'returns no template if none was selected through params' do
|
197
|
-
|
197
|
+
assert_empty composer.selected_job_templates
|
198
198
|
end
|
199
199
|
|
200
200
|
context 'extra unavailable templates id were selected' do
|
@@ -207,14 +207,14 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
207
207
|
|
208
208
|
it 'ignores unauthorized template' do
|
209
209
|
unauthorized # make sure unautorized exists
|
210
|
-
|
210
|
+
refute_includes composer.selected_job_templates, unauthorized
|
211
211
|
end
|
212
212
|
|
213
213
|
it 'contains only authorized template specified in params' do
|
214
214
|
mcollective_authorized # make sure mcollective_authorized exists
|
215
|
-
|
216
|
-
|
217
|
-
|
215
|
+
assert_includes composer.selected_job_templates, trying_job_template_1
|
216
|
+
assert_includes composer.selected_job_templates, mcollective_authorized
|
217
|
+
refute_includes composer.selected_job_templates, trying_job_template_3
|
218
218
|
end
|
219
219
|
end
|
220
220
|
end
|
@@ -222,7 +222,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
222
222
|
describe '#preselected_template_for_provider(provider_type)' do
|
223
223
|
context 'none template was selected through params' do
|
224
224
|
it 'returns nil' do
|
225
|
-
|
225
|
+
assert_nil composer.preselected_template_for_provider('SSH')
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
@@ -231,7 +231,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
231
231
|
let(:params) { { :job_invocation => providers_params }.with_indifferent_access }
|
232
232
|
|
233
233
|
it 'returns the selected template because it is available for provider' do
|
234
|
-
|
234
|
+
assert_equal trying_job_template_1, composer.preselected_template_for_provider('SSH')
|
235
235
|
end
|
236
236
|
end
|
237
237
|
end
|
@@ -249,9 +249,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
249
249
|
let(:invocations) { composer.pattern_template_invocations }
|
250
250
|
|
251
251
|
it 'builds pattern template invocations based on passed params and it filters out wrong inputs' do
|
252
|
-
|
253
|
-
|
254
|
-
|
252
|
+
assert_equal 1, invocations.size
|
253
|
+
assert_equal 1, invocations.first.input_values.size
|
254
|
+
assert_equal 'value1', invocations.first.input_values.first.value
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
@@ -275,7 +275,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
275
275
|
let(:invocation_effective_user) { 'invocation user' }
|
276
276
|
|
277
277
|
it 'takes the value from the template invocation' do
|
278
|
-
|
278
|
+
assert_equal 'invocation user', template_invocation.effective_user
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
@@ -284,7 +284,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
284
284
|
let(:invocation_effective_user) { '' }
|
285
285
|
|
286
286
|
it 'takes the value from the job template' do
|
287
|
-
|
287
|
+
assert_equal 'template user', template_invocation.effective_user
|
288
288
|
end
|
289
289
|
end
|
290
290
|
|
@@ -293,14 +293,14 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
293
293
|
let(:invocation_effective_user) { 'invocation user' }
|
294
294
|
|
295
295
|
it 'takes the value from the job template' do
|
296
|
-
|
296
|
+
assert_equal 'template user', template_invocation.effective_user
|
297
297
|
end
|
298
298
|
end
|
299
299
|
end
|
300
300
|
|
301
301
|
describe '#displayed_search_query' do
|
302
302
|
it 'is empty by default' do
|
303
|
-
|
303
|
+
assert_empty composer.displayed_search_query
|
304
304
|
end
|
305
305
|
|
306
306
|
let(:host) { FactoryBot.create(:host) }
|
@@ -310,7 +310,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
310
310
|
let(:params) { { :targeting => { :search_query => 'a', :bookmark_id => bookmark.id }, :host_ids => [ host.id ] }.with_indifferent_access }
|
311
311
|
|
312
312
|
it 'explicit search query has highest priority' do
|
313
|
-
|
313
|
+
assert_equal 'a', composer.displayed_search_query
|
314
314
|
end
|
315
315
|
end
|
316
316
|
|
@@ -318,7 +318,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
318
318
|
let(:params) { { :targeting => { :bookmark_id => bookmark.id }, :host_ids => [ host.id ] }.with_indifferent_access }
|
319
319
|
|
320
320
|
it 'hosts will be used instead of a bookmark' do
|
321
|
-
|
321
|
+
assert_includes composer.displayed_search_query, host.name
|
322
322
|
end
|
323
323
|
end
|
324
324
|
|
@@ -327,20 +327,20 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
327
327
|
|
328
328
|
it 'bookmark query is used if it is available for the user' do
|
329
329
|
bookmark.update_attribute :public, false
|
330
|
-
|
330
|
+
assert_equal bookmark.query, composer.displayed_search_query
|
331
331
|
end
|
332
332
|
|
333
333
|
it 'bookmark query is used if the bookmark is public' do
|
334
334
|
bookmark.owner = nil
|
335
335
|
bookmark.save(:validate => false) # skip validations so owner remains nil
|
336
|
-
|
336
|
+
assert_equal bookmark.query, composer.displayed_search_query
|
337
337
|
end
|
338
338
|
|
339
339
|
it 'empty search is returned if bookmark is not owned by the user and is not public' do
|
340
340
|
bookmark.public = false
|
341
341
|
bookmark.owner = nil
|
342
342
|
bookmark.save(:validate => false) # skip validations so owner remains nil
|
343
|
-
|
343
|
+
assert_empty composer.displayed_search_query
|
344
344
|
end
|
345
345
|
end
|
346
346
|
end
|
@@ -355,9 +355,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
355
355
|
hosts
|
356
356
|
dashboard
|
357
357
|
hostgroups
|
358
|
-
|
359
|
-
|
360
|
-
|
358
|
+
assert_includes composer.available_bookmarks, hosts
|
359
|
+
assert_includes composer.available_bookmarks, dashboard
|
360
|
+
refute_includes composer.available_bookmarks, hostgroups
|
361
361
|
end
|
362
362
|
end
|
363
363
|
end
|
@@ -375,17 +375,17 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
375
375
|
|
376
376
|
it 'searches hosts based on displayed_search_query' do
|
377
377
|
composer.stubs(:displayed_search_query => "name = #{host.name}")
|
378
|
-
|
378
|
+
assert_equal 1, composer.targeted_hosts_count
|
379
379
|
end
|
380
380
|
|
381
381
|
it 'returns 0 for queries with syntax errors' do
|
382
382
|
composer.stubs(:displayed_search_query => 'name = ')
|
383
|
-
|
383
|
+
assert_equal 0, composer.targeted_hosts_count
|
384
384
|
end
|
385
385
|
|
386
386
|
it 'returns 0 when no query is present' do
|
387
387
|
composer.stubs(:displayed_search_query => '')
|
388
|
-
|
388
|
+
assert_equal 0, composer.targeted_hosts_count
|
389
389
|
end
|
390
390
|
end
|
391
391
|
|
@@ -393,7 +393,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
393
393
|
let(:value1) { composer.input_value_for(input1) }
|
394
394
|
it 'returns new empty input value if there is no invocation' do
|
395
395
|
assert value1.new_record?
|
396
|
-
|
396
|
+
assert_empty value1.value
|
397
397
|
end
|
398
398
|
|
399
399
|
context 'there are invocations without input values for a given input' do
|
@@ -409,7 +409,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
409
409
|
|
410
410
|
it 'returns new empty input value' do
|
411
411
|
assert value1.new_record?
|
412
|
-
|
412
|
+
assert_empty value1.value
|
413
413
|
end
|
414
414
|
end
|
415
415
|
|
@@ -425,7 +425,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
425
425
|
let(:params) { { :job_invocation => { :providers => { :ssh => ssh_params } } }.with_indifferent_access }
|
426
426
|
|
427
427
|
it 'finds the value among template invocations' do
|
428
|
-
|
428
|
+
assert_equal 'value1', value1.value
|
429
429
|
end
|
430
430
|
end
|
431
431
|
end
|
@@ -462,12 +462,12 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
462
462
|
end
|
463
463
|
|
464
464
|
it 'accepts the concurrency options' do
|
465
|
-
|
465
|
+
assert_equal 5, composer.job_invocation.concurrency_level
|
466
466
|
end
|
467
467
|
end
|
468
468
|
|
469
469
|
it 'can be disabled' do
|
470
|
-
|
470
|
+
assert_nil composer.job_invocation.concurrency_level
|
471
471
|
end
|
472
472
|
end
|
473
473
|
|
@@ -477,11 +477,11 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
477
477
|
end
|
478
478
|
|
479
479
|
it 'accepts the triggering params' do
|
480
|
-
|
480
|
+
assert_equal :future, composer.job_invocation.triggering.mode
|
481
481
|
end
|
482
482
|
|
483
483
|
it 'formats the triggering end time when its unordered' do
|
484
|
-
|
484
|
+
assert_equal Time.local(3,2,1,4,5), composer.job_invocation.triggering.end_time
|
485
485
|
end
|
486
486
|
end
|
487
487
|
|
@@ -515,7 +515,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
515
515
|
|
516
516
|
it 'sets the password properly' do
|
517
517
|
composer
|
518
|
-
|
518
|
+
assert_equal password, composer.job_invocation.password
|
519
519
|
end
|
520
520
|
end
|
521
521
|
|
@@ -527,7 +527,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
527
527
|
|
528
528
|
it 'sets the key passphrase properly' do
|
529
529
|
composer
|
530
|
-
|
530
|
+
assert_equal key_passphrase, composer.job_invocation.key_passphrase
|
531
531
|
end
|
532
532
|
end
|
533
533
|
|
@@ -539,7 +539,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
539
539
|
|
540
540
|
it 'sets the effective_user_password password properly' do
|
541
541
|
composer
|
542
|
-
|
542
|
+
assert_equal effective_user_password, composer.job_invocation.effective_user_password
|
543
543
|
end
|
544
544
|
end
|
545
545
|
|
@@ -581,29 +581,29 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
581
581
|
end
|
582
582
|
|
583
583
|
it 'sets the same job name' do
|
584
|
-
|
584
|
+
assert_equal existing.job_category, new_composer.job_category
|
585
585
|
end
|
586
586
|
|
587
587
|
it 'accepts additional host ids' do
|
588
588
|
new_composer = JobInvocationComposer.from_job_invocation(composer.job_invocation, { :host_ids => [host.id] })
|
589
|
-
|
589
|
+
assert_equal "name ^ (#{host.name})", new_composer.search_query
|
590
590
|
end
|
591
591
|
|
592
592
|
it 'builds new targeting object which keeps search query' do
|
593
|
-
|
594
|
-
|
593
|
+
refute_equal existing.targeting, new_composer.targeting
|
594
|
+
assert_equal existing.targeting.search_query, new_composer.search_query
|
595
595
|
end
|
596
596
|
|
597
597
|
it 'keeps job template ids' do
|
598
|
-
|
598
|
+
assert_equal existing.pattern_template_invocations.map(&:template_id), new_composer.job_template_ids
|
599
599
|
end
|
600
600
|
|
601
601
|
it 'keeps template invocations and their values' do
|
602
|
-
|
602
|
+
assert_equal existing.pattern_template_invocations.size, new_composer.pattern_template_invocations.size
|
603
603
|
end
|
604
604
|
|
605
605
|
it 'sets the same concurrency control options' do
|
606
|
-
|
606
|
+
assert_equal existing.concurrency_level, new_composer.job_invocation.concurrency_level
|
607
607
|
end
|
608
608
|
|
609
609
|
end
|
@@ -701,7 +701,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
701
701
|
|
702
702
|
it 'sets the effective user based on the input' do
|
703
703
|
assert composer.save!
|
704
|
-
|
704
|
+
assert_equal 'invocation user', template_invocation.effective_user
|
705
705
|
end
|
706
706
|
end
|
707
707
|
|
@@ -720,7 +720,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
720
720
|
|
721
721
|
it 'sets the concurrency level based on the input' do
|
722
722
|
assert composer.save!
|
723
|
-
|
723
|
+
assert_equal level, composer.job_invocation.concurrency_level
|
724
724
|
end
|
725
725
|
end
|
726
726
|
|
@@ -737,7 +737,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
737
737
|
|
738
738
|
it 'sets the remote execution feature based on the input' do
|
739
739
|
assert composer.save!
|
740
|
-
|
740
|
+
assert_equal feature, composer.job_invocation.remote_execution_feature
|
741
741
|
end
|
742
742
|
|
743
743
|
it 'sets the remote execution_feature id based on `feature` param' do
|
@@ -747,7 +747,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
747
747
|
refute_equal feature.job_template, trying_job_template_1
|
748
748
|
|
749
749
|
assert composer.save!
|
750
|
-
|
750
|
+
assert_equal feature, composer.job_invocation.remote_execution_feature
|
751
751
|
end
|
752
752
|
end
|
753
753
|
|
@@ -797,7 +797,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
797
797
|
error = assert_raises(ActiveRecord::RecordNotSaved) do
|
798
798
|
composer.save!
|
799
799
|
end
|
800
|
-
|
800
|
+
assert_includes error.message, "Template #{trying_job_template_1.name}: Input #{input3.name.downcase}: Value can't be blank"
|
801
801
|
end
|
802
802
|
end
|
803
803
|
|
@@ -826,13 +826,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
826
826
|
end
|
827
827
|
|
828
828
|
it 'handles errors' do
|
829
|
-
|
829
|
+
assert_predicate input3, :required
|
830
830
|
|
831
831
|
error = assert_raises(ActiveRecord::RecordNotSaved) do
|
832
832
|
composer.save!
|
833
833
|
end
|
834
834
|
|
835
|
-
|
835
|
+
assert_includes error.message, "Template #{trying_job_template_1.name}: Not all required inputs have values. Missing inputs: #{input3.name}"
|
836
836
|
end
|
837
837
|
end
|
838
838
|
end
|
@@ -11,12 +11,12 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
11
11
|
|
12
12
|
it 'is able to perform search through job invocations' do
|
13
13
|
found_jobs = JobInvocation.search_for(%{job_category = "#{job_invocation.job_category}"}).paginate(:page => 1).order('job_invocations.id DESC')
|
14
|
-
|
14
|
+
assert_equal [job_invocation], found_jobs
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'is able to auto complete description' do
|
18
18
|
expected = 'description = "A text with \"quotes\""'
|
19
|
-
JobInvocation.complete_for('description = ')
|
19
|
+
assert_equal [expected], JobInvocation.complete_for('description = ')
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -40,7 +40,7 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
40
40
|
job_invocation.save!
|
41
41
|
host.destroy
|
42
42
|
job_invocation.reload
|
43
|
-
|
43
|
+
assert_empty job_invocation.template_invocations
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -85,13 +85,13 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
85
85
|
it 'generates description from input values' do
|
86
86
|
job_invocation.description_format = '%{job_category} - %{foo}'
|
87
87
|
job_invocation.generate_description
|
88
|
-
|
88
|
+
assert_equal "#{job_invocation.job_category} - #{@input_value.value}", job_invocation.description
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'handles missing keys correctly' do
|
92
92
|
job_invocation.description_format = '%{job_category} - %{missing_key}'
|
93
93
|
job_invocation.generate_description
|
94
|
-
|
94
|
+
assert_equal "#{job_invocation.job_category} - ''", job_invocation.description
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'truncates generated description to 255 characters' do
|
@@ -100,22 +100,22 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
100
100
|
job_invocation.description_format = '%{job_category}'
|
101
101
|
job_invocation.job_category = 'a' * 1000
|
102
102
|
job_invocation.generate_description
|
103
|
-
|
103
|
+
assert_equal expected_result, job_invocation.description
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
108
|
context 'future execution' do
|
109
109
|
it 'can report host count' do
|
110
|
-
|
110
|
+
assert_equal 'N/A', job_invocation.total_hosts_count
|
111
111
|
job_invocation.targeting.expects(:resolved_at).returns(Time.now.getlocal)
|
112
|
-
|
112
|
+
assert_equal 0, job_invocation.total_hosts_count
|
113
113
|
end
|
114
114
|
|
115
115
|
# task does not exist
|
116
|
-
specify {
|
117
|
-
specify {
|
118
|
-
specify {
|
116
|
+
specify { assert_equal HostStatus::ExecutionStatus::QUEUED, job_invocation.status }
|
117
|
+
specify { assert_equal HostStatus::ExecutionStatus::STATUS_NAMES[HostStatus::ExecutionStatus::QUEUED], job_invocation.status_label }
|
118
|
+
specify { assert_equal 0, job_invocation.progress }
|
119
119
|
end
|
120
120
|
|
121
121
|
context 'with task' do
|
@@ -138,10 +138,10 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
138
138
|
context 'which is scheduled' do
|
139
139
|
before { task.state = 'scheduled' }
|
140
140
|
|
141
|
-
specify {
|
142
|
-
specify {
|
143
|
-
specify {
|
144
|
-
specify {
|
141
|
+
specify { assert_equal HostStatus::ExecutionStatus::QUEUED, job_invocation.status }
|
142
|
+
specify { assert job_invocation.queued? }
|
143
|
+
specify { assert_equal 0, job_invocation.progress }
|
144
|
+
specify { assert_equal progress_report_without_sub_tasks, job_invocation.progress_report }
|
145
145
|
end
|
146
146
|
|
147
147
|
context 'with cancelled task' do
|
@@ -153,7 +153,7 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
153
153
|
it 'calculates the progress correctly' do
|
154
154
|
job_invocation.targeting.stubs(:resolved?).returns(true)
|
155
155
|
task.expects(:sub_tasks_counts).never
|
156
|
-
|
156
|
+
assert_equal progress_report_without_sub_tasks, job_invocation.progress_report
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
@@ -163,8 +163,8 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
163
163
|
task.result = 'success'
|
164
164
|
end
|
165
165
|
|
166
|
-
specify {
|
167
|
-
specify {
|
166
|
+
specify { assert_equal HostStatus::ExecutionStatus::OK, job_invocation.status }
|
167
|
+
specify { refute job_invocation.queued? }
|
168
168
|
|
169
169
|
it 'calculates the progress correctly' do
|
170
170
|
sub_tasks = [ForemanTasks::Task.new]
|
@@ -173,7 +173,7 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
173
173
|
sub_tasks.expects(:where).with(:result => %w(success warning error)).returns(sub_tasks)
|
174
174
|
job_invocation.stubs(:sub_tasks).returns(sub_tasks)
|
175
175
|
|
176
|
-
|
176
|
+
assert_equal 100, job_invocation.progress
|
177
177
|
end
|
178
178
|
end
|
179
179
|
end
|
@@ -203,29 +203,29 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
203
203
|
|
204
204
|
it 'returns only failed hosts when not #finished?' do
|
205
205
|
invocation.stubs(:finished?).returns(false)
|
206
|
-
|
206
|
+
assert_equal 1, invocation.failed_hosts.count
|
207
207
|
end
|
208
208
|
|
209
209
|
it 'returns failed hosts and hosts without task when #finished?' do
|
210
210
|
invocation.stubs(:finished?).returns(true)
|
211
|
-
|
211
|
+
assert_equal 2, invocation.failed_hosts.count
|
212
212
|
end
|
213
213
|
|
214
214
|
describe '#failed_template_invocations' do
|
215
215
|
it 'finds only failed template invocations' do
|
216
216
|
template_invocations = invocation.send(:failed_template_invocations)
|
217
|
-
|
217
|
+
assert_equal 1, template_invocations.count
|
218
218
|
template_invocation = template_invocations.first
|
219
|
-
|
219
|
+
assert_equal 'error', template_invocation.run_host_job_task.result
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
223
|
describe '#not_failed_template_invocations' do
|
224
224
|
it 'finds only non-failed template invocations' do
|
225
225
|
template_invocations = invocation.send(:not_failed_template_invocations)
|
226
|
-
|
226
|
+
assert_equal 1, template_invocations.count
|
227
227
|
template_invocation = template_invocations.first
|
228
|
-
|
228
|
+
assert_equal 'success', template_invocation.run_host_job_task.result
|
229
229
|
end
|
230
230
|
end
|
231
231
|
end
|
@@ -19,19 +19,19 @@ class JobTemplateEffectiveUserTest < ActiveSupport::TestCase
|
|
19
19
|
user = FactoryBot.create(:user)
|
20
20
|
User.current = user
|
21
21
|
effective_user.current_user = true
|
22
|
-
|
22
|
+
assert_equal user.login, effective_user.compute_value
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'returns the value when not current user is set to true' do
|
26
26
|
effective_user.current_user = false
|
27
27
|
effective_user.value = 'testuser'
|
28
|
-
|
28
|
+
assert_equal 'testuser', effective_user.compute_value
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'returns a default value when no value is specified for the user' do
|
32
32
|
effective_user.value = ''
|
33
33
|
Setting[:remote_execution_effective_user] = 'myuser'
|
34
|
-
|
34
|
+
assert_equal 'myuser', effective_user.compute_value
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|