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
@@ -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
+ assert_includes job_template.errors.full_messages.first, '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
+ assert_equal template_with_description.generate_description_format, 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
+ assert_equal minimal_template.generate_description_format, '%{template_name}'
48
48
  minimal_template.description_format = ''
49
- _(minimal_template.generate_description_format).must_equal '%{template_name}'
49
+ assert_equal minimal_template.generate_description_format, '%{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
+ assert_equal template.generate_description_format, expected_result
56
56
  template.description_format = ''
57
- _(template.generate_description_format).must_equal expected_result
57
+ assert_equal template.generate_description_format, 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
+ refute_equal duplicate, job_template
68
+ refute_empty duplicate.template_inputs
69
+ refute_equal duplicate.template_inputs.first, job_template.template_inputs.first
70
+ assert_equal duplicate.template_inputs.first.name, job_template.template_inputs.first.name
71
71
  end
72
72
  end
73
73
  end
@@ -120,30 +120,30 @@ class JobTemplateTest < ActiveSupport::TestCase
120
120
  end
121
121
 
122
122
  it 'sets the name' do
123
- _(template.name).must_equal 'Service Restart'
123
+ assert_equal template.name, 'Service Restart'
124
124
  end
125
125
 
126
126
  it 'has a template' do
127
- _(template.template.squish).must_equal 'service <%= input("service_name") %> restart <%# test comment %>'
127
+ assert_equal template.template.squish, 'service <%= input("service_name") %> restart <%# test comment %>'
128
128
  end
129
129
 
130
130
  it 'imports inputs' do
131
- _(template.template_inputs.first.name).must_equal 'service_name'
131
+ assert_equal template.template_inputs.first.name, 'service_name'
132
132
  end
133
133
 
134
134
  it 'imports input sets' do
135
- _(template_with_input_sets.foreign_input_sets.first.target_template).must_equal template
136
- _(template_with_input_sets.template_inputs_with_foreign.map(&:name)).must_equal ['service_name']
135
+ assert_equal template_with_input_sets.foreign_input_sets.first.target_template, template
136
+ assert_equal template_with_input_sets.template_inputs_with_foreign.map(&:name), ['service_name']
137
137
  end
138
138
 
139
139
  it 'imports feature' do
140
140
  template # let is lazy
141
141
  remote_execution_feature.reload
142
- _(remote_execution_feature.job_template).must_equal template
142
+ assert_equal remote_execution_feature.job_template, template
143
143
  end
144
144
 
145
145
  it 'sets additional options' do
146
- _(template.default).must_equal true
146
+ assert_equal template.default, true
147
147
  end
148
148
  end
149
149
 
@@ -226,16 +226,16 @@ class JobTemplateTest < ActiveSupport::TestCase
226
226
 
227
227
  it 'syncs inputs' do
228
228
  hostname = synced_template.template_inputs.find { |input| input.name == 'hostname' }
229
- _(hostname.options).must_equal 'www.redhat.com'
229
+ assert_equal hostname.options, 'www.redhat.com'
230
230
  end
231
231
 
232
232
  it 'syncs content' do
233
- _(synced_template.template).must_match(/ping -c <%= input\('count'\) %> <%= input\('hostname'\) %>/m)
233
+ assert_match(/ping -c <%= input\('count'\) %> <%= input\('hostname'\) %>/m, synced_template.template)
234
234
  end
235
235
 
236
236
  it 'syncs input sets' do
237
- _(synced_template.foreign_input_sets.first.target_template).must_equal included
238
- _(synced_template.template_inputs_with_foreign.map(&:name)).must_equal ['hostname', 'count']
237
+ assert_equal synced_template.foreign_input_sets.first.target_template, included
238
+ assert_equal synced_template.template_inputs_with_foreign.map(&:name), ['hostname', 'count']
239
239
  end
240
240
  end
241
241
 
@@ -249,15 +249,15 @@ class JobTemplateTest < ActiveSupport::TestCase
249
249
  end
250
250
 
251
251
  it 'exports name' do
252
- _(erb).must_match(/^name: #{exportable_template.name}$/)
252
+ assert_match(/^name: #{exportable_template.name}$/, erb)
253
253
  end
254
254
 
255
255
  it 'includes template inputs' do
256
- _(erb).must_match(/^template_inputs:$/)
256
+ assert_match(/^template_inputs:$/, erb)
257
257
  end
258
258
 
259
259
  it 'includes template contents' do
260
- _(erb).must_include exportable_template.template
260
+ assert_includes erb, exportable_template.template
261
261
  end
262
262
 
263
263
  it 'is importable' do
@@ -266,8 +266,8 @@ class JobTemplateTest < ActiveSupport::TestCase
266
266
  exportable_template.update(:name => "#{old_name}_renamed")
267
267
 
268
268
  imported = JobTemplate.import_raw!(erb)
269
- _(imported.name).must_equal old_name
270
- _(imported.template_inputs.first.to_export).must_equal exportable_template.template_inputs.first.to_export
269
+ assert_equal imported.name, old_name
270
+ assert_equal imported.template_inputs.first.to_export, exportable_template.template_inputs.first.to_export
271
271
  end
272
272
 
273
273
  it 'has taxonomies in metadata' do
@@ -282,7 +282,7 @@ class JobTemplateTest < ActiveSupport::TestCase
282
282
 
283
283
  describe 'job template deletion' do
284
284
  it 'succeeds' do
285
- _(job_template.pattern_template_invocations).wont_be_empty
285
+ refute_empty job_template.pattern_template_invocations
286
286
  assert job_template.destroy
287
287
  end
288
288
  end
@@ -310,7 +310,7 @@ class JobTemplateTest < ActiveSupport::TestCase
310
310
  template_invocation.host,
311
311
  template_invocation
312
312
  result = renderer.render
313
- _(result).must_equal "<wrap>#{inner.template}</wrap>"
313
+ assert_equal result, "<wrap>#{inner.template}</wrap>"
314
314
  end
315
315
  end
316
316
  end
@@ -31,16 +31,16 @@ class RemoteExecutionFeatureTest < ActiveSupport::TestCase
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
+ assert_equal 1, composer.pattern_template_invocations.size
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
+ assert_equal package_template, template_invocation.template
37
+ assert_equal 1, template_invocation.input_values.size
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
+ assert_equal 'zsh', input_value.value
41
+ assert_equal 'package', input_value.template_input.name
42
42
 
43
- _(composer.targeting.search_query).must_equal "name ^ (#{host.name})"
43
+ assert_equal "name ^ (#{host.name})", composer.targeting.search_query
44
44
  end
45
45
 
46
46
  it 'updates the feature when attributes change' do
@@ -48,24 +48,24 @@ class RemoteExecutionFeatureTest < ActiveSupport::TestCase
48
48
  :description => 'New description',
49
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
+ assert_equal install_feature.id, updated_feature.id
52
+ assert_equal 'New description', updated_feature.description
53
+ assert_equal ['package', 'force'], updated_feature.provided_input_names
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
+ assert_predicate feature, :persisted?
61
+ assert_equal 'new_feature_that_does_not_exist', feature.label
62
+ assert_equal 'name', feature.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
+ assert_predicate feature, :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
+ assert_predicate feature, :persisted?
82
82
  existing.reload
83
83
  assert existing.host_action_button
84
84
  end
@@ -3,39 +3,39 @@ 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 { assert_kind_of HashWithIndifferentAccess, providers }
7
7
  it 'makes providers accessible using symbol' do
8
- _(providers[:SSH]).must_equal SSHExecutionProvider
9
- _(providers[:script]).must_equal ScriptExecutionProvider
8
+ assert_equal SSHExecutionProvider, providers[:SSH]
9
+ assert_equal ScriptExecutionProvider, providers[:script]
10
10
  end
11
11
  it 'makes providers accessible using string' do
12
- _(providers['SSH']).must_equal SSHExecutionProvider
13
- _(providers['script']).must_equal ScriptExecutionProvider
12
+ assert_equal SSHExecutionProvider, providers['SSH']
13
+ assert_equal ScriptExecutionProvider, providers['script']
14
14
  end
15
15
  end
16
16
 
17
17
  describe '.register_provider' do
18
18
  before { RemoteExecutionProvider.providers.delete(:new) }
19
19
  let(:new_provider) { RemoteExecutionProvider.providers[:new] }
20
- it { _(new_provider).must_be_nil }
20
+ it { assert_nil new_provider }
21
21
 
22
22
  context 'registers a provider under key :new' do
23
23
  before { RemoteExecutionProvider.register(:new, String) }
24
- it { _(new_provider).must_equal String }
24
+ it { assert_equal String, new_provider }
25
25
  end
26
26
  end
27
27
 
28
28
  describe '.provider_for' do
29
29
  it 'accepts symbols' do
30
- RemoteExecutionProvider.provider_for(:SSH).must_equal SSHExecutionProvider
30
+ assert_equal SSHExecutionProvider, RemoteExecutionProvider.provider_for(:SSH)
31
31
  end
32
32
 
33
33
  it 'accepts strings' do
34
- RemoteExecutionProvider.provider_for('SSH').must_equal SSHExecutionProvider
34
+ assert_equal SSHExecutionProvider, RemoteExecutionProvider.provider_for('SSH')
35
35
  end
36
36
 
37
37
  it 'returns a default one if unknown value is provided' do
38
- RemoteExecutionProvider.provider_for('WinRM').must_equal ScriptExecutionProvider
38
+ assert_equal ScriptExecutionProvider, RemoteExecutionProvider.provider_for('WinRM')
39
39
  end
40
40
  end
41
41
 
@@ -44,15 +44,15 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
44
44
 
45
45
  it 'returns only strings' do
46
46
  provider_names.each do |name|
47
- _(name).must_be_kind_of String
47
+ assert_kind_of String, name
48
48
  end
49
49
  end
50
50
 
51
51
  context 'provider is registetered under :custom symbol' do
52
52
  before { RemoteExecutionProvider.register(:Custom, String) }
53
53
 
54
- it { _(provider_names).must_include 'SSH' }
55
- it { _(provider_names).must_include 'Custom' }
54
+ it { assert_includes provider_names, 'SSH' }
55
+ it { assert_includes provider_names, 'Custom' }
56
56
  end
57
57
  end
58
58
 
@@ -71,7 +71,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
71
71
  ::RemoteExecutionProvider.register('custom', CustomProvider)
72
72
 
73
73
  feature = CustomProvider.proxy_feature
74
- _(feature).must_equal 'custom'
74
+ assert_equal 'custom', feature
75
75
  ensure
76
76
  ::RemoteExecutionProvider = old
77
77
  end
@@ -86,8 +86,8 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
86
86
  )
87
87
 
88
88
  features = RemoteExecutionProvider.provider_proxy_features
89
- _(features).must_include 'SSH'
90
- _(features).must_include 'Script'
89
+ assert_includes features, 'SSH'
90
+ assert_includes features, 'Script'
91
91
  RemoteExecutionProvider.unstub(:providers)
92
92
  end
93
93
 
@@ -95,7 +95,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
95
95
  provider = OpenStruct.new(proxy_feature: 'Testing')
96
96
  RemoteExecutionProvider.stubs(:providers).returns(:testing => provider)
97
97
  features = RemoteExecutionProvider.provider_proxy_features
98
- _(features).must_include 'Testing'
98
+ assert_includes features, 'Testing'
99
99
  RemoteExecutionProvider.unstub(:providers)
100
100
  end
101
101
  end
@@ -125,14 +125,14 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
125
125
  describe 'effective user' do
126
126
  it 'takes the effective user from value from the template invocation' do
127
127
  template_invocation.effective_user = 'my user'
128
- _(proxy_options[:effective_user]).must_equal 'my user'
128
+ assert_equal 'my user', proxy_options[:effective_user]
129
129
  end
130
130
  end
131
131
 
132
132
  describe 'ssh user' do
133
133
  it 'uses the remote_execution_ssh_user on the host param' do
134
134
  host.host_parameters << FactoryBot.create(:host_parameter, :host => host, :name => 'remote_execution_ssh_user', :value => 'my user')
135
- _(proxy_options[:ssh_user]).must_equal 'my user'
135
+ assert_equal 'my user', proxy_options[:ssh_user]
136
136
  end
137
137
  end
138
138
 
@@ -140,8 +140,8 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
140
140
  it 'uses the remote_execution_effective_user_password on the host param' do
141
141
  host.params['remote_execution_effective_user_password'] = 'mypassword'
142
142
  host.host_parameters << FactoryBot.create(:host_parameter, :host => host, :name => 'remote_execution_effective_user_password', :value => 'mypassword')
143
- assert_not proxy_options.key?(:effective_user_password)
144
- _(secrets[:effective_user_password]).must_equal 'mypassword'
143
+ assert_nil proxy_options[:effective_user_password]
144
+ assert_equal 'mypassword', secrets[:effective_user_password]
145
145
  end
146
146
  end
147
147
 
@@ -150,15 +150,15 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
150
150
  host.params['remote_execution_effective_user_method'] = 'sudo'
151
151
  method_param = FactoryBot.create(:host_parameter, :host => host, :name => 'remote_execution_effective_user_method', :value => 'sudo')
152
152
  host.host_parameters << method_param
153
- _(proxy_options[:effective_user_method]).must_equal 'sudo'
153
+ assert_equal 'sudo', proxy_options[:effective_user_method]
154
154
  method_param.update!(:value => 'su')
155
155
  host.clear_host_parameters_cache!
156
156
  proxy_options = SSHExecutionProvider.proxy_command_options(template_invocation, host)
157
- _(proxy_options[:effective_user_method]).must_equal 'su'
157
+ assert_equal 'su', proxy_options[:effective_user_method]
158
158
  method_param.update!(:value => 'dzdo')
159
159
  host.clear_host_parameters_cache!
160
160
  proxy_options = SSHExecutionProvider.proxy_command_options(template_invocation, host)
161
- _(proxy_options[:effective_user_method]).must_equal 'dzdo'
161
+ assert_equal 'dzdo', proxy_options[:effective_user_method]
162
162
  end
163
163
  end
164
164
 
@@ -168,8 +168,8 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
168
168
  end
169
169
 
170
170
  it 'has ssh port changed in settings and check return type' do
171
- _(proxy_options[:ssh_port]).must_be_kind_of Integer
172
- _(proxy_options[:ssh_port]).must_equal 66
171
+ assert_kind_of Integer, proxy_options[:ssh_port]
172
+ assert_equal 66, proxy_options[:ssh_port]
173
173
  end
174
174
  end
175
175
 
@@ -178,8 +178,8 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
178
178
  host.params['remote_execution_ssh_port'] = '30'
179
179
  host.host_parameters << FactoryBot.build(:host_parameter, :name => 'remote_execution_ssh_port', :value => '30')
180
180
  host.clear_host_parameters_cache!
181
- _(proxy_options[:ssh_port]).must_be_kind_of Integer
182
- _(proxy_options[:ssh_port]).must_equal 30
181
+ assert_kind_of Integer, proxy_options[:ssh_port]
182
+ assert_equal 30, proxy_options[:ssh_port]
183
183
  end
184
184
  end
185
185
 
@@ -189,7 +189,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
189
189
  end
190
190
 
191
191
  it 'updates the value via settings' do
192
- _(proxy_options[:cleanup_working_dirs]).must_equal false
192
+ refute proxy_options[:cleanup_working_dirs]
193
193
  end
194
194
  end
195
195
 
@@ -198,7 +198,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
198
198
  host.params['remote_execution_cleanup_working_dirs'] = 'false'
199
199
  host.host_parameters << FactoryBot.build(:host_parameter, :name => 'remote_execution_cleanup_working_dirs', :value => 'false')
200
200
  host.clear_host_parameters_cache!
201
- _(proxy_options[:cleanup_working_dirs]).must_equal false
201
+ refute proxy_options[:cleanup_working_dirs]
202
202
  end
203
203
  end
204
204
 
@@ -219,7 +219,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
219
219
 
220
220
  it 'gets fqdn from flagged interfaces if not preferring ips' do
221
221
  # falling to primary interface
222
- SSHExecutionProvider.find_ip_or_hostname(host).must_equal 'somehost.somedomain.org'
222
+ assert_equal 'somehost.somedomain.org', SSHExecutionProvider.find_ip_or_hostname(host)
223
223
 
224
224
  # execution wins if present
225
225
  execution_interface = FactoryBot.build(:nic_managed,
@@ -228,13 +228,13 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
228
228
  host.primary_interface.update(:execution => false)
229
229
  host.interfaces.each(&:save)
230
230
  host.reload
231
- SSHExecutionProvider.find_ip_or_hostname(host).must_equal execution_interface.fqdn
231
+ assert_equal execution_interface.fqdn, SSHExecutionProvider.find_ip_or_hostname(host)
232
232
  end
233
233
 
234
234
  it 'gets ip from flagged interfaces' do
235
235
  host.host_params['remote_execution_connect_by_ip'] = true
236
236
  # no ip address set on relevant interface - fallback to fqdn
237
- SSHExecutionProvider.find_ip_or_hostname(host).must_equal 'somehost.somedomain.org'
237
+ assert_equal 'somehost.somedomain.org', SSHExecutionProvider.find_ip_or_hostname(host)
238
238
 
239
239
  # provision interface with ip while primary without
240
240
  provision_interface = FactoryBot.build(:nic_managed,
@@ -243,12 +243,12 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
243
243
  host.primary_interface.update(:provision => false)
244
244
  host.interfaces.each(&:save)
245
245
  host.reload
246
- SSHExecutionProvider.find_ip_or_hostname(host).must_equal provision_interface.ip
246
+ assert_equal provision_interface.ip, SSHExecutionProvider.find_ip_or_hostname(host)
247
247
 
248
248
  # both primary and provision interface have IPs: the primary wins
249
249
  host.primary_interface.update(:ip => '10.0.0.2', :execution => false)
250
250
  host.reload
251
- SSHExecutionProvider.find_ip_or_hostname(host).must_equal host.primary_interface.ip
251
+ assert_equal host.primary_interface.ip, SSHExecutionProvider.find_ip_or_hostname(host)
252
252
 
253
253
  # there is an execution interface with IP: it wins
254
254
  execution_interface = FactoryBot.build(:nic_managed,
@@ -257,7 +257,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
257
257
  host.primary_interface.update(:execution => false)
258
258
  host.interfaces.each(&:save)
259
259
  host.reload
260
- SSHExecutionProvider.find_ip_or_hostname(host).must_equal execution_interface.ip
260
+ assert_equal execution_interface.ip, SSHExecutionProvider.find_ip_or_hostname(host)
261
261
 
262
262
  # there is an execution interface with both IPv6 and IPv4: IPv4 is being preferred over IPv6 by default
263
263
  execution_interface = FactoryBot.build(:nic_managed,
@@ -265,7 +265,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
265
265
  host.interfaces = [execution_interface]
266
266
  host.interfaces.each(&:save)
267
267
  host.reload
268
- SSHExecutionProvider.find_ip_or_hostname(host).must_equal execution_interface.ip
268
+ assert_equal execution_interface.ip, SSHExecutionProvider.find_ip_or_hostname(host)
269
269
  end
270
270
 
271
271
  it 'gets ipv6 from flagged interfaces with IPv6 preference' do
@@ -278,7 +278,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
278
278
  host.interfaces = [execution_interface]
279
279
  host.interfaces.each(&:save)
280
280
  host.reload
281
- SSHExecutionProvider.find_ip_or_hostname(host).must_equal execution_interface.ip6
281
+ assert_equal execution_interface.ip6, SSHExecutionProvider.find_ip_or_hostname(host)
282
282
  end
283
283
 
284
284
  it 'gets ipv6 from flagged interfaces with IPv4 preference but without IPv4 address' do
@@ -291,7 +291,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
291
291
  host.interfaces = [execution_interface]
292
292
  host.interfaces.each(&:save)
293
293
  host.reload
294
- SSHExecutionProvider.find_ip_or_hostname(host).must_equal execution_interface.ip6
294
+ assert_equal execution_interface.ip6, SSHExecutionProvider.find_ip_or_hostname(host)
295
295
  end
296
296
  end
297
297
  end
@@ -13,15 +13,15 @@ class RendererScopeInputTest < ActiveSupport::TestCase
13
13
  it 'caches the value under given key' do
14
14
  i = 1
15
15
  result = input.cached('some_key') { i }
16
- _(result).must_equal 1
16
+ assert_equal 1, result
17
17
 
18
18
  i += 1
19
19
  result = input.cached('some_key') { i }
20
- _(result).must_equal 1
20
+ assert_equal 1, result
21
21
 
22
22
  i += 1
23
23
  result = input.cached('different_key') { i }
24
- _(result).must_equal 3
24
+ assert_equal 3, result
25
25
  end
26
26
  end
27
27
 
@@ -35,15 +35,15 @@ class RendererScopeInputTest < ActiveSupport::TestCase
35
35
  it 'does not cache the value' do
36
36
  i = 1
37
37
  result = input.cached('some_key') { i }
38
- _(result).must_equal 1
38
+ assert_equal 1, result
39
39
 
40
40
  i += 1
41
41
  result = input.cached('some_key') { i }
42
- _(result).must_equal 2
42
+ assert_equal 2, result
43
43
 
44
44
  i += 1
45
45
  result = input.cached('different_key') { i }
46
- _(result).must_equal 3
46
+ assert_equal 3, result
47
47
  end
48
48
  end
49
49
  end
@@ -51,7 +51,7 @@ class TargetingTest < ActiveSupport::TestCase
51
51
  targeting.resolve_hosts!
52
52
  end
53
53
 
54
- it { _(targeting.hosts).must_include(host) }
54
+ it { assert_includes targeting.hosts, host }
55
55
  end
56
56
 
57
57
  context 'can delete a user' do
@@ -63,7 +63,7 @@ class TargetingTest < ActiveSupport::TestCase
63
63
 
64
64
  it { assert_nil targeting.reload.user }
65
65
  it do
66
- -> { targeting.resolve_hosts! }.must_raise(Foreman::Exception)
66
+ assert_raises(Foreman::Exception) { targeting.resolve_hosts! }
67
67
  end
68
68
  end
69
69
 
@@ -74,7 +74,7 @@ class TargetingTest < ActiveSupport::TestCase
74
74
  host.destroy
75
75
  end
76
76
 
77
- it { _(targeting.reload.hosts).must_be_empty }
77
+ it { assert_empty targeting.reload.hosts }
78
78
  end
79
79
 
80
80
  describe '#resolve_hosts!' do
@@ -100,9 +100,9 @@ class TargetingTest < ActiveSupport::TestCase
100
100
  targeting.user = User.current
101
101
  targeting.resolve_hosts!
102
102
 
103
- targeting.hosts.must_include host
104
- targeting.hosts.must_include second_host
105
- targeting.hosts.must_include infra_host
103
+ assert_includes targeting.hosts, host
104
+ assert_includes targeting.hosts, second_host
105
+ assert_includes targeting.hosts, infra_host
106
106
  end
107
107
  end
108
108
 
@@ -115,9 +115,9 @@ class TargetingTest < ActiveSupport::TestCase
115
115
  targeting.user = User.current
116
116
  targeting.resolve_hosts!
117
117
 
118
- targeting.hosts.must_include host
119
- targeting.hosts.must_include second_host
120
- targeting.hosts.wont_include infra_host
118
+ assert_includes targeting.hosts, host
119
+ assert_includes targeting.hosts, second_host
120
+ refute_includes targeting.hosts, infra_host
121
121
  end
122
122
  end
123
123
  end
@@ -136,14 +136,14 @@ class TargetingTest < ActiveSupport::TestCase
136
136
  let(:query) { Targeting.build_query_from_hosts([ host.id, second_host.id, infra_host.id ]) }
137
137
 
138
138
  it 'builds query using host names joining inside ^' do
139
- _(query).must_include host.name
140
- _(query).must_include second_host.name
141
- _(query).must_include infra_host.name
142
- _(query).must_include 'name ^'
143
-
144
- Host.search_for(query).must_include host
145
- Host.search_for(query).must_include second_host
146
- Host.search_for(query).must_include infra_host
139
+ assert_includes query, host.name
140
+ assert_includes query, second_host.name
141
+ assert_includes query, infra_host.name
142
+ assert_includes query, 'name ^'
143
+
144
+ assert_includes Host.search_for(query), host
145
+ assert_includes Host.search_for(query), second_host
146
+ assert_includes Host.search_for(query), infra_host
147
147
  end
148
148
  end
149
149
 
@@ -151,10 +151,10 @@ class TargetingTest < ActiveSupport::TestCase
151
151
  let(:query) { Targeting.build_query_from_hosts([ host.id ]) }
152
152
 
153
153
  it 'builds query using host name' do
154
- _(query).must_equal "name ^ (#{host.name})"
155
- Host.search_for(query).must_include host
156
- Host.search_for(query).wont_include second_host
157
- Host.search_for(query).wont_include infra_host
154
+ assert_equal "name ^ (#{host.name})", query
155
+ assert_includes Host.search_for(query), host
156
+ refute_includes Host.search_for(query), second_host
157
+ refute_includes Host.search_for(query), infra_host
158
158
  end
159
159
  end
160
160
 
@@ -162,9 +162,9 @@ class TargetingTest < ActiveSupport::TestCase
162
162
  let(:query) { Targeting.build_query_from_hosts([]) }
163
163
 
164
164
  it 'builds query to find all hosts' do
165
- Host.search_for(query).must_include host
166
- Host.search_for(query).must_include second_host
167
- Host.search_for(query).must_include infra_host
165
+ assert_includes Host.search_for(query), host
166
+ assert_includes Host.search_for(query), second_host
167
+ assert_includes Host.search_for(query), infra_host
168
168
  end
169
169
  end
170
170
 
@@ -173,14 +173,14 @@ class TargetingTest < ActiveSupport::TestCase
173
173
 
174
174
  it 'ignores the infrastructure host' do
175
175
  query = Targeting.build_query_from_hosts([host.id, second_host.id, infra_host.id])
176
- _(query).must_include host.name
177
- _(query).must_include second_host.name
178
- _(query).wont_include infra_host.name
179
- _(query).must_include 'name ^'
180
-
181
- Host.search_for(query).must_include host
182
- Host.search_for(query).must_include second_host
183
- Host.search_for(query).wont_include infra_host
176
+ assert_includes query, host.name
177
+ assert_includes query, second_host.name
178
+ refute_includes query, infra_host.name
179
+ assert_includes query, 'name ^'
180
+
181
+ assert_includes Host.search_for(query), host
182
+ assert_includes Host.search_for(query), second_host
183
+ refute_includes Host.search_for(query), infra_host
184
184
  end
185
185
  end
186
186
  end
@@ -5,6 +5,10 @@ export const JOB_TEMPLATES = 'JOB_TEMPLATES';
5
5
  export const JOB_CATEGORIES = 'JOB_CATEGORIES';
6
6
  export const JOB_TEMPLATE = 'JOB_TEMPLATE';
7
7
  export const JOB_INVOCATION = 'JOB_INVOCATION';
8
+ export const CURRENT_PERMISSIONS = 'CURRENT_PERMISSIONS';
9
+ export const currentPermissionsUrl = foremanUrl(
10
+ '/api/v2/permissions/current_permissions'
11
+ );
8
12
  export const templatesUrl = foremanUrl('/api/v2/job_templates');
9
13
 
10
14
  export const repeatTypes = {