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
@@ -35,6 +35,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
35
35
|
let(:trying_job_template_1) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying1', :provider_type => 'SSH') }
|
36
36
|
let(:trying_job_template_2) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_2', :name => 'trying2', :provider_type => 'Mcollective') }
|
37
37
|
let(:trying_job_template_3) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying3', :provider_type => 'SSH') }
|
38
|
+
let(:trying_job_template_5) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_5', :name => 'trying5', :provider_type => 'SSH') }
|
38
39
|
let(:unauthorized_job_template_1) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'unauth1', :provider_type => 'SSH') }
|
39
40
|
let(:unauthorized_job_template_2) { FactoryBot.create(:job_template, :job_category => 'unauthorized_job_template_2', :name => 'unauth2', :provider_type => 'Ansible') }
|
40
41
|
|
@@ -44,6 +45,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
44
45
|
let(:input2) { FactoryBot.create(:template_input, :template => trying_job_template_3, :input_type => 'user') }
|
45
46
|
let(:input3) { FactoryBot.create(:template_input, :template => trying_job_template_1, :input_type => 'user', :required => true) }
|
46
47
|
let(:input4) { FactoryBot.create(:template_input, :template => provider_inputs_job_template, :input_type => 'user') }
|
48
|
+
let(:input5) { FactoryBot.create(:template_input, :template => trying_job_template_5, :input_type => 'user', :default => 'value') }
|
47
49
|
let(:unauthorized_input1) { FactoryBot.create(:template_input, :template => unauthorized_job_template_1, :input_type => 'user') }
|
48
50
|
|
49
51
|
let(:ansible_params) { { } }
|
@@ -75,13 +77,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
75
77
|
describe '#available_templates_for(job_category)' do
|
76
78
|
it 'find the templates only for a given job name' do
|
77
79
|
results = composer.available_templates_for(trying_job_template_1.job_category)
|
78
|
-
|
79
|
-
|
80
|
+
assert_includes results, trying_job_template_1
|
81
|
+
refute_includes results, trying_job_template_2
|
80
82
|
end
|
81
83
|
|
82
84
|
it 'it respects view permissions' do
|
83
85
|
results = composer.available_templates_for(trying_job_template_1.job_category)
|
84
|
-
|
86
|
+
refute_includes results, unauthorized_job_template_1
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
@@ -89,13 +91,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
89
91
|
let(:job_categories) { composer.available_job_categories }
|
90
92
|
|
91
93
|
it 'find only job names that user is granted to view' do
|
92
|
-
|
93
|
-
|
94
|
-
|
94
|
+
assert_includes job_categories, trying_job_template_1.job_category
|
95
|
+
assert_includes job_categories, trying_job_template_2.job_category
|
96
|
+
refute_includes job_categories, unauthorized_job_template_2.job_category
|
95
97
|
end
|
96
98
|
|
97
99
|
it 'every job name is listed just once' do
|
98
|
-
|
100
|
+
assert_equal job_categories.uniq, job_categories
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
@@ -104,13 +106,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
104
106
|
|
105
107
|
it 'finds only providers which user is granted to view' do
|
106
108
|
composer.job_invocation.job_category = 'trying_job_template_1'
|
107
|
-
|
108
|
-
|
109
|
-
|
109
|
+
assert_includes provider_types, 'SSH'
|
110
|
+
refute_includes provider_types, 'Mcollective'
|
111
|
+
refute_includes provider_types, 'Ansible'
|
110
112
|
end
|
111
113
|
|
112
114
|
it 'every provider type is listed just once' do
|
113
|
-
|
115
|
+
assert_equal provider_types.uniq, provider_types
|
114
116
|
end
|
115
117
|
end
|
116
118
|
|
@@ -122,9 +124,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
122
124
|
end
|
123
125
|
|
124
126
|
it 'returns only authorized inputs based on templates' do
|
125
|
-
|
126
|
-
|
127
|
-
|
127
|
+
assert_includes composer.available_template_inputs, input1
|
128
|
+
assert_includes composer.available_template_inputs, input2
|
129
|
+
refute_includes composer.available_template_inputs, unauthorized_input1
|
128
130
|
end
|
129
131
|
|
130
132
|
context 'params contains job template ids' do
|
@@ -134,9 +136,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
134
136
|
let(:params) { { :job_invocation => providers_params }.with_indifferent_access }
|
135
137
|
|
136
138
|
it 'finds the inputs only specified job templates' do
|
137
|
-
|
138
|
-
|
139
|
-
|
139
|
+
assert_includes composer.available_template_inputs, input1
|
140
|
+
refute_includes composer.available_template_inputs, input2
|
141
|
+
refute_includes composer.available_template_inputs, unauthorized_input1
|
140
142
|
end
|
141
143
|
end
|
142
144
|
end
|
@@ -149,7 +151,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
149
151
|
|
150
152
|
it 'returns false if there is one provider' do
|
151
153
|
composer.stubs(:available_provider_types => [ 'SSH' ])
|
152
|
-
|
154
|
+
refute composer.needs_provider_type_selection?
|
153
155
|
end
|
154
156
|
end
|
155
157
|
|
@@ -161,40 +163,40 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
161
163
|
it 'returns all templates for a given provider respecting template permissions' do
|
162
164
|
trying_job_template_4 = FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying4', :provider_type => 'Ansible')
|
163
165
|
result = composer.templates_for_provider('SSH')
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
166
|
+
assert_includes result, trying_job_template_1
|
167
|
+
assert_includes result, trying_job_template_3
|
168
|
+
refute_includes result, unauthorized_job_template_1
|
169
|
+
refute_includes result, trying_job_template_4
|
168
170
|
|
169
171
|
result = composer.templates_for_provider('Ansible')
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
172
|
+
refute_includes result, trying_job_template_1
|
173
|
+
refute_includes result, trying_job_template_3
|
174
|
+
refute_includes result, unauthorized_job_template_2
|
175
|
+
assert_includes result, trying_job_template_4
|
174
176
|
end
|
175
177
|
end
|
176
178
|
|
177
179
|
describe '#rerun_possible?' do
|
178
180
|
it 'is true when not rerunning' do
|
179
|
-
|
181
|
+
assert_predicate composer, :rerun_possible?
|
180
182
|
end
|
181
183
|
|
182
184
|
it 'is true when rerunning with pattern tempalte invocations' do
|
183
185
|
composer.expects(:reruns).returns(1)
|
184
186
|
composer.job_invocation.expects(:pattern_template_invocations).returns([1])
|
185
|
-
|
187
|
+
assert_predicate composer, :rerun_possible?
|
186
188
|
end
|
187
189
|
|
188
190
|
it 'is false when rerunning without pattern template invocations' do
|
189
191
|
composer.expects(:reruns).returns(1)
|
190
192
|
composer.job_invocation.expects(:pattern_template_invocations).returns([])
|
191
|
-
|
193
|
+
refute_predicate composer, :rerun_possible?
|
192
194
|
end
|
193
195
|
end
|
194
196
|
|
195
197
|
describe '#selected_job_templates' do
|
196
198
|
it 'returns no template if none was selected through params' do
|
197
|
-
|
199
|
+
assert_empty composer.selected_job_templates
|
198
200
|
end
|
199
201
|
|
200
202
|
context 'extra unavailable templates id were selected' do
|
@@ -207,14 +209,14 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
207
209
|
|
208
210
|
it 'ignores unauthorized template' do
|
209
211
|
unauthorized # make sure unautorized exists
|
210
|
-
|
212
|
+
refute_includes composer.selected_job_templates, unauthorized
|
211
213
|
end
|
212
214
|
|
213
215
|
it 'contains only authorized template specified in params' do
|
214
216
|
mcollective_authorized # make sure mcollective_authorized exists
|
215
|
-
|
216
|
-
|
217
|
-
|
217
|
+
assert_includes composer.selected_job_templates, trying_job_template_1
|
218
|
+
assert_includes composer.selected_job_templates, mcollective_authorized
|
219
|
+
refute_includes composer.selected_job_templates, trying_job_template_3
|
218
220
|
end
|
219
221
|
end
|
220
222
|
end
|
@@ -222,7 +224,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
222
224
|
describe '#preselected_template_for_provider(provider_type)' do
|
223
225
|
context 'none template was selected through params' do
|
224
226
|
it 'returns nil' do
|
225
|
-
|
227
|
+
assert_nil composer.preselected_template_for_provider('SSH')
|
226
228
|
end
|
227
229
|
end
|
228
230
|
|
@@ -231,7 +233,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
231
233
|
let(:params) { { :job_invocation => providers_params }.with_indifferent_access }
|
232
234
|
|
233
235
|
it 'returns the selected template because it is available for provider' do
|
234
|
-
|
236
|
+
assert_equal trying_job_template_1, composer.preselected_template_for_provider('SSH')
|
235
237
|
end
|
236
238
|
end
|
237
239
|
end
|
@@ -249,9 +251,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
249
251
|
let(:invocations) { composer.pattern_template_invocations }
|
250
252
|
|
251
253
|
it 'builds pattern template invocations based on passed params and it filters out wrong inputs' do
|
252
|
-
|
253
|
-
|
254
|
-
|
254
|
+
assert_equal 1, invocations.size
|
255
|
+
assert_equal 1, invocations.first.input_values.size
|
256
|
+
assert_equal 'value1', invocations.first.input_values.first.value
|
255
257
|
end
|
256
258
|
end
|
257
259
|
|
@@ -275,7 +277,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
275
277
|
let(:invocation_effective_user) { 'invocation user' }
|
276
278
|
|
277
279
|
it 'takes the value from the template invocation' do
|
278
|
-
|
280
|
+
assert_equal 'invocation user', template_invocation.effective_user
|
279
281
|
end
|
280
282
|
end
|
281
283
|
|
@@ -284,7 +286,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
284
286
|
let(:invocation_effective_user) { '' }
|
285
287
|
|
286
288
|
it 'takes the value from the job template' do
|
287
|
-
|
289
|
+
assert_equal 'template user', template_invocation.effective_user
|
288
290
|
end
|
289
291
|
end
|
290
292
|
|
@@ -293,14 +295,14 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
293
295
|
let(:invocation_effective_user) { 'invocation user' }
|
294
296
|
|
295
297
|
it 'takes the value from the job template' do
|
296
|
-
|
298
|
+
assert_equal 'template user', template_invocation.effective_user
|
297
299
|
end
|
298
300
|
end
|
299
301
|
end
|
300
302
|
|
301
303
|
describe '#displayed_search_query' do
|
302
304
|
it 'is empty by default' do
|
303
|
-
|
305
|
+
assert_empty composer.displayed_search_query
|
304
306
|
end
|
305
307
|
|
306
308
|
let(:host) { FactoryBot.create(:host) }
|
@@ -310,7 +312,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
310
312
|
let(:params) { { :targeting => { :search_query => 'a', :bookmark_id => bookmark.id }, :host_ids => [ host.id ] }.with_indifferent_access }
|
311
313
|
|
312
314
|
it 'explicit search query has highest priority' do
|
313
|
-
|
315
|
+
assert_equal 'a', composer.displayed_search_query
|
314
316
|
end
|
315
317
|
end
|
316
318
|
|
@@ -318,7 +320,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
318
320
|
let(:params) { { :targeting => { :bookmark_id => bookmark.id }, :host_ids => [ host.id ] }.with_indifferent_access }
|
319
321
|
|
320
322
|
it 'hosts will be used instead of a bookmark' do
|
321
|
-
|
323
|
+
assert_includes composer.displayed_search_query, host.name
|
322
324
|
end
|
323
325
|
end
|
324
326
|
|
@@ -327,20 +329,20 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
327
329
|
|
328
330
|
it 'bookmark query is used if it is available for the user' do
|
329
331
|
bookmark.update_attribute :public, false
|
330
|
-
|
332
|
+
assert_equal bookmark.query, composer.displayed_search_query
|
331
333
|
end
|
332
334
|
|
333
335
|
it 'bookmark query is used if the bookmark is public' do
|
334
336
|
bookmark.owner = nil
|
335
337
|
bookmark.save(:validate => false) # skip validations so owner remains nil
|
336
|
-
|
338
|
+
assert_equal bookmark.query, composer.displayed_search_query
|
337
339
|
end
|
338
340
|
|
339
341
|
it 'empty search is returned if bookmark is not owned by the user and is not public' do
|
340
342
|
bookmark.public = false
|
341
343
|
bookmark.owner = nil
|
342
344
|
bookmark.save(:validate => false) # skip validations so owner remains nil
|
343
|
-
|
345
|
+
assert_empty composer.displayed_search_query
|
344
346
|
end
|
345
347
|
end
|
346
348
|
end
|
@@ -355,9 +357,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
355
357
|
hosts
|
356
358
|
dashboard
|
357
359
|
hostgroups
|
358
|
-
|
359
|
-
|
360
|
-
|
360
|
+
assert_includes composer.available_bookmarks, hosts
|
361
|
+
assert_includes composer.available_bookmarks, dashboard
|
362
|
+
refute_includes composer.available_bookmarks, hostgroups
|
361
363
|
end
|
362
364
|
end
|
363
365
|
end
|
@@ -375,17 +377,17 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
375
377
|
|
376
378
|
it 'searches hosts based on displayed_search_query' do
|
377
379
|
composer.stubs(:displayed_search_query => "name = #{host.name}")
|
378
|
-
|
380
|
+
assert_equal 1, composer.targeted_hosts_count
|
379
381
|
end
|
380
382
|
|
381
383
|
it 'returns 0 for queries with syntax errors' do
|
382
384
|
composer.stubs(:displayed_search_query => 'name = ')
|
383
|
-
|
385
|
+
assert_equal 0, composer.targeted_hosts_count
|
384
386
|
end
|
385
387
|
|
386
388
|
it 'returns 0 when no query is present' do
|
387
389
|
composer.stubs(:displayed_search_query => '')
|
388
|
-
|
390
|
+
assert_equal 0, composer.targeted_hosts_count
|
389
391
|
end
|
390
392
|
end
|
391
393
|
|
@@ -393,7 +395,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
393
395
|
let(:value1) { composer.input_value_for(input1) }
|
394
396
|
it 'returns new empty input value if there is no invocation' do
|
395
397
|
assert value1.new_record?
|
396
|
-
|
398
|
+
assert_empty value1.value
|
397
399
|
end
|
398
400
|
|
399
401
|
context 'there are invocations without input values for a given input' do
|
@@ -409,7 +411,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
409
411
|
|
410
412
|
it 'returns new empty input value' do
|
411
413
|
assert value1.new_record?
|
412
|
-
|
414
|
+
assert_empty value1.value
|
413
415
|
end
|
414
416
|
end
|
415
417
|
|
@@ -425,7 +427,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
425
427
|
let(:params) { { :job_invocation => { :providers => { :ssh => ssh_params } } }.with_indifferent_access }
|
426
428
|
|
427
429
|
it 'finds the value among template invocations' do
|
428
|
-
|
430
|
+
assert_equal 'value1', value1.value
|
429
431
|
end
|
430
432
|
end
|
431
433
|
end
|
@@ -462,12 +464,12 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
462
464
|
end
|
463
465
|
|
464
466
|
it 'accepts the concurrency options' do
|
465
|
-
|
467
|
+
assert_equal 5, composer.job_invocation.concurrency_level
|
466
468
|
end
|
467
469
|
end
|
468
470
|
|
469
471
|
it 'can be disabled' do
|
470
|
-
|
472
|
+
assert_nil composer.job_invocation.concurrency_level
|
471
473
|
end
|
472
474
|
end
|
473
475
|
|
@@ -477,11 +479,11 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
477
479
|
end
|
478
480
|
|
479
481
|
it 'accepts the triggering params' do
|
480
|
-
|
482
|
+
assert_equal :future, composer.job_invocation.triggering.mode
|
481
483
|
end
|
482
484
|
|
483
485
|
it 'formats the triggering end time when its unordered' do
|
484
|
-
|
486
|
+
assert_equal Time.local(3,2,1,4,5), composer.job_invocation.triggering.end_time
|
485
487
|
end
|
486
488
|
end
|
487
489
|
|
@@ -515,7 +517,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
515
517
|
|
516
518
|
it 'sets the password properly' do
|
517
519
|
composer
|
518
|
-
|
520
|
+
assert_equal password, composer.job_invocation.password
|
519
521
|
end
|
520
522
|
end
|
521
523
|
|
@@ -527,7 +529,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
527
529
|
|
528
530
|
it 'sets the key passphrase properly' do
|
529
531
|
composer
|
530
|
-
|
532
|
+
assert_equal key_passphrase, composer.job_invocation.key_passphrase
|
531
533
|
end
|
532
534
|
end
|
533
535
|
|
@@ -539,7 +541,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
539
541
|
|
540
542
|
it 'sets the effective_user_password password properly' do
|
541
543
|
composer
|
542
|
-
|
544
|
+
assert_equal effective_user_password, composer.job_invocation.effective_user_password
|
543
545
|
end
|
544
546
|
end
|
545
547
|
|
@@ -581,29 +583,29 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
581
583
|
end
|
582
584
|
|
583
585
|
it 'sets the same job name' do
|
584
|
-
|
586
|
+
assert_equal existing.job_category, new_composer.job_category
|
585
587
|
end
|
586
588
|
|
587
589
|
it 'accepts additional host ids' do
|
588
590
|
new_composer = JobInvocationComposer.from_job_invocation(composer.job_invocation, { :host_ids => [host.id] })
|
589
|
-
|
591
|
+
assert_equal "name ^ (#{host.name})", new_composer.search_query
|
590
592
|
end
|
591
593
|
|
592
594
|
it 'builds new targeting object which keeps search query' do
|
593
|
-
|
594
|
-
|
595
|
+
refute_equal existing.targeting, new_composer.targeting
|
596
|
+
assert_equal existing.targeting.search_query, new_composer.search_query
|
595
597
|
end
|
596
598
|
|
597
599
|
it 'keeps job template ids' do
|
598
|
-
|
600
|
+
assert_equal existing.pattern_template_invocations.map(&:template_id), new_composer.job_template_ids
|
599
601
|
end
|
600
602
|
|
601
603
|
it 'keeps template invocations and their values' do
|
602
|
-
|
604
|
+
assert_equal existing.pattern_template_invocations.size, new_composer.pattern_template_invocations.size
|
603
605
|
end
|
604
606
|
|
605
607
|
it 'sets the same concurrency control options' do
|
606
|
-
|
608
|
+
assert_equal existing.concurrency_level, new_composer.job_invocation.concurrency_level
|
607
609
|
end
|
608
610
|
|
609
611
|
end
|
@@ -654,14 +656,40 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
654
656
|
|
655
657
|
context 'with with inputs' do
|
656
658
|
let(:params) do
|
657
|
-
{ :job_category =>
|
658
|
-
:job_template_id =>
|
659
|
+
{ :job_category => trying_job_template_5.job_category,
|
660
|
+
:job_template_id => trying_job_template_5.id,
|
659
661
|
:targeting_type => 'static_query',
|
660
662
|
:search_query => 'some hosts',
|
661
|
-
:inputs => {
|
663
|
+
:inputs => {input5.name => 'some_value'}}
|
662
664
|
end
|
663
665
|
|
664
666
|
it 'finds the inputs by name' do
|
667
|
+
assert composer.save!
|
668
|
+
values = composer.pattern_template_invocations.first.input_values
|
669
|
+
assert_equal 1, values.count
|
670
|
+
assert_equal 'some_value', values.first.value
|
671
|
+
end
|
672
|
+
|
673
|
+
it 'can be forced to be empty' do
|
674
|
+
params[:inputs] = {input5.name => ''}
|
675
|
+
assert composer.save!
|
676
|
+
values = composer.pattern_template_invocations.first.input_values
|
677
|
+
assert_equal 1, values.count
|
678
|
+
assert_equal '', values.first.value
|
679
|
+
end
|
680
|
+
end
|
681
|
+
|
682
|
+
context 'with inputs and default values' do
|
683
|
+
let(:params) do
|
684
|
+
{ :job_category => trying_job_template_5.job_category,
|
685
|
+
:job_template_id => trying_job_template_5.id,
|
686
|
+
:targeting_type => 'static_query',
|
687
|
+
:search_query => 'some hosts',
|
688
|
+
:inputs => {}}
|
689
|
+
end
|
690
|
+
|
691
|
+
it 'uses the default input values' do
|
692
|
+
input5 # Force the factory to be materialized
|
665
693
|
assert composer.save!
|
666
694
|
assert_equal 1, composer.pattern_template_invocations.first.input_values.collect.count
|
667
695
|
end
|
@@ -701,7 +729,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
701
729
|
|
702
730
|
it 'sets the effective user based on the input' do
|
703
731
|
assert composer.save!
|
704
|
-
|
732
|
+
assert_equal 'invocation user', template_invocation.effective_user
|
705
733
|
end
|
706
734
|
end
|
707
735
|
|
@@ -720,7 +748,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
720
748
|
|
721
749
|
it 'sets the concurrency level based on the input' do
|
722
750
|
assert composer.save!
|
723
|
-
|
751
|
+
assert_equal level, composer.job_invocation.concurrency_level
|
724
752
|
end
|
725
753
|
end
|
726
754
|
|
@@ -737,7 +765,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
737
765
|
|
738
766
|
it 'sets the remote execution feature based on the input' do
|
739
767
|
assert composer.save!
|
740
|
-
|
768
|
+
assert_equal feature, composer.job_invocation.remote_execution_feature
|
741
769
|
end
|
742
770
|
|
743
771
|
it 'sets the remote execution_feature id based on `feature` param' do
|
@@ -747,7 +775,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
747
775
|
refute_equal feature.job_template, trying_job_template_1
|
748
776
|
|
749
777
|
assert composer.save!
|
750
|
-
|
778
|
+
assert_equal feature, composer.job_invocation.remote_execution_feature
|
751
779
|
end
|
752
780
|
end
|
753
781
|
|
@@ -797,7 +825,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
797
825
|
error = assert_raises(ActiveRecord::RecordNotSaved) do
|
798
826
|
composer.save!
|
799
827
|
end
|
800
|
-
|
828
|
+
assert_includes error.message, "Template #{trying_job_template_1.name}: Input #{input3.name.downcase}: Value can't be blank"
|
801
829
|
end
|
802
830
|
end
|
803
831
|
|
@@ -826,13 +854,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
|
|
826
854
|
end
|
827
855
|
|
828
856
|
it 'handles errors' do
|
829
|
-
|
857
|
+
assert_predicate input3, :required
|
830
858
|
|
831
859
|
error = assert_raises(ActiveRecord::RecordNotSaved) do
|
832
860
|
composer.save!
|
833
861
|
end
|
834
862
|
|
835
|
-
|
863
|
+
assert_includes error.message, "Template #{trying_job_template_1.name}: Not all required inputs have values. Missing inputs: #{input3.name}"
|
836
864
|
end
|
837
865
|
end
|
838
866
|
end
|