foreman_remote_execution 12.0.5 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/js_ci.yml +1 -1
  3. data/.github/workflows/ruby_ci.yml +16 -81
  4. data/.packit.yaml +8 -3
  5. data/app/assets/javascripts/foreman_remote_execution/locale/de/foreman_remote_execution.js +23 -14
  6. data/app/assets/javascripts/foreman_remote_execution/locale/en/foreman_remote_execution.js +22 -4
  7. data/app/assets/javascripts/foreman_remote_execution/locale/en_GB/foreman_remote_execution.js +23 -14
  8. data/app/assets/javascripts/foreman_remote_execution/locale/es/foreman_remote_execution.js +23 -14
  9. data/app/assets/javascripts/foreman_remote_execution/locale/fr/foreman_remote_execution.js +23 -14
  10. data/app/assets/javascripts/foreman_remote_execution/locale/ja/foreman_remote_execution.js +23 -14
  11. data/app/assets/javascripts/foreman_remote_execution/locale/ka/foreman_remote_execution.js +23 -14
  12. data/app/assets/javascripts/foreman_remote_execution/locale/ko/foreman_remote_execution.js +23 -14
  13. data/app/assets/javascripts/foreman_remote_execution/locale/pt_BR/foreman_remote_execution.js +23 -14
  14. data/app/assets/javascripts/foreman_remote_execution/locale/ru/foreman_remote_execution.js +23 -14
  15. data/app/assets/javascripts/foreman_remote_execution/locale/zh_CN/foreman_remote_execution.js +23 -14
  16. data/app/assets/javascripts/foreman_remote_execution/locale/zh_TW/foreman_remote_execution.js +23 -14
  17. data/app/controllers/ui_job_wizard_controller.rb +1 -1
  18. data/app/helpers/job_invocations_helper.rb +1 -1
  19. data/app/helpers/remote_execution_helper.rb +2 -2
  20. data/app/lib/actions/remote_execution/proxy_action.rb +1 -1
  21. data/app/lib/actions/remote_execution/run_host_job.rb +9 -3
  22. data/app/models/host_status/execution_status.rb +2 -2
  23. data/app/views/job_invocations/_preview_hosts_list.html.erb +1 -1
  24. data/app/views/job_invocations/show.html.erb +12 -5
  25. data/app/views/job_invocations/show.js.erb +8 -1
  26. data/app/views/job_invocations/welcome.html.erb +1 -1
  27. data/app/views/template_invocations/_refresh.js.erb +10 -4
  28. data/app/views/template_invocations/show.html.erb +2 -2
  29. data/lib/foreman_remote_execution/engine.rb +1 -1
  30. data/lib/foreman_remote_execution/version.rb +1 -1
  31. data/locale/de/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  32. data/locale/de/foreman_remote_execution.po +24 -6
  33. data/locale/en/foreman_remote_execution.po +24 -6
  34. data/locale/en_GB/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  35. data/locale/en_GB/foreman_remote_execution.po +24 -6
  36. data/locale/es/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  37. data/locale/es/foreman_remote_execution.po +24 -6
  38. data/locale/foreman_remote_execution.pot +170 -142
  39. data/locale/fr/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  40. data/locale/fr/foreman_remote_execution.po +24 -6
  41. data/locale/ja/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  42. data/locale/ja/foreman_remote_execution.po +24 -6
  43. data/locale/ka/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  44. data/locale/ka/foreman_remote_execution.po +24 -6
  45. data/locale/ko/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  46. data/locale/ko/foreman_remote_execution.po +24 -6
  47. data/locale/pt_BR/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  48. data/locale/pt_BR/foreman_remote_execution.po +24 -6
  49. data/locale/ru/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  50. data/locale/ru/foreman_remote_execution.po +24 -6
  51. data/locale/zh_CN/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  52. data/locale/zh_CN/foreman_remote_execution.po +24 -6
  53. data/locale/zh_TW/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  54. data/locale/zh_TW/foreman_remote_execution.po +24 -6
  55. data/package.json +1 -5
  56. data/test/functional/api/v2/job_invocations_controller_test.rb +7 -7
  57. data/test/functional/api/v2/template_invocations_controller_test.rb +3 -3
  58. data/test/helpers/remote_execution_helper_test.rb +8 -7
  59. data/test/unit/actions/run_host_job_test.rb +1 -1
  60. data/test/unit/actions/run_hosts_job_test.rb +11 -11
  61. data/test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb +5 -5
  62. data/test/unit/concerns/host_extensions_test.rb +34 -34
  63. data/test/unit/concerns/nic_extensions_test.rb +1 -1
  64. data/test/unit/execution_task_status_mapper_test.rb +10 -10
  65. data/test/unit/input_template_renderer_test.rb +53 -49
  66. data/test/unit/job_invocation_composer_test.rb +78 -78
  67. data/test/unit/job_invocation_test.rb +25 -25
  68. data/test/unit/job_template_effective_user_test.rb +3 -3
  69. data/test/unit/job_template_test.rb +28 -28
  70. data/test/unit/remote_execution_feature_test.rb +14 -14
  71. data/test/unit/remote_execution_provider_test.rb +39 -39
  72. data/test/unit/renderer_scope_input_test.rb +6 -6
  73. data/test/unit/targeting_test.rb +32 -32
  74. data/webpack/JobWizard/JobWizardConstants.js +4 -0
  75. data/webpack/JobWizard/JobWizardSelectors.js +31 -3
  76. data/webpack/JobWizard/PermissionDenied.js +64 -0
  77. data/webpack/JobWizard/__tests__/fixtures.js +3 -3
  78. data/webpack/JobWizard/autofill.js +8 -4
  79. data/webpack/JobWizard/index.js +40 -1
  80. data/webpack/JobWizard/steps/CategoryAndTemplate/CategoryAndTemplate.js +26 -5
  81. data/webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js +3 -3
  82. data/webpack/JobWizard/steps/HostsAndInputs/SelectGQL.js +1 -0
  83. data/webpack/JobWizard/steps/HostsAndInputs/SelectedChips.js +13 -6
  84. data/webpack/JobWizard/steps/HostsAndInputs/hosts.gql +1 -0
  85. data/webpack/JobWizard/steps/HostsAndInputs/index.js +21 -1
  86. data/webpack/JobWizard/steps/ReviewDetails/index.js +3 -2
  87. data/webpack/JobWizard/steps/form/SearchSelect.js +3 -1
  88. data/webpack/JobWizard/steps/form/__tests__/SelectSearch.test.js +2 -0
  89. metadata +3 -2
@@ -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
- _(results).must_include trying_job_template_1
79
- _(results).wont_include trying_job_template_2
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
- _(results).wont_include unauthorized_job_template_1
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
- _(job_categories).must_include trying_job_template_1.job_category
93
- _(job_categories).must_include trying_job_template_2.job_category
94
- _(job_categories).wont_include unauthorized_job_template_2.job_category
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
- _(job_categories.uniq).must_equal job_categories
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
- _(provider_types).must_include 'SSH'
108
- _(provider_types).wont_include 'Mcollective'
109
- _(provider_types).wont_include 'Ansible'
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
- _(provider_types.uniq).must_equal provider_types
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
- _(composer.available_template_inputs).must_include(input1)
126
- _(composer.available_template_inputs).must_include(input2)
127
- _(composer.available_template_inputs).wont_include(unauthorized_input1)
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
- _(composer.available_template_inputs).must_include(input1)
138
- _(composer.available_template_inputs).wont_include(input2)
139
- _(composer.available_template_inputs).wont_include(unauthorized_input1)
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
- assert_not composer.needs_provider_type_selection?
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
- _(result).must_include trying_job_template_1
165
- _(result).must_include trying_job_template_3
166
- _(result).wont_include unauthorized_job_template_1
167
- _(result).wont_include trying_job_template_4
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
- _(result).wont_include trying_job_template_1
171
- _(result).wont_include trying_job_template_3
172
- _(result).wont_include unauthorized_job_template_2
173
- _(result).must_include trying_job_template_4
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
- _(composer).must_be :rerun_possible?
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
- _(composer).must_be :rerun_possible?
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
- _(composer).wont_be :rerun_possible?
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
- _(composer.selected_job_templates).must_be_empty
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
- _(composer.selected_job_templates).wont_include unauthorized
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
- _(composer.selected_job_templates).must_include trying_job_template_1
216
- _(composer.selected_job_templates).must_include mcollective_authorized
217
- _(composer.selected_job_templates).wont_include trying_job_template_3
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
- _(composer.preselected_template_for_provider('SSH')).must_be_nil
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
- _(composer.preselected_template_for_provider('SSH')).must_equal trying_job_template_1
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
- _(invocations.size).must_equal 1
253
- _(invocations.first.input_values.size).must_equal 1
254
- _(invocations.first.input_values.first.value).must_equal 'value1'
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
- _(template_invocation.effective_user).must_equal 'invocation user'
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
- _(template_invocation.effective_user).must_equal 'template user'
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
- _(template_invocation.effective_user).must_equal 'template user'
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
- _(composer.displayed_search_query).must_be_empty
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
- _(composer.displayed_search_query).must_equal 'a'
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
- _(composer.displayed_search_query).must_include host.name
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
- _(composer.displayed_search_query).must_equal bookmark.query
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
- _(composer.displayed_search_query).must_equal bookmark.query
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
- _(composer.displayed_search_query).must_be_empty
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
- _(composer.available_bookmarks).must_include hosts
359
- _(composer.available_bookmarks).must_include dashboard
360
- _(composer.available_bookmarks).wont_include hostgroups
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
- _(composer.targeted_hosts_count).must_equal 1
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
- _(composer.targeted_hosts_count).must_equal 0
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
- _(composer.targeted_hosts_count).must_equal 0
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
- _(value1.value).must_be_empty
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
- _(value1.value).must_be_empty
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
- _(value1.value).must_equal 'value1'
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
- _(composer.job_invocation.concurrency_level).must_equal 5
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
- _(composer.job_invocation.concurrency_level).must_be_nil
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
- _(composer.job_invocation.triggering.mode).must_equal :future
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
- _(composer.job_invocation.triggering.end_time).must_equal Time.local(3,2,1,4,5)
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
- _(composer.job_invocation.password).must_equal password
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
- _(composer.job_invocation.key_passphrase).must_equal key_passphrase
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
- _(composer.job_invocation.effective_user_password).must_equal effective_user_password
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
- _(new_composer.job_category).must_equal existing.job_category
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
- _(new_composer.search_query).must_equal("name ^ (#{host.name})")
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
- _(new_composer.targeting).wont_equal existing.targeting
594
- _(new_composer.search_query).must_equal existing.targeting.search_query
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
- _(new_composer.job_template_ids).must_equal existing.pattern_template_invocations.map(&:template_id)
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
- _(new_composer.pattern_template_invocations.size).must_equal existing.pattern_template_invocations.size
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
- _(new_composer.job_invocation.concurrency_level).must_equal existing.concurrency_level
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
- _(template_invocation.effective_user).must_equal 'invocation user'
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
- _(composer.job_invocation.concurrency_level).must_equal level
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
- _(composer.job_invocation.remote_execution_feature).must_equal feature
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
- _(composer.job_invocation.remote_execution_feature).must_equal feature
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
- _(error.message).must_include "Template #{trying_job_template_1.name}: Input #{input3.name.downcase}: Value can't be blank"
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
- _(input3).must_be :required
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
- _(error.message).must_include "Template #{trying_job_template_1.name}: Not all required inputs have values. Missing inputs: #{input3.name}"
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
- _(found_jobs).must_equal [job_invocation]
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 = ').must_equal [expected]
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
- _(job_invocation.template_invocations).must_be_empty
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
- _(job_invocation.description).must_equal "#{job_invocation.job_category} - #{@input_value.value}"
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
- _(job_invocation.description).must_equal "#{job_invocation.job_category} - ''"
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
- _(job_invocation.description).must_equal expected_result
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
- _(job_invocation.total_hosts_count).must_equal 'N/A'
110
+ assert_equal 'N/A', job_invocation.total_hosts_count
111
111
  job_invocation.targeting.expects(:resolved_at).returns(Time.now.getlocal)
112
- _(job_invocation.total_hosts_count).must_equal 0
112
+ assert_equal 0, job_invocation.total_hosts_count
113
113
  end
114
114
 
115
115
  # task does not exist
116
- specify { _(job_invocation.status).must_equal HostStatus::ExecutionStatus::QUEUED }
117
- specify { _(job_invocation.status_label).must_equal HostStatus::ExecutionStatus::STATUS_NAMES[HostStatus::ExecutionStatus::QUEUED] }
118
- specify { _(job_invocation.progress).must_equal 0 }
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 { _(job_invocation.status).must_equal HostStatus::ExecutionStatus::QUEUED }
142
- specify { _(job_invocation.queued?).must_equal true }
143
- specify { _(job_invocation.progress).must_equal 0 }
144
- specify { _(job_invocation.progress_report).must_equal progress_report_without_sub_tasks }
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
- _(job_invocation.progress_report).must_equal progress_report_without_sub_tasks
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 { _(job_invocation.status).must_equal HostStatus::ExecutionStatus::OK }
167
- specify { _(job_invocation.queued?).must_equal false }
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
- _(job_invocation.progress).must_equal 100
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
- _(invocation.failed_hosts.count).must_equal 1
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
- _(invocation.failed_hosts.count).must_equal 2
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
- _(template_invocations.count).must_equal 1
217
+ assert_equal 1, template_invocations.count
218
218
  template_invocation = template_invocations.first
219
- _(template_invocation.run_host_job_task.result).must_equal 'error'
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
- _(template_invocations.count).must_equal 1
226
+ assert_equal 1, template_invocations.count
227
227
  template_invocation = template_invocations.first
228
- _(template_invocation.run_host_job_task.result).must_equal 'success'
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
- _(effective_user.compute_value).must_equal user.login
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
- _(effective_user.compute_value).must_equal 'testuser'
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
- _(effective_user.compute_value).must_equal 'myuser'
34
+ assert_equal 'myuser', effective_user.compute_value
35
35
  end
36
36
  end
37
37
  end