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
@@ -11,7 +11,7 @@ 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).with_task.order('job_invocations.id DESC')
14
- found_jobs.must_equal [job_invocation]
14
+ _(found_jobs).must_equal [job_invocation]
15
15
  end
16
16
 
17
17
  it 'is able to auto complete description' do
@@ -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
+ _(job_invocation.template_invocations).must_be_empty
44
44
  end
45
45
  end
46
46
 
@@ -51,11 +51,11 @@ class JobInvocationTest < ActiveSupport::TestCase
51
51
  input = job_invocation.pattern_template_invocations.first.template.template_inputs.create!(:name => 'foo', :required => true, :input_type => 'user')
52
52
  input2 = job_invocation.pattern_template_invocations.first.template.template_inputs.create!(:name => 'bar', :required => true, :input_type => 'user')
53
53
  FactoryBot.create(:template_invocation_input_value,
54
- :template_invocation => job_invocation.pattern_template_invocations.first,
55
- :template_input => input2)
54
+ :template_invocation => job_invocation.pattern_template_invocations.first,
55
+ :template_input => input2)
56
56
  @input_value = FactoryBot.create(:template_invocation_input_value,
57
- :template_invocation => job_invocation.pattern_template_invocations.first,
58
- :template_input => input)
57
+ :template_invocation => job_invocation.pattern_template_invocations.first,
58
+ :template_input => input)
59
59
  job_invocation.reload
60
60
  job_invocation.pattern_template_invocations.first.reload
61
61
  end
@@ -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
+ _(job_invocation.description).must_equal "#{job_invocation.job_category} - #{@input_value.value}"
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} - %{missing_key}"
94
+ _(job_invocation.description).must_equal "#{job_invocation.job_category} - ''"
95
95
  end
96
96
 
97
97
  it 'truncates generated description to 255 characters' do
@@ -101,22 +101,22 @@ class JobInvocationTest < ActiveSupport::TestCase
101
101
  job_invocation.description_format = '%{job_category}'
102
102
  job_invocation.job_category = 'a' * 1000
103
103
  job_invocation.generate_description
104
- job_invocation.description.must_equal expected_result
104
+ _(job_invocation.description).must_equal expected_result
105
105
  end
106
106
  end
107
107
  end
108
108
 
109
109
  context 'future execution' do
110
110
  it 'can report host count' do
111
- job_invocation.total_hosts_count.must_equal 'N/A'
111
+ _(job_invocation.total_hosts_count).must_equal 'N/A'
112
112
  job_invocation.targeting.expects(:resolved_at).returns(Time.now.getlocal)
113
- job_invocation.total_hosts_count.must_equal 0
113
+ _(job_invocation.total_hosts_count).must_equal 0
114
114
  end
115
115
 
116
116
  # task does not exist
117
- specify { job_invocation.status.must_equal HostStatus::ExecutionStatus::QUEUED }
118
- specify { job_invocation.status_label.must_equal HostStatus::ExecutionStatus::STATUS_NAMES[HostStatus::ExecutionStatus::QUEUED] }
119
- specify { job_invocation.progress.must_equal 0 }
117
+ specify { _(job_invocation.status).must_equal HostStatus::ExecutionStatus::QUEUED }
118
+ specify { _(job_invocation.status_label).must_equal HostStatus::ExecutionStatus::STATUS_NAMES[HostStatus::ExecutionStatus::QUEUED] }
119
+ specify { _(job_invocation.progress).must_equal 0 }
120
120
  end
121
121
 
122
122
  context 'with task' do
@@ -130,7 +130,7 @@ class JobInvocationTest < ActiveSupport::TestCase
130
130
  :cancelled => 0,
131
131
  :failed => 0,
132
132
  :pending => 0,
133
- :progress => 0
133
+ :progress => 0,
134
134
  }
135
135
  end
136
136
  before { job_invocation.task = task }
@@ -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 { _(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 }
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
+ _(job_invocation.progress_report).must_equal progress_report_without_sub_tasks
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 { _(job_invocation.status).must_equal HostStatus::ExecutionStatus::OK }
167
+ specify { _(job_invocation.queued?).must_equal false }
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
+ _(job_invocation.progress).must_equal 100
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
+ _(invocation.failed_hosts.count).must_equal 1
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
+ _(invocation.failed_hosts.count).must_equal 2
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
+ _(template_invocations.count).must_equal 1
218
218
  template_invocation = template_invocations.first
219
- template_invocation.run_host_job_task.result.must_equal 'error'
219
+ _(template_invocation.run_host_job_task.result).must_equal 'error'
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
+ _(template_invocations.count).must_equal 1
227
227
  template_invocation = template_invocations.first
228
- template_invocation.run_host_job_task.result.must_equal 'success'
228
+ _(template_invocation.run_host_job_task.result).must_equal 'success'
229
229
  end
230
230
  end
231
231
  end
@@ -23,19 +23,19 @@ class JobTemplateEffectiveUserTest < ActiveSupport::TestCase
23
23
  user = FactoryBot.create(:user)
24
24
  User.current = user
25
25
  effective_user.current_user = true
26
- effective_user.compute_value.must_equal user.login
26
+ _(effective_user.compute_value).must_equal user.login
27
27
  end
28
28
 
29
29
  it 'returns the value when not current user is set to true' do
30
30
  effective_user.current_user = false
31
31
  effective_user.value = 'testuser'
32
- effective_user.compute_value.must_equal 'testuser'
32
+ _(effective_user.compute_value).must_equal 'testuser'
33
33
  end
34
34
 
35
35
  it 'returns a default value when no value is specified for the user' do
36
36
  effective_user.value = ''
37
37
  Setting[:remote_execution_effective_user] = 'myuser'
38
- effective_user.compute_value.must_equal 'myuser'
38
+ _(effective_user.compute_value).must_equal 'myuser'
39
39
  end
40
40
  end
41
41
  end
@@ -30,7 +30,7 @@ class JobTemplateTest < ActiveSupport::TestCase
30
30
  job_template.foreign_input_sets << FactoryBot.build(:foreign_input_set, :target_template => template_with_inputs)
31
31
  job_template.foreign_input_sets << FactoryBot.build(:foreign_input_set, :target_template => template_with_inputs)
32
32
  assert_not job_template.valid?
33
- job_template.errors.full_messages.first.must_include 'Duplicated inputs detected: ["command"]'
33
+ _(job_template.errors.full_messages.first).must_include 'Duplicated inputs detected: ["command"]'
34
34
  end
35
35
  end
36
36
 
@@ -40,21 +40,21 @@ class JobTemplateTest < ActiveSupport::TestCase
40
40
  let(:minimal_template) { FactoryBot.build(:job_template) }
41
41
 
42
42
  it 'uses the description_format attribute if set' do
43
- template_with_description.generate_description_format.must_equal template_with_description.description_format
43
+ _(template_with_description.generate_description_format).must_equal template_with_description.description_format
44
44
  end
45
45
 
46
46
  it 'uses the job name as description_format if not set or blank and has no inputs' do
47
- minimal_template.generate_description_format.must_equal '%{template_name}'
47
+ _(minimal_template.generate_description_format).must_equal '%{template_name}'
48
48
  minimal_template.description_format = ''
49
- minimal_template.generate_description_format.must_equal '%{template_name}'
49
+ _(minimal_template.generate_description_format).must_equal '%{template_name}'
50
50
  end
51
51
 
52
52
  it 'generates the description_format if not set or blank and has inputs' do
53
53
  input_name = template.template_inputs.first.name
54
54
  expected_result = %(%{template_name} with inputs #{input_name}="%{#{input_name}}")
55
- template.generate_description_format.must_equal expected_result
55
+ _(template.generate_description_format).must_equal expected_result
56
56
  template.description_format = ''
57
- template.generate_description_format.must_equal expected_result
57
+ _(template.generate_description_format).must_equal expected_result
58
58
  end
59
59
  end
60
60
 
@@ -64,10 +64,10 @@ class JobTemplateTest < ActiveSupport::TestCase
64
64
  describe '#dup' do
65
65
  it 'duplicates also template inputs' do
66
66
  duplicate = job_template.dup
67
- duplicate.wont_equal job_template
68
- duplicate.template_inputs.wont_be_empty
69
- duplicate.template_inputs.first.wont_equal job_template.template_inputs.first
70
- duplicate.template_inputs.first.name.must_equal job_template.template_inputs.first.name
67
+ _(duplicate).wont_equal job_template
68
+ _(duplicate.template_inputs).wont_be_empty
69
+ _(duplicate.template_inputs.first).wont_equal job_template.template_inputs.first
70
+ _(duplicate.template_inputs.first.name).must_equal job_template.template_inputs.first.name
71
71
  end
72
72
  end
73
73
  end
@@ -118,30 +118,30 @@ class JobTemplateTest < ActiveSupport::TestCase
118
118
  end
119
119
 
120
120
  it 'sets the name' do
121
- template.name.must_equal 'Service Restart'
121
+ _(template.name).must_equal 'Service Restart'
122
122
  end
123
123
 
124
124
  it 'has a template' do
125
- template.template.squish.must_equal 'service <%= input("service_name") %> restart'
125
+ _(template.template.squish).must_equal 'service <%= input("service_name") %> restart'
126
126
  end
127
127
 
128
128
  it 'imports inputs' do
129
- template.template_inputs.first.name.must_equal 'service_name'
129
+ _(template.template_inputs.first.name).must_equal 'service_name'
130
130
  end
131
131
 
132
132
  it 'imports input sets' do
133
- template_with_input_sets.foreign_input_sets.first.target_template.must_equal template
134
- template_with_input_sets.template_inputs_with_foreign.map(&:name).must_equal ['service_name']
133
+ _(template_with_input_sets.foreign_input_sets.first.target_template).must_equal template
134
+ _(template_with_input_sets.template_inputs_with_foreign.map(&:name)).must_equal ['service_name']
135
135
  end
136
136
 
137
137
  it 'imports feature' do
138
138
  template # let is lazy
139
139
  remote_execution_feature.reload
140
- remote_execution_feature.job_template.must_equal template
140
+ _(remote_execution_feature.job_template).must_equal template
141
141
  end
142
142
 
143
143
  it 'sets additional options' do
144
- template.default.must_equal true
144
+ _(template.default).must_equal true
145
145
  end
146
146
  end
147
147
 
@@ -224,16 +224,16 @@ class JobTemplateTest < ActiveSupport::TestCase
224
224
 
225
225
  it 'syncs inputs' do
226
226
  hostname = synced_template.template_inputs.find { |input| input.name == 'hostname' }
227
- hostname.options.must_equal 'www.redhat.com'
227
+ _(hostname.options).must_equal 'www.redhat.com'
228
228
  end
229
229
 
230
230
  it 'syncs content' do
231
- synced_template.template.must_match(/ping -c <%= input\('count'\) %> <%= input\('hostname'\) %>/m)
231
+ _(synced_template.template).must_match(/ping -c <%= input\('count'\) %> <%= input\('hostname'\) %>/m)
232
232
  end
233
233
 
234
234
  it 'syncs input sets' do
235
- synced_template.foreign_input_sets.first.target_template.must_equal included
236
- synced_template.template_inputs_with_foreign.map(&:name).must_equal ['hostname', 'count']
235
+ _(synced_template.foreign_input_sets.first.target_template).must_equal included
236
+ _(synced_template.template_inputs_with_foreign.map(&:name)).must_equal ['hostname', 'count']
237
237
  end
238
238
  end
239
239
 
@@ -247,25 +247,25 @@ class JobTemplateTest < ActiveSupport::TestCase
247
247
  end
248
248
 
249
249
  it 'exports name' do
250
- erb.must_match(/^name: #{exportable_template.name}$/)
250
+ _(erb).must_match(/^name: #{exportable_template.name}$/)
251
251
  end
252
252
 
253
253
  it 'includes template inputs' do
254
- erb.must_match(/^template_inputs:$/)
254
+ _(erb).must_match(/^template_inputs:$/)
255
255
  end
256
256
 
257
257
  it 'includes template contents' do
258
- erb.must_include exportable_template.template
258
+ _(erb).must_include exportable_template.template
259
259
  end
260
260
 
261
261
  it 'is importable' do
262
262
  erb
263
263
  old_name = exportable_template.name
264
- exportable_template.update_attributes(:name => "#{old_name}_renamed")
264
+ exportable_template.update(:name => "#{old_name}_renamed")
265
265
 
266
266
  imported = JobTemplate.import_raw!(erb)
267
- imported.name.must_equal old_name
268
- imported.template_inputs.first.to_export.must_equal exportable_template.template_inputs.first.to_export
267
+ _(imported.name).must_equal old_name
268
+ _(imported.template_inputs.first.to_export).must_equal exportable_template.template_inputs.first.to_export
269
269
  end
270
270
 
271
271
  it 'has taxonomies in metadata' do
@@ -280,7 +280,7 @@ class JobTemplateTest < ActiveSupport::TestCase
280
280
 
281
281
  describe 'job template deletion' do
282
282
  it 'succeeds' do
283
- job_template.pattern_template_invocations.wont_be_empty
283
+ _(job_template.pattern_template_invocations).wont_be_empty
284
284
  assert job_template.destroy
285
285
  end
286
286
  end
@@ -305,10 +305,10 @@ class JobTemplateTest < ActiveSupport::TestCase
305
305
 
306
306
  setup_user('view', 'job_templates')
307
307
  renderer = InputTemplateRenderer.new template_invocation.template,
308
- template_invocation.host,
309
- template_invocation
308
+ template_invocation.host,
309
+ template_invocation
310
310
  result = renderer.render
311
- result.must_equal "<wrap>#{inner.template}</wrap>"
311
+ _(result).must_equal "<wrap>#{inner.template}</wrap>"
312
312
  end
313
313
  end
314
314
  end
@@ -8,8 +8,8 @@ class RemoteExecutionFeatureTest < ActiveSupport::TestCase
8
8
 
9
9
  let(:install_feature) do
10
10
  RemoteExecutionFeature.register(:katello_install_package, N_('Katello: Install package'),
11
- :description => 'Install package via Katello user interface',
12
- :provided_inputs => ['package'])
11
+ :description => 'Install package via Katello user interface',
12
+ :provided_inputs => ['package'])
13
13
  end
14
14
 
15
15
  let(:package_template) do
@@ -24,48 +24,48 @@ class RemoteExecutionFeatureTest < ActiveSupport::TestCase
24
24
 
25
25
  before do
26
26
  User.current = users :admin
27
- install_feature.update_attributes!(:job_template_id => package_template.id)
27
+ install_feature.update!(:job_template_id => package_template.id)
28
28
  end
29
29
 
30
30
  describe 'composer' do
31
31
  it 'prepares composer for given feature based on the mapping' do
32
32
  composer = JobInvocationComposer.for_feature(:katello_install_package, host, :package => 'zsh')
33
33
  assert composer.valid?
34
- composer.pattern_template_invocations.size.must_equal 1
34
+ _(composer.pattern_template_invocations.size).must_equal 1
35
35
  template_invocation = composer.pattern_template_invocations.first
36
- template_invocation.template.must_equal package_template
37
- template_invocation.input_values.size.must_equal 1
36
+ _(template_invocation.template).must_equal package_template
37
+ _(template_invocation.input_values.size).must_equal 1
38
38
 
39
39
  input_value = template_invocation.input_values.first
40
- input_value.value.must_equal 'zsh'
41
- input_value.template_input.name.must_equal 'package'
40
+ _(input_value.value).must_equal 'zsh'
41
+ _(input_value.template_input.name).must_equal 'package'
42
42
 
43
- composer.targeting.search_query.must_equal "name ^ (#{host.name})"
43
+ _(composer.targeting.search_query).must_equal "name ^ (#{host.name})"
44
44
  end
45
45
 
46
46
  it 'updates the feature when attributes change' do
47
47
  updated_feature = RemoteExecutionFeature.register(install_feature.label, N_('Katello: Install package'),
48
- :description => 'New description',
49
- :provided_inputs => ['package', 'force'])
48
+ :description => 'New description',
49
+ :provided_inputs => ['package', 'force'])
50
50
  updated_feature.reload
51
- updated_feature.id.must_equal(install_feature.id)
52
- updated_feature.description.must_equal 'New description'
53
- updated_feature.provided_input_names.must_equal ['package', 'force']
51
+ _(updated_feature.id).must_equal(install_feature.id)
52
+ _(updated_feature.description).must_equal 'New description'
53
+ _(updated_feature.provided_input_names).must_equal ['package', 'force']
54
54
  end
55
55
  end
56
56
 
57
57
  describe '.register' do
58
58
  it "creates a feature if it's missing" do
59
59
  feature = RemoteExecutionFeature.register('new_feature_that_does_not_exist', 'name')
60
- feature.must_be :persisted?
61
- feature.label.must_equal 'new_feature_that_does_not_exist'
62
- feature.name.must_equal 'name'
60
+ _(feature).must_be :persisted?
61
+ _(feature.label).must_equal 'new_feature_that_does_not_exist'
62
+ _(feature.name).must_equal 'name'
63
63
  assert_not feature.host_action_button
64
64
  end
65
65
 
66
66
  it 'creates a feature with host action flag' do
67
67
  feature = RemoteExecutionFeature.register('new_feature_that_does_not_exist_button', 'name', :host_action_button => true)
68
- feature.must_be :persisted?
68
+ _(feature).must_be :persisted?
69
69
  assert feature.host_action_button
70
70
  end
71
71
 
@@ -78,7 +78,7 @@ class RemoteExecutionFeatureTest < ActiveSupport::TestCase
78
78
  it 'updates a feature if it exists' do
79
79
  existing = FactoryBot.create(:remote_execution_feature, :name => 'existing_feature_withou_action_button')
80
80
  feature = RemoteExecutionFeature.register(existing.label, existing.name, :host_action_button => true)
81
- feature.must_be :persisted?
81
+ _(feature).must_be :persisted?
82
82
  existing.reload
83
83
  assert existing.host_action_button
84
84
  end
@@ -3,23 +3,23 @@ require 'test_plugin_helper'
3
3
  class RemoteExecutionProviderTest < ActiveSupport::TestCase
4
4
  describe '.providers' do
5
5
  let(:providers) { RemoteExecutionProvider.providers }
6
- it { providers.must_be_kind_of HashWithIndifferentAccess }
6
+ it { _(providers).must_be_kind_of HashWithIndifferentAccess }
7
7
  it 'makes providers accessible using symbol' do
8
- providers[:SSH].must_equal SSHExecutionProvider
8
+ _(providers[:SSH]).must_equal SSHExecutionProvider
9
9
  end
10
10
  it 'makes providers accessible using string' do
11
- providers['SSH'].must_equal SSHExecutionProvider
11
+ _(providers['SSH']).must_equal SSHExecutionProvider
12
12
  end
13
13
  end
14
14
 
15
15
  describe '.register_provider' do
16
16
  before { RemoteExecutionProvider.providers.delete(:new) }
17
17
  let(:new_provider) { RemoteExecutionProvider.providers[:new] }
18
- it { new_provider.must_be_nil }
18
+ it { _(new_provider).must_be_nil }
19
19
 
20
20
  context 'registers a provider under key :new' do
21
21
  before { RemoteExecutionProvider.register(:new, String) }
22
- it { new_provider.must_equal String }
22
+ it { _(new_provider).must_equal String }
23
23
  end
24
24
  end
25
25
 
@@ -38,15 +38,15 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
38
38
 
39
39
  it 'returns only strings' do
40
40
  provider_names.each do |name|
41
- name.must_be_kind_of String
41
+ _(name).must_be_kind_of String
42
42
  end
43
43
  end
44
44
 
45
45
  context 'provider is registetered under :custom symbol' do
46
46
  before { RemoteExecutionProvider.register(:Custom, String) }
47
47
 
48
- it { provider_names.must_include 'SSH' }
49
- it { provider_names.must_include 'Custom' }
48
+ it { _(provider_names).must_include 'SSH' }
49
+ it { _(provider_names).must_include 'Custom' }
50
50
  end
51
51
  end
52
52
 
@@ -67,14 +67,14 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
67
67
  describe 'effective user' do
68
68
  it 'takes the effective user from value from the template invocation' do
69
69
  template_invocation.effective_user = 'my user'
70
- proxy_options[:effective_user].must_equal 'my user'
70
+ _(proxy_options[:effective_user]).must_equal 'my user'
71
71
  end
72
72
  end
73
73
 
74
74
  describe 'ssh user' do
75
75
  it 'uses the remote_execution_ssh_user on the host param' do
76
76
  host.host_parameters << FactoryBot.create(:host_parameter, :host => host, :name => 'remote_execution_ssh_user', :value => 'my user')
77
- proxy_options[:ssh_user].must_equal 'my user'
77
+ _(proxy_options[:ssh_user]).must_equal 'my user'
78
78
  end
79
79
  end
80
80
 
@@ -83,7 +83,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
83
83
  host.params['remote_execution_sudo_password'] = 'mypassword'
84
84
  host.host_parameters << FactoryBot.create(:host_parameter, :host => host, :name => 'remote_execution_sudo_password', :value => 'mypassword')
85
85
  assert_not proxy_options.key?(:sudo_password)
86
- secrets[:sudo_password].must_equal 'mypassword'
86
+ _(secrets[:sudo_password]).must_equal 'mypassword'
87
87
  end
88
88
  end
89
89
 
@@ -92,15 +92,15 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
92
92
  host.params['remote_execution_effective_user_method'] = 'sudo'
93
93
  method_param = FactoryBot.create(:host_parameter, :host => host, :name => 'remote_execution_effective_user_method', :value => 'sudo')
94
94
  host.host_parameters << method_param
95
- proxy_options[:effective_user_method].must_equal 'sudo'
96
- method_param.update_attributes!(:value => 'su')
95
+ _(proxy_options[:effective_user_method]).must_equal 'sudo'
96
+ method_param.update!(:value => 'su')
97
97
  host.clear_host_parameters_cache!
98
98
  proxy_options = SSHExecutionProvider.proxy_command_options(template_invocation, host)
99
- proxy_options[:effective_user_method].must_equal 'su'
100
- method_param.update_attributes!(:value => 'dzdo')
99
+ _(proxy_options[:effective_user_method]).must_equal 'su'
100
+ method_param.update!(:value => 'dzdo')
101
101
  host.clear_host_parameters_cache!
102
102
  proxy_options = SSHExecutionProvider.proxy_command_options(template_invocation, host)
103
- proxy_options[:effective_user_method].must_equal 'dzdo'
103
+ _(proxy_options[:effective_user_method]).must_equal 'dzdo'
104
104
  end
105
105
  end
106
106
 
@@ -110,8 +110,8 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
110
110
  end
111
111
 
112
112
  it 'has ssh port changed in settings and check return type' do
113
- proxy_options[:ssh_port].must_be_kind_of Integer
114
- proxy_options[:ssh_port].must_equal 66
113
+ _(proxy_options[:ssh_port]).must_be_kind_of Integer
114
+ _(proxy_options[:ssh_port]).must_equal 66
115
115
  end
116
116
  end
117
117
 
@@ -120,8 +120,8 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
120
120
  host.params['remote_execution_ssh_port'] = '30'
121
121
  host.host_parameters << FactoryBot.build(:host_parameter, :name => 'remote_execution_ssh_port', :value => '30')
122
122
  host.clear_host_parameters_cache!
123
- proxy_options[:ssh_port].must_be_kind_of Integer
124
- proxy_options[:ssh_port].must_equal 30
123
+ _(proxy_options[:ssh_port]).must_be_kind_of Integer
124
+ _(proxy_options[:ssh_port]).must_equal 30
125
125
  end
126
126
  end
127
127
 
@@ -131,7 +131,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
131
131
  end
132
132
 
133
133
  it 'updates the value via settings' do
134
- proxy_options[:cleanup_working_dirs].must_equal false
134
+ _(proxy_options[:cleanup_working_dirs]).must_equal false
135
135
  end
136
136
  end
137
137
 
@@ -140,7 +140,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
140
140
  host.params['remote_execution_cleanup_working_dirs'] = 'false'
141
141
  host.host_parameters << FactoryBot.build(:host_parameter, :name => 'remote_execution_cleanup_working_dirs', :value => 'false')
142
142
  host.clear_host_parameters_cache!
143
- proxy_options[:cleanup_working_dirs].must_equal false
143
+ _(proxy_options[:cleanup_working_dirs]).must_equal false
144
144
  end
145
145
  end
146
146
 
@@ -162,9 +162,9 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
162
162
 
163
163
  # execution wins if present
164
164
  execution_interface = FactoryBot.build(:nic_managed,
165
- flags.merge(:execution => true, :name => 'special.somedomain.org'))
165
+ flags.merge(:execution => true, :name => 'special.somedomain.org'))
166
166
  host.interfaces << execution_interface
167
- host.primary_interface.update_attributes(:execution => false)
167
+ host.primary_interface.update(:execution => false)
168
168
  host.interfaces.each(&:save)
169
169
  host.reload
170
170
  SSHExecutionProvider.find_ip_or_hostname(host).must_equal execution_interface.fqdn
@@ -177,23 +177,23 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
177
177
 
178
178
  # provision interface with ip while primary without
179
179
  provision_interface = FactoryBot.build(:nic_managed,
180
- flags.merge(:provision => true, :ip => '10.0.0.1'))
180
+ flags.merge(:provision => true, :ip => '10.0.0.1'))
181
181
  host.interfaces << provision_interface
182
- host.primary_interface.update_attributes(:provision => false)
182
+ host.primary_interface.update(:provision => false)
183
183
  host.interfaces.each(&:save)
184
184
  host.reload
185
185
  SSHExecutionProvider.find_ip_or_hostname(host).must_equal provision_interface.ip
186
186
 
187
187
  # both primary and provision interface have IPs: the primary wins
188
- host.primary_interface.update_attributes(:ip => '10.0.0.2', :execution => false)
188
+ host.primary_interface.update(:ip => '10.0.0.2', :execution => false)
189
189
  host.reload
190
190
  SSHExecutionProvider.find_ip_or_hostname(host).must_equal host.primary_interface.ip
191
191
 
192
192
  # there is an execution interface with IP: it wins
193
193
  execution_interface = FactoryBot.build(:nic_managed,
194
- flags.merge(:execution => true, :ip => '10.0.0.3'))
194
+ flags.merge(:execution => true, :ip => '10.0.0.3'))
195
195
  host.interfaces << execution_interface
196
- host.primary_interface.update_attributes(:execution => false)
196
+ host.primary_interface.update(:execution => false)
197
197
  host.interfaces.each(&:save)
198
198
  host.reload
199
199
  SSHExecutionProvider.find_ip_or_hostname(host).must_equal execution_interface.ip