foreman_remote_execution 3.0.3 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +2 -1
  3. data/.rubocop.yml +80 -50
  4. data/.rubocop_todo.yml +113 -73
  5. data/Gemfile +4 -0
  6. data/app/controllers/api/v2/foreign_input_sets_controller.rb +3 -2
  7. data/app/controllers/api/v2/job_invocations_controller.rb +7 -6
  8. data/app/controllers/api/v2/job_templates_controller.rb +3 -2
  9. data/app/controllers/api/v2/remote_execution_features_controller.rb +3 -2
  10. data/app/controllers/api/v2/template_invocations_controller.rb +1 -1
  11. data/app/controllers/cockpit_controller.rb +1 -0
  12. data/app/controllers/concerns/foreman/controller/parameters/foreign_input_set.rb +1 -1
  13. data/app/controllers/concerns/foreman/controller/parameters/job_template.rb +4 -4
  14. data/app/controllers/job_invocations_controller.rb +10 -6
  15. data/app/controllers/job_templates_controller.rb +1 -1
  16. data/app/controllers/remote_execution_features_controller.rb +3 -2
  17. data/app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb +16 -5
  18. data/app/helpers/job_invocations_chart_helper.rb +11 -10
  19. data/app/helpers/job_invocations_helper.rb +13 -5
  20. data/app/helpers/remote_execution_helper.rb +43 -46
  21. data/app/lib/actions/remote_execution/run_host_job.rb +5 -6
  22. data/app/lib/actions/remote_execution/run_hosts_job.rb +2 -2
  23. data/app/lib/foreman_remote_execution/renderer/scope/input.rb +1 -0
  24. data/app/models/concerns/foreman_remote_execution/errors_flattener.rb +0 -2
  25. data/app/models/concerns/foreman_remote_execution/host_extensions.rb +3 -5
  26. data/app/models/concerns/foreman_remote_execution/nic_extensions.rb +1 -0
  27. data/app/models/concerns/foreman_remote_execution/smart_proxy_extensions.rb +1 -0
  28. data/app/models/foreign_input_set.rb +3 -2
  29. data/app/models/input_template_renderer.rb +1 -1
  30. data/app/models/job_invocation.rb +10 -12
  31. data/app/models/job_invocation_composer.rb +20 -14
  32. data/app/models/job_invocation_task_group.rb +1 -1
  33. data/app/models/job_template.rb +3 -3
  34. data/app/models/remote_execution_feature.rb +0 -2
  35. data/app/models/remote_execution_provider.rb +4 -2
  36. data/app/models/setting/remote_execution.rb +54 -56
  37. data/app/models/ssh_execution_provider.rb +2 -2
  38. data/app/models/targeting.rb +1 -0
  39. data/app/models/template_invocation.rb +2 -3
  40. data/app/views/api/v2/job_invocations/base.json.rabl +1 -1
  41. data/app/views/api/v2/job_invocations/main.json.rabl +5 -2
  42. data/app/views/job_invocations/_card_target_hosts.html.erb +12 -0
  43. data/app/views/job_invocations/_card_user_input.html.erb +1 -1
  44. data/app/views/job_invocations/_form.html.erb +3 -2
  45. data/app/views/job_invocations/_rerun_taxonomies.html.erb +22 -0
  46. data/app/views/job_invocations/_user_input.html.erb +1 -1
  47. data/app/views/job_invocations/show.html.erb +2 -0
  48. data/db/migrate/20151215114631_add_host_id_to_template_invocation.rb +1 -0
  49. data/db/migrate/20180110104432_rename_template_invocation_permission.rb +1 -0
  50. data/db/seeds.d/50-notification_blueprints.rb +4 -4
  51. data/db/seeds.d/90-bookmarks.rb +1 -0
  52. data/extra/cockpit/foreman-cockpit-session +7 -2
  53. data/lib/foreman_remote_execution/engine.rb +18 -17
  54. data/lib/foreman_remote_execution/version.rb +1 -1
  55. data/test/benchmark/run_hosts_job_benchmark.rb +1 -1
  56. data/test/factories/foreman_remote_execution_factories.rb +1 -1
  57. data/test/functional/api/v2/job_invocations_controller_test.rb +9 -9
  58. data/test/functional/api/v2/job_templates_controller_test.rb +1 -1
  59. data/test/functional/api/v2/remote_execution_features_controller_test.rb +2 -2
  60. data/test/functional/api/v2/template_invocations_controller_test.rb +4 -4
  61. data/test/functional/job_invocations_controller_test.rb +11 -11
  62. data/test/functional/job_templates_controller_test.rb +1 -1
  63. data/test/unit/actions/run_hosts_job_test.rb +8 -8
  64. data/test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb +3 -3
  65. data/test/unit/concerns/host_extensions_test.rb +19 -19
  66. data/test/unit/concerns/nic_extensions_test.rb +1 -1
  67. data/test/unit/execution_task_status_mapper_test.rb +10 -10
  68. data/test/unit/input_template_renderer_test.rb +77 -77
  69. data/test/unit/job_invocation_composer_test.rb +100 -96
  70. data/test/unit/job_invocation_test.rb +29 -29
  71. data/test/unit/job_template_effective_user_test.rb +3 -3
  72. data/test/unit/job_template_test.rb +31 -31
  73. data/test/unit/remote_execution_feature_test.rb +19 -19
  74. data/test/unit/remote_execution_provider_test.rb +29 -29
  75. data/test/unit/renderer_scope_input.rb +6 -6
  76. data/test/unit/targeting_test.rb +6 -6
  77. data/test/unit/template_invocation_input_value_test.rb +3 -3
  78. metadata +3 -2
@@ -57,13 +57,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
57
57
  describe '#available_templates_for(job_category)' do
58
58
  it 'find the templates only for a given job name' do
59
59
  results = composer.available_templates_for(trying_job_template_1.job_category)
60
- results.must_include trying_job_template_1
61
- results.wont_include trying_job_template_2
60
+ _(results).must_include trying_job_template_1
61
+ _(results).wont_include trying_job_template_2
62
62
  end
63
63
 
64
64
  it 'it respects view permissions' do
65
65
  results = composer.available_templates_for(trying_job_template_1.job_category)
66
- results.wont_include unauthorized_job_template_1
66
+ _(results).wont_include unauthorized_job_template_1
67
67
  end
68
68
  end
69
69
 
@@ -71,13 +71,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
71
71
  let(:job_categories) { composer.available_job_categories }
72
72
 
73
73
  it 'find only job names that user is granted to view' do
74
- job_categories.must_include trying_job_template_1.job_category
75
- job_categories.must_include trying_job_template_2.job_category
76
- job_categories.wont_include unauthorized_job_template_2.job_category
74
+ _(job_categories).must_include trying_job_template_1.job_category
75
+ _(job_categories).must_include trying_job_template_2.job_category
76
+ _(job_categories).wont_include unauthorized_job_template_2.job_category
77
77
  end
78
78
 
79
79
  it 'every job name is listed just once' do
80
- job_categories.uniq.must_equal job_categories
80
+ _(job_categories.uniq).must_equal job_categories
81
81
  end
82
82
  end
83
83
 
@@ -86,13 +86,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
86
86
 
87
87
  it 'finds only providers which user is granted to view' do
88
88
  composer.job_invocation.job_category = 'trying_job_template_1'
89
- provider_types.must_include 'SSH'
90
- provider_types.wont_include 'Mcollective'
91
- provider_types.wont_include 'Ansible'
89
+ _(provider_types).must_include 'SSH'
90
+ _(provider_types).wont_include 'Mcollective'
91
+ _(provider_types).wont_include 'Ansible'
92
92
  end
93
93
 
94
94
  it 'every provider type is listed just once' do
95
- provider_types.uniq.must_equal provider_types
95
+ _(provider_types.uniq).must_equal provider_types
96
96
  end
97
97
  end
98
98
 
@@ -104,9 +104,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
104
104
  end
105
105
 
106
106
  it 'returns only authorized inputs based on templates' do
107
- composer.available_template_inputs.must_include(input1)
108
- composer.available_template_inputs.must_include(input2)
109
- composer.available_template_inputs.wont_include(unauthorized_input1)
107
+ _(composer.available_template_inputs).must_include(input1)
108
+ _(composer.available_template_inputs).must_include(input2)
109
+ _(composer.available_template_inputs).wont_include(unauthorized_input1)
110
110
  end
111
111
 
112
112
  context 'params contains job template ids' do
@@ -116,9 +116,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
116
116
  let(:params) { { :job_invocation => providers_params }.with_indifferent_access }
117
117
 
118
118
  it 'finds the inputs only specified job templates' do
119
- composer.available_template_inputs.must_include(input1)
120
- composer.available_template_inputs.wont_include(input2)
121
- composer.available_template_inputs.wont_include(unauthorized_input1)
119
+ _(composer.available_template_inputs).must_include(input1)
120
+ _(composer.available_template_inputs).wont_include(input2)
121
+ _(composer.available_template_inputs).wont_include(unauthorized_input1)
122
122
  end
123
123
  end
124
124
  end
@@ -143,40 +143,40 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
143
143
  it 'returns all templates for a given provider respecting template permissions' do
144
144
  trying_job_template_4 = FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying4', :provider_type => 'Ansible')
145
145
  result = composer.templates_for_provider('SSH')
146
- result.must_include trying_job_template_1
147
- result.must_include trying_job_template_3
148
- result.wont_include unauthorized_job_template_1
149
- result.wont_include trying_job_template_4
146
+ _(result).must_include trying_job_template_1
147
+ _(result).must_include trying_job_template_3
148
+ _(result).wont_include unauthorized_job_template_1
149
+ _(result).wont_include trying_job_template_4
150
150
 
151
151
  result = composer.templates_for_provider('Ansible')
152
- result.wont_include trying_job_template_1
153
- result.wont_include trying_job_template_3
154
- result.wont_include unauthorized_job_template_2
155
- result.must_include trying_job_template_4
152
+ _(result).wont_include trying_job_template_1
153
+ _(result).wont_include trying_job_template_3
154
+ _(result).wont_include unauthorized_job_template_2
155
+ _(result).must_include trying_job_template_4
156
156
  end
157
157
  end
158
158
 
159
159
  describe '#rerun_possible?' do
160
160
  it 'is true when not rerunning' do
161
- composer.must_be :rerun_possible?
161
+ _(composer).must_be :rerun_possible?
162
162
  end
163
163
 
164
164
  it 'is true when rerunning with pattern tempalte invocations' do
165
165
  composer.expects(:reruns).returns(1)
166
166
  composer.job_invocation.expects(:pattern_template_invocations).returns([1])
167
- composer.must_be :rerun_possible?
167
+ _(composer).must_be :rerun_possible?
168
168
  end
169
169
 
170
170
  it 'is false when rerunning without pattern template invocations' do
171
171
  composer.expects(:reruns).returns(1)
172
172
  composer.job_invocation.expects(:pattern_template_invocations).returns([])
173
- composer.wont_be :rerun_possible?
173
+ _(composer).wont_be :rerun_possible?
174
174
  end
175
175
  end
176
176
 
177
177
  describe '#selected_job_templates' do
178
178
  it 'returns no template if none was selected through params' do
179
- composer.selected_job_templates.must_be_empty
179
+ _(composer.selected_job_templates).must_be_empty
180
180
  end
181
181
 
182
182
  context 'extra unavailable templates id were selected' do
@@ -189,14 +189,14 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
189
189
 
190
190
  it 'ignores unauthorized template' do
191
191
  unauthorized # make sure unautorized exists
192
- composer.selected_job_templates.wont_include unauthorized
192
+ _(composer.selected_job_templates).wont_include unauthorized
193
193
  end
194
194
 
195
195
  it 'contains only authorized template specified in params' do
196
196
  mcollective_authorized # make sure mcollective_authorized exists
197
- composer.selected_job_templates.must_include trying_job_template_1
198
- composer.selected_job_templates.must_include mcollective_authorized
199
- composer.selected_job_templates.wont_include trying_job_template_3
197
+ _(composer.selected_job_templates).must_include trying_job_template_1
198
+ _(composer.selected_job_templates).must_include mcollective_authorized
199
+ _(composer.selected_job_templates).wont_include trying_job_template_3
200
200
  end
201
201
  end
202
202
  end
@@ -204,7 +204,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
204
204
  describe '#preselected_template_for_provider(provider_type)' do
205
205
  context 'none template was selected through params' do
206
206
  it 'returns nil' do
207
- composer.preselected_template_for_provider('SSH').must_be_nil
207
+ _(composer.preselected_template_for_provider('SSH')).must_be_nil
208
208
  end
209
209
  end
210
210
 
@@ -213,7 +213,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
213
213
  let(:params) { { :job_invocation => providers_params }.with_indifferent_access }
214
214
 
215
215
  it 'returns the selected template because it is available for provider' do
216
- composer.preselected_template_for_provider('SSH').must_equal trying_job_template_1
216
+ _(composer.preselected_template_for_provider('SSH')).must_equal trying_job_template_1
217
217
  end
218
218
  end
219
219
  end
@@ -223,17 +223,17 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
223
223
  { :job_template_id => trying_job_template_1.id.to_s,
224
224
  :job_templates => {
225
225
  trying_job_template_1.id.to_s => {
226
- :input_values => { input1.id.to_s => { :value => 'value1' }, unauthorized_input1.id.to_s => { :value => 'dropped' } }
227
- }
226
+ :input_values => { input1.id.to_s => { :value => 'value1' }, unauthorized_input1.id.to_s => { :value => 'dropped' } },
227
+ },
228
228
  }}
229
229
  end
230
230
  let(:params) { { :job_invocation => { :providers => { :ssh => ssh_params } } }.with_indifferent_access }
231
231
  let(:invocations) { composer.pattern_template_invocations }
232
232
 
233
233
  it 'builds pattern template invocations based on passed params and it filters out wrong inputs' do
234
- invocations.size.must_equal 1
235
- invocations.first.input_values.size.must_equal 1
236
- invocations.first.input_values.first.value.must_equal 'value1'
234
+ _(invocations.size).must_equal 1
235
+ _(invocations.first.input_values.size).must_equal 1
236
+ _(invocations.first.input_values.first.value).must_equal 'value1'
237
237
  end
238
238
  end
239
239
 
@@ -242,13 +242,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
242
242
  { :job_template_id => trying_job_template_1.id.to_s,
243
243
  :job_templates => {
244
244
  trying_job_template_1.id.to_s => {
245
- :effective_user => invocation_effective_user
246
- }
245
+ :effective_user => invocation_effective_user,
246
+ },
247
247
  }}
248
248
  end
249
249
  let(:params) { { :job_invocation => { :providers => { :ssh => ssh_params } } }.with_indifferent_access }
250
250
  let(:template_invocation) do
251
- trying_job_template_1.effective_user.update_attributes(:overridable => overridable, :value => 'template user')
251
+ trying_job_template_1.effective_user.update(:overridable => overridable, :value => 'template user')
252
252
  composer.pattern_template_invocations.first
253
253
  end
254
254
 
@@ -261,7 +261,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
261
261
  let(:invocation_effective_user) { 'invocation user' }
262
262
 
263
263
  it 'takes the value from the template invocation' do
264
- template_invocation.effective_user.must_equal 'invocation user'
264
+ _(template_invocation.effective_user).must_equal 'invocation user'
265
265
  end
266
266
  end
267
267
 
@@ -270,7 +270,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
270
270
  let(:invocation_effective_user) { '' }
271
271
 
272
272
  it 'takes the value from the job template' do
273
- template_invocation.effective_user.must_equal 'template user'
273
+ _(template_invocation.effective_user).must_equal 'template user'
274
274
  end
275
275
  end
276
276
 
@@ -279,14 +279,14 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
279
279
  let(:invocation_effective_user) { 'invocation user' }
280
280
 
281
281
  it 'takes the value from the job template' do
282
- template_invocation.effective_user.must_equal 'template user'
282
+ _(template_invocation.effective_user).must_equal 'template user'
283
283
  end
284
284
  end
285
285
  end
286
286
 
287
287
  describe '#displayed_search_query' do
288
288
  it 'is empty by default' do
289
- composer.displayed_search_query.must_be_empty
289
+ _(composer.displayed_search_query).must_be_empty
290
290
  end
291
291
 
292
292
  let(:host) { FactoryBot.create(:host) }
@@ -296,7 +296,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
296
296
  let(:params) { { :targeting => { :search_query => 'a', :bookmark_id => bookmark.id }, :host_ids => [ host.id ] }.with_indifferent_access }
297
297
 
298
298
  it 'explicit search query has highest priority' do
299
- composer.displayed_search_query.must_equal 'a'
299
+ _(composer.displayed_search_query).must_equal 'a'
300
300
  end
301
301
  end
302
302
 
@@ -304,7 +304,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
304
304
  let(:params) { { :targeting => { :bookmark_id => bookmark.id }, :host_ids => [ host.id ] }.with_indifferent_access }
305
305
 
306
306
  it 'hosts will be used instead of a bookmark' do
307
- composer.displayed_search_query.must_include host.name
307
+ _(composer.displayed_search_query).must_include host.name
308
308
  end
309
309
  end
310
310
 
@@ -313,20 +313,20 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
313
313
 
314
314
  it 'bookmark query is used if it is available for the user' do
315
315
  bookmark.update_attribute :public, false
316
- composer.displayed_search_query.must_equal bookmark.query
316
+ _(composer.displayed_search_query).must_equal bookmark.query
317
317
  end
318
318
 
319
319
  it 'bookmark query is used if the bookmark is public' do
320
320
  bookmark.owner = nil
321
321
  bookmark.save(:validate => false) # skip validations so owner remains nil
322
- composer.displayed_search_query.must_equal bookmark.query
322
+ _(composer.displayed_search_query).must_equal bookmark.query
323
323
  end
324
324
 
325
325
  it 'empty search is returned if bookmark is not owned by the user and is not public' do
326
326
  bookmark.public = false
327
327
  bookmark.owner = nil
328
328
  bookmark.save(:validate => false) # skip validations so owner remains nil
329
- composer.displayed_search_query.must_be_empty
329
+ _(composer.displayed_search_query).must_be_empty
330
330
  end
331
331
  end
332
332
  end
@@ -347,9 +347,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
347
347
  hosts
348
348
  dashboard
349
349
  hostgroups
350
- composer.available_bookmarks.must_include hosts
351
- composer.available_bookmarks.must_include dashboard
352
- composer.available_bookmarks.wont_include hostgroups
350
+ _(composer.available_bookmarks).must_include hosts
351
+ _(composer.available_bookmarks).must_include dashboard
352
+ _(composer.available_bookmarks).wont_include hostgroups
353
353
  end
354
354
  end
355
355
  end
@@ -365,17 +365,17 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
365
365
 
366
366
  it 'searches hosts based on displayed_search_query' do
367
367
  composer.stubs(:displayed_search_query => "name = #{host.name}")
368
- composer.targeted_hosts_count.must_equal 1
368
+ _(composer.targeted_hosts_count).must_equal 1
369
369
  end
370
370
 
371
371
  it 'returns 0 for queries with syntax errors' do
372
372
  composer.stubs(:displayed_search_query => 'name = ')
373
- composer.targeted_hosts_count.must_equal 0
373
+ _(composer.targeted_hosts_count).must_equal 0
374
374
  end
375
375
 
376
376
  it 'returns 0 when no query is present' do
377
377
  composer.stubs(:displayed_search_query => '')
378
- composer.targeted_hosts_count.must_equal 0
378
+ _(composer.targeted_hosts_count).must_equal 0
379
379
  end
380
380
  end
381
381
 
@@ -383,7 +383,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
383
383
  let(:value1) { composer.input_value_for(input1) }
384
384
  it 'returns new empty input value if there is no invocation' do
385
385
  assert value1.new_record?
386
- value1.value.must_be_empty
386
+ _(value1.value).must_be_empty
387
387
  end
388
388
 
389
389
  context 'there are invocations without input values for a given input' do
@@ -391,15 +391,15 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
391
391
  { :job_template_id => trying_job_template_1.id.to_s,
392
392
  :job_templates => {
393
393
  trying_job_template_1.id.to_s => {
394
- :input_values => { }
395
- }
394
+ :input_values => { },
395
+ },
396
396
  } }
397
397
  end
398
398
  let(:params) { { :job_invocation => { :providers => { :ssh => ssh_params } } }.with_indifferent_access }
399
399
 
400
400
  it 'returns new empty input value' do
401
401
  assert value1.new_record?
402
- value1.value.must_be_empty
402
+ _(value1.value).must_be_empty
403
403
  end
404
404
  end
405
405
 
@@ -408,14 +408,14 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
408
408
  { :job_template_id => trying_job_template_1.id.to_s,
409
409
  :job_templates => {
410
410
  trying_job_template_1.id.to_s => {
411
- :input_values => { input1.id.to_s => { :value => 'value1' } }
412
- }
411
+ :input_values => { input1.id.to_s => { :value => 'value1' } },
412
+ },
413
413
  } }
414
414
  end
415
415
  let(:params) { { :job_invocation => { :providers => { :ssh => ssh_params } } }.with_indifferent_access }
416
416
 
417
417
  it 'finds the value among template invocations' do
418
- value1.value.must_equal 'value1'
418
+ _(value1.value).must_equal 'value1'
419
419
  end
420
420
  end
421
421
  end
@@ -426,8 +426,8 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
426
426
  { :job_template_id => trying_job_template_1.id.to_s,
427
427
  :job_templates => {
428
428
  trying_job_template_1.id.to_s => {
429
- :input_values => { input1.id.to_s => { :value => 'value1' } }
430
- }
429
+ :input_values => { input1.id.to_s => { :value => 'value1' } },
430
+ },
431
431
  } }
432
432
  end
433
433
 
@@ -452,24 +452,28 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
452
452
  end
453
453
 
454
454
  it 'accepts the concurrency options' do
455
- composer.job_invocation.concurrency_level.must_equal 5
456
- composer.job_invocation.time_span.must_equal 60
455
+ _(composer.job_invocation.concurrency_level).must_equal 5
456
+ _(composer.job_invocation.time_span).must_equal 60
457
457
  end
458
458
  end
459
459
 
460
460
  it 'can be disabled' do
461
- composer.job_invocation.concurrency_level.must_be_nil
462
- composer.job_invocation.time_span.must_be_nil
461
+ _(composer.job_invocation.concurrency_level).must_be_nil
462
+ _(composer.job_invocation.time_span).must_be_nil
463
463
  end
464
464
  end
465
465
 
466
466
  describe 'triggering' do
467
467
  let(:params) do
468
- { :job_invocation => { :providers => { :ssh => ssh_params } }, :triggering => { :mode => 'future' }}.with_indifferent_access
468
+ { :job_invocation => { :providers => { :ssh => ssh_params } }, :triggering => { :mode => 'future', :end_time=> {"end_time(3i)": 1, "end_time(2i)": 2, "end_time(1i)": 3, "end_time(4i)": 4, "end_time(5i)": 5} }}.with_indifferent_access
469
469
  end
470
470
 
471
471
  it 'accepts the triggering params' do
472
- composer.job_invocation.triggering.mode.must_equal :future
472
+ _(composer.job_invocation.triggering.mode).must_equal :future
473
+ end
474
+
475
+ it 'formats the triggering end time when its unordered' do
476
+ _(composer.job_invocation.triggering.end_time).must_equal Time.local(3,2,1,4,5)
473
477
  end
474
478
  end
475
479
 
@@ -503,7 +507,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
503
507
 
504
508
  it 'sets the password properly' do
505
509
  composer
506
- composer.job_invocation.password.must_equal password
510
+ _(composer.job_invocation.password).must_equal password
507
511
  end
508
512
  end
509
513
 
@@ -515,7 +519,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
515
519
 
516
520
  it 'sets the key passphrase properly' do
517
521
  composer
518
- composer.job_invocation.key_passphrase.must_equal key_passphrase
522
+ _(composer.job_invocation.key_passphrase).must_equal key_passphrase
519
523
  end
520
524
  end
521
525
 
@@ -527,7 +531,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
527
531
 
528
532
  it 'sets the sudo password properly' do
529
533
  composer
530
- composer.job_invocation.sudo_password.must_equal sudo_password
534
+ _(composer.job_invocation.sudo_password).must_equal sudo_password
531
535
  end
532
536
  end
533
537
 
@@ -545,8 +549,8 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
545
549
  { :job_template_id => trying_job_template_1.id.to_s,
546
550
  :job_templates => {
547
551
  trying_job_template_1.id.to_s => {
548
- :input_values => { input1.id.to_s => { :value => 'value1' } }
549
- }
552
+ :input_values => { input1.id.to_s => { :value => 'value1' } },
553
+ },
550
554
  } }
551
555
  end
552
556
  let(:params) do
@@ -558,8 +562,8 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
558
562
  },
559
563
  :targeting => {
560
564
  :search_query => "name = #{host.name}",
561
- :targeting_type => Targeting::STATIC_TYPE
562
- }
565
+ :targeting_type => Targeting::STATIC_TYPE,
566
+ },
563
567
  }.with_indifferent_access
564
568
  end
565
569
  let(:existing) { composer.job_invocation }
@@ -570,30 +574,30 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
570
574
  end
571
575
 
572
576
  it 'sets the same job name' do
573
- new_composer.job_category.must_equal existing.job_category
577
+ _(new_composer.job_category).must_equal existing.job_category
574
578
  end
575
579
 
576
580
  it 'accepts additional host ids' do
577
581
  new_composer = JobInvocationComposer.from_job_invocation(composer.job_invocation, { :host_ids => [host.id] })
578
- new_composer.search_query.must_equal("name ^ (#{host.name})")
582
+ _(new_composer.search_query).must_equal("name ^ (#{host.name})")
579
583
  end
580
584
 
581
585
  it 'builds new targeting object which keeps search query' do
582
- new_composer.targeting.wont_equal existing.targeting
583
- new_composer.search_query.must_equal existing.targeting.search_query
586
+ _(new_composer.targeting).wont_equal existing.targeting
587
+ _(new_composer.search_query).must_equal existing.targeting.search_query
584
588
  end
585
589
 
586
590
  it 'keeps job template ids' do
587
- new_composer.job_template_ids.must_equal existing.pattern_template_invocations.map(&:template_id)
591
+ _(new_composer.job_template_ids).must_equal existing.pattern_template_invocations.map(&:template_id)
588
592
  end
589
593
 
590
594
  it 'keeps template invocations and their values' do
591
- new_composer.pattern_template_invocations.size.must_equal existing.pattern_template_invocations.size
595
+ _(new_composer.pattern_template_invocations.size).must_equal existing.pattern_template_invocations.size
592
596
  end
593
597
 
594
598
  it 'sets the same concurrency control options' do
595
- new_composer.job_invocation.concurrency_level.must_equal existing.concurrency_level
596
- new_composer.job_invocation.time_span.must_equal existing.time_span
599
+ _(new_composer.job_invocation.concurrency_level).must_equal existing.concurrency_level
600
+ _(new_composer.job_invocation.time_span).must_equal existing.time_span
597
601
  end
598
602
 
599
603
  end
@@ -669,7 +673,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
669
673
 
670
674
  it 'sets the effective user based on the input' do
671
675
  assert composer.save!
672
- template_invocation.effective_user.must_equal 'invocation user'
676
+ _(template_invocation.effective_user).must_equal 'invocation user'
673
677
  end
674
678
  end
675
679
 
@@ -681,7 +685,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
681
685
  :job_template_id => trying_job_template_1.id,
682
686
  :concurrency_control => {
683
687
  :concurrency_level => level,
684
- :time_span => time_span
688
+ :time_span => time_span,
685
689
  },
686
690
  :targeting_type => 'static_query',
687
691
  :search_query => 'some hosts',
@@ -690,8 +694,8 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
690
694
 
691
695
  it 'sets the concurrency level and time span based on the input' do
692
696
  assert composer.save!
693
- composer.job_invocation.time_span.must_equal time_span
694
- composer.job_invocation.concurrency_level.must_equal level
697
+ _(composer.job_invocation.time_span).must_equal time_span
698
+ _(composer.job_invocation.concurrency_level).must_equal level
695
699
  end
696
700
  end
697
701
 
@@ -708,7 +712,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
708
712
 
709
713
  it 'sets the remote execution feature based on the input' do
710
714
  assert composer.save!
711
- composer.job_invocation.remote_execution_feature.must_equal feature
715
+ _(composer.job_invocation.remote_execution_feature).must_equal feature
712
716
  end
713
717
  end
714
718
 
@@ -757,7 +761,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
757
761
  error = assert_raises(ActiveRecord::RecordNotSaved) do
758
762
  composer.save!
759
763
  end
760
- error.message.must_include "Template #{trying_job_template_1.name}: Input #{input3.name.downcase}: Value can't be blank"
764
+ _(error.message).must_include "Template #{trying_job_template_1.name}: Input #{input3.name.downcase}: Value can't be blank"
761
765
  end
762
766
  end
763
767
 
@@ -786,13 +790,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
786
790
  end
787
791
 
788
792
  it 'handles errors' do
789
- input3.must_be :required
793
+ _(input3).must_be :required
790
794
 
791
795
  error = assert_raises(ActiveRecord::RecordNotSaved) do
792
796
  composer.save!
793
797
  end
794
798
 
795
- error.message.must_include "Template #{trying_job_template_1.name}: Not all required inputs have values. Missing inputs: #{input3.name}"
799
+ _(error.message).must_include "Template #{trying_job_template_1.name}: Not all required inputs have values. Missing inputs: #{input3.name}"
796
800
  end
797
801
  end
798
802
  end