foreman_remote_execution 12.0.5 → 13.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc +4 -1
- data/.github/workflows/js_ci.yml +1 -1
- data/.github/workflows/release.yml +4 -2
- data/.github/workflows/ruby_ci.yml +16 -81
- data/.packit.yaml +8 -3
- data/app/assets/javascripts/foreman_remote_execution/locale/de/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/en/foreman_remote_execution.js +22 -4
- data/app/assets/javascripts/foreman_remote_execution/locale/en_GB/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/es/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/fr/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/ja/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/ka/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/ko/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/pt_BR/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/ru/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/zh_CN/foreman_remote_execution.js +23 -14
- data/app/assets/javascripts/foreman_remote_execution/locale/zh_TW/foreman_remote_execution.js +23 -14
- data/app/controllers/ui_job_wizard_controller.rb +1 -1
- data/app/helpers/job_invocations_helper.rb +1 -1
- data/app/helpers/remote_execution_helper.rb +2 -2
- data/app/lib/actions/remote_execution/proxy_action.rb +1 -1
- data/app/lib/actions/remote_execution/run_host_job.rb +9 -17
- data/app/models/concerns/foreman_remote_execution/host_extensions.rb +8 -0
- data/app/models/host_status/execution_status.rb +2 -2
- data/app/models/job_invocation_composer.rb +4 -3
- data/app/views/api/v2/job_invocations/base.json.rabl +5 -3
- data/app/views/job_invocations/_preview_hosts_list.html.erb +1 -1
- data/app/views/job_invocations/show.html.erb +12 -5
- data/app/views/job_invocations/show.js.erb +8 -1
- data/app/views/job_invocations/welcome.html.erb +1 -1
- data/app/views/template_invocations/_refresh.js.erb +10 -4
- data/app/views/template_invocations/show.html.erb +2 -2
- data/app/views/templates/script/convert2rhel_analyze.erb +1 -12
- data/app/views/templates/script/package_action.erb +11 -1
- data/app/views/templates/script/puppet_run_once.erb +3 -3
- data/lib/foreman_remote_execution/engine.rb +1 -1
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/locale/de/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/de/foreman_remote_execution.po +24 -6
- data/locale/en/foreman_remote_execution.po +24 -6
- data/locale/en_GB/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/en_GB/foreman_remote_execution.po +24 -6
- data/locale/es/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/es/foreman_remote_execution.po +24 -6
- data/locale/foreman_remote_execution.pot +170 -142
- data/locale/fr/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/fr/foreman_remote_execution.po +24 -6
- data/locale/ja/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ja/foreman_remote_execution.po +24 -6
- data/locale/ka/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ka/foreman_remote_execution.po +24 -6
- data/locale/ko/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ko/foreman_remote_execution.po +24 -6
- data/locale/pt_BR/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/pt_BR/foreman_remote_execution.po +24 -6
- data/locale/ru/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ru/foreman_remote_execution.po +24 -6
- data/locale/zh_CN/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/zh_CN/foreman_remote_execution.po +24 -6
- data/locale/zh_TW/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/zh_TW/foreman_remote_execution.po +24 -6
- data/package.json +7 -11
- data/test/functional/api/v2/job_invocations_controller_test.rb +7 -7
- data/test/functional/api/v2/template_invocations_controller_test.rb +3 -3
- data/test/helpers/remote_execution_helper_test.rb +8 -7
- data/test/unit/actions/run_host_job_test.rb +1 -1
- data/test/unit/actions/run_hosts_job_test.rb +11 -11
- data/test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb +5 -5
- data/test/unit/concerns/host_extensions_test.rb +34 -34
- data/test/unit/concerns/nic_extensions_test.rb +1 -1
- data/test/unit/execution_task_status_mapper_test.rb +10 -10
- data/test/unit/input_template_renderer_test.rb +53 -49
- data/test/unit/job_invocation_composer_test.rb +109 -81
- data/test/unit/job_invocation_test.rb +25 -25
- data/test/unit/job_template_effective_user_test.rb +3 -3
- data/test/unit/job_template_test.rb +28 -28
- data/test/unit/remote_execution_feature_test.rb +14 -14
- data/test/unit/remote_execution_provider_test.rb +39 -39
- data/test/unit/renderer_scope_input_test.rb +6 -6
- data/test/unit/targeting_test.rb +32 -32
- data/webpack/JobInvocationDetail/JobInvocationConstants.js +10 -0
- data/webpack/JobInvocationDetail/JobInvocationDetail.scss +38 -0
- data/webpack/JobInvocationDetail/JobInvocationOverview.js +13 -25
- data/webpack/JobInvocationDetail/JobInvocationSystemStatusChart.js +153 -0
- data/webpack/JobInvocationDetail/index.js +48 -10
- data/webpack/JobWizard/Footer.js +5 -1
- data/webpack/JobWizard/JobWizardConstants.js +4 -0
- data/webpack/JobWizard/JobWizardPageRerun.js +3 -0
- data/webpack/JobWizard/JobWizardSelectors.js +31 -3
- data/webpack/JobWizard/PermissionDenied.js +64 -0
- data/webpack/JobWizard/StartsBeforeErrorAlert.js +1 -0
- data/webpack/JobWizard/__tests__/fixtures.js +3 -3
- data/webpack/JobWizard/autofill.js +8 -4
- data/webpack/JobWizard/index.js +41 -1
- data/webpack/JobWizard/steps/AdvancedFields/DescriptionField.js +8 -1
- data/webpack/JobWizard/steps/AdvancedFields/Fields.js +7 -0
- data/webpack/JobWizard/steps/CategoryAndTemplate/CategoryAndTemplate.js +41 -7
- data/webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js +7 -3
- data/webpack/JobWizard/steps/HostsAndInputs/SelectGQL.js +1 -0
- data/webpack/JobWizard/steps/HostsAndInputs/SelectedChips.js +21 -7
- data/webpack/JobWizard/steps/HostsAndInputs/hosts.gql +1 -0
- data/webpack/JobWizard/steps/HostsAndInputs/index.js +27 -2
- data/webpack/JobWizard/steps/ReviewDetails/index.js +7 -2
- data/webpack/JobWizard/steps/Schedule/PurposeField.js +1 -0
- data/webpack/JobWizard/steps/Schedule/QueryType.js +2 -0
- data/webpack/JobWizard/steps/Schedule/RepeatCron.js +1 -0
- data/webpack/JobWizard/steps/Schedule/RepeatHour.js +2 -0
- data/webpack/JobWizard/steps/Schedule/RepeatMonth.js +1 -0
- data/webpack/JobWizard/steps/Schedule/RepeatWeek.js +1 -0
- data/webpack/JobWizard/steps/Schedule/ScheduleFuture.js +2 -0
- data/webpack/JobWizard/steps/Schedule/ScheduleRecurring.js +6 -0
- data/webpack/JobWizard/steps/Schedule/ScheduleType.js +3 -0
- data/webpack/JobWizard/steps/form/FormHelpers.js +1 -0
- data/webpack/JobWizard/steps/form/GroupedSelectField.js +1 -0
- data/webpack/JobWizard/steps/form/NumberInput.js +1 -0
- data/webpack/JobWizard/steps/form/ResourceSelect.js +1 -0
- data/webpack/JobWizard/steps/form/SearchSelect.js +4 -1
- data/webpack/JobWizard/steps/form/SelectField.js +1 -0
- data/webpack/JobWizard/steps/form/WizardTitle.js +6 -1
- data/webpack/JobWizard/steps/form/__tests__/SelectSearch.test.js +2 -0
- data/webpack/__mocks__/foremanReact/routes/Hosts/constants.js +1 -0
- data/webpack/react_app/components/FeaturesDropdown/index.js +1 -0
- data/webpack/react_app/components/RecentJobsCard/RecentJobsCard.js +3 -0
- data/webpack/react_app/components/RecentJobsCard/RecentJobsTable.js +2 -1
- data/webpack/react_app/components/RegistrationExtension/RexInterface.js +1 -0
- data/webpack/react_app/components/RegistrationExtension/RexPull.js +1 -0
- data/webpack/react_app/components/RegistrationExtension/__tests__/__snapshots__/RexInterface.test.js.snap +1 -0
- metadata +10 -6
@@ -11,12 +11,12 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
11
11
|
|
12
12
|
it 'is able to perform search through job invocations' do
|
13
13
|
found_jobs = JobInvocation.search_for(%{job_category = "#{job_invocation.job_category}"}).paginate(:page => 1).order('job_invocations.id DESC')
|
14
|
-
|
14
|
+
assert_equal [job_invocation], found_jobs
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'is able to auto complete description' do
|
18
18
|
expected = 'description = "A text with \"quotes\""'
|
19
|
-
JobInvocation.complete_for('description = ')
|
19
|
+
assert_equal [expected], JobInvocation.complete_for('description = ')
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -40,7 +40,7 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
40
40
|
job_invocation.save!
|
41
41
|
host.destroy
|
42
42
|
job_invocation.reload
|
43
|
-
|
43
|
+
assert_empty job_invocation.template_invocations
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -85,13 +85,13 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
85
85
|
it 'generates description from input values' do
|
86
86
|
job_invocation.description_format = '%{job_category} - %{foo}'
|
87
87
|
job_invocation.generate_description
|
88
|
-
|
88
|
+
assert_equal "#{job_invocation.job_category} - #{@input_value.value}", job_invocation.description
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'handles missing keys correctly' do
|
92
92
|
job_invocation.description_format = '%{job_category} - %{missing_key}'
|
93
93
|
job_invocation.generate_description
|
94
|
-
|
94
|
+
assert_equal "#{job_invocation.job_category} - ''", job_invocation.description
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'truncates generated description to 255 characters' do
|
@@ -100,22 +100,22 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
100
100
|
job_invocation.description_format = '%{job_category}'
|
101
101
|
job_invocation.job_category = 'a' * 1000
|
102
102
|
job_invocation.generate_description
|
103
|
-
|
103
|
+
assert_equal expected_result, job_invocation.description
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
108
|
context 'future execution' do
|
109
109
|
it 'can report host count' do
|
110
|
-
|
110
|
+
assert_equal 'N/A', job_invocation.total_hosts_count
|
111
111
|
job_invocation.targeting.expects(:resolved_at).returns(Time.now.getlocal)
|
112
|
-
|
112
|
+
assert_equal 0, job_invocation.total_hosts_count
|
113
113
|
end
|
114
114
|
|
115
115
|
# task does not exist
|
116
|
-
specify {
|
117
|
-
specify {
|
118
|
-
specify {
|
116
|
+
specify { assert_equal HostStatus::ExecutionStatus::QUEUED, job_invocation.status }
|
117
|
+
specify { assert_equal HostStatus::ExecutionStatus::STATUS_NAMES[HostStatus::ExecutionStatus::QUEUED], job_invocation.status_label }
|
118
|
+
specify { assert_equal 0, job_invocation.progress }
|
119
119
|
end
|
120
120
|
|
121
121
|
context 'with task' do
|
@@ -138,10 +138,10 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
138
138
|
context 'which is scheduled' do
|
139
139
|
before { task.state = 'scheduled' }
|
140
140
|
|
141
|
-
specify {
|
142
|
-
specify {
|
143
|
-
specify {
|
144
|
-
specify {
|
141
|
+
specify { assert_equal HostStatus::ExecutionStatus::QUEUED, job_invocation.status }
|
142
|
+
specify { assert job_invocation.queued? }
|
143
|
+
specify { assert_equal 0, job_invocation.progress }
|
144
|
+
specify { assert_equal progress_report_without_sub_tasks, job_invocation.progress_report }
|
145
145
|
end
|
146
146
|
|
147
147
|
context 'with cancelled task' do
|
@@ -153,7 +153,7 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
153
153
|
it 'calculates the progress correctly' do
|
154
154
|
job_invocation.targeting.stubs(:resolved?).returns(true)
|
155
155
|
task.expects(:sub_tasks_counts).never
|
156
|
-
|
156
|
+
assert_equal progress_report_without_sub_tasks, job_invocation.progress_report
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
@@ -163,8 +163,8 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
163
163
|
task.result = 'success'
|
164
164
|
end
|
165
165
|
|
166
|
-
specify {
|
167
|
-
specify {
|
166
|
+
specify { assert_equal HostStatus::ExecutionStatus::OK, job_invocation.status }
|
167
|
+
specify { refute job_invocation.queued? }
|
168
168
|
|
169
169
|
it 'calculates the progress correctly' do
|
170
170
|
sub_tasks = [ForemanTasks::Task.new]
|
@@ -173,7 +173,7 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
173
173
|
sub_tasks.expects(:where).with(:result => %w(success warning error)).returns(sub_tasks)
|
174
174
|
job_invocation.stubs(:sub_tasks).returns(sub_tasks)
|
175
175
|
|
176
|
-
|
176
|
+
assert_equal 100, job_invocation.progress
|
177
177
|
end
|
178
178
|
end
|
179
179
|
end
|
@@ -203,29 +203,29 @@ class JobInvocationTest < ActiveSupport::TestCase
|
|
203
203
|
|
204
204
|
it 'returns only failed hosts when not #finished?' do
|
205
205
|
invocation.stubs(:finished?).returns(false)
|
206
|
-
|
206
|
+
assert_equal 1, invocation.failed_hosts.count
|
207
207
|
end
|
208
208
|
|
209
209
|
it 'returns failed hosts and hosts without task when #finished?' do
|
210
210
|
invocation.stubs(:finished?).returns(true)
|
211
|
-
|
211
|
+
assert_equal 2, invocation.failed_hosts.count
|
212
212
|
end
|
213
213
|
|
214
214
|
describe '#failed_template_invocations' do
|
215
215
|
it 'finds only failed template invocations' do
|
216
216
|
template_invocations = invocation.send(:failed_template_invocations)
|
217
|
-
|
217
|
+
assert_equal 1, template_invocations.count
|
218
218
|
template_invocation = template_invocations.first
|
219
|
-
|
219
|
+
assert_equal 'error', template_invocation.run_host_job_task.result
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
223
|
describe '#not_failed_template_invocations' do
|
224
224
|
it 'finds only non-failed template invocations' do
|
225
225
|
template_invocations = invocation.send(:not_failed_template_invocations)
|
226
|
-
|
226
|
+
assert_equal 1, template_invocations.count
|
227
227
|
template_invocation = template_invocations.first
|
228
|
-
|
228
|
+
assert_equal 'success', template_invocation.run_host_job_task.result
|
229
229
|
end
|
230
230
|
end
|
231
231
|
end
|
@@ -19,19 +19,19 @@ class JobTemplateEffectiveUserTest < ActiveSupport::TestCase
|
|
19
19
|
user = FactoryBot.create(:user)
|
20
20
|
User.current = user
|
21
21
|
effective_user.current_user = true
|
22
|
-
|
22
|
+
assert_equal user.login, effective_user.compute_value
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'returns the value when not current user is set to true' do
|
26
26
|
effective_user.current_user = false
|
27
27
|
effective_user.value = 'testuser'
|
28
|
-
|
28
|
+
assert_equal 'testuser', effective_user.compute_value
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'returns a default value when no value is specified for the user' do
|
32
32
|
effective_user.value = ''
|
33
33
|
Setting[:remote_execution_effective_user] = 'myuser'
|
34
|
-
|
34
|
+
assert_equal 'myuser', effective_user.compute_value
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
47
|
+
assert_equal minimal_template.generate_description_format, '%{template_name}'
|
48
48
|
minimal_template.description_format = ''
|
49
|
-
|
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
|
-
|
55
|
+
assert_equal template.generate_description_format, expected_result
|
56
56
|
template.description_format = ''
|
57
|
-
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
123
|
+
assert_equal template.name, 'Service Restart'
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'has a template' do
|
127
|
-
|
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
|
-
|
131
|
+
assert_equal template.template_inputs.first.name, 'service_name'
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'imports input sets' do
|
135
|
-
|
136
|
-
|
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
|
-
|
142
|
+
assert_equal remote_execution_feature.job_template, template
|
143
143
|
end
|
144
144
|
|
145
145
|
it 'sets additional options' do
|
146
|
-
|
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
|
-
|
229
|
+
assert_equal hostname.options, 'www.redhat.com'
|
230
230
|
end
|
231
231
|
|
232
232
|
it 'syncs content' do
|
233
|
-
|
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
|
-
|
238
|
-
|
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
|
-
|
252
|
+
assert_match(/^name: #{exportable_template.name}$/, erb)
|
253
253
|
end
|
254
254
|
|
255
255
|
it 'includes template inputs' do
|
256
|
-
|
256
|
+
assert_match(/^template_inputs:$/, erb)
|
257
257
|
end
|
258
258
|
|
259
259
|
it 'includes template contents' do
|
260
|
-
|
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
|
-
|
270
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
34
|
+
assert_equal 1, composer.pattern_template_invocations.size
|
35
35
|
template_invocation = composer.pattern_template_invocations.first
|
36
|
-
|
37
|
-
|
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
|
-
|
41
|
-
|
40
|
+
assert_equal 'zsh', input_value.value
|
41
|
+
assert_equal 'package', input_value.template_input.name
|
42
42
|
|
43
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
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
|
-
|
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 {
|
6
|
+
it { assert_kind_of HashWithIndifferentAccess, providers }
|
7
7
|
it 'makes providers accessible using symbol' do
|
8
|
-
|
9
|
-
|
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
|
-
|
13
|
-
|
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 {
|
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 {
|
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)
|
30
|
+
assert_equal SSHExecutionProvider, RemoteExecutionProvider.provider_for(:SSH)
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'accepts strings' do
|
34
|
-
RemoteExecutionProvider.provider_for('SSH')
|
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')
|
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
|
-
|
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 {
|
55
|
-
it {
|
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
|
-
|
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
|
-
|
90
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
144
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
172
|
-
|
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
|
-
|
182
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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)
|
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
|
-
|
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)
|
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)
|
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)
|
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)
|
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)
|
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)
|
294
|
+
assert_equal execution_interface.ip6, SSHExecutionProvider.find_ip_or_hostname(host)
|
295
295
|
end
|
296
296
|
end
|
297
297
|
end
|