foreman_puppet 2.0.3 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/app/controllers/concerns/foreman_puppet/extensions/api_smart_proxies_controller.rb +7 -2
- data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +1 -1
- data/app/services/foreman_puppet/host_info_providers/puppet_info.rb +1 -1
- data/app/views/foreman_puppet/config_groups/_config_group.html.erb +5 -1
- data/app/views/hosts/_form_puppet_enc_tab.html.erb +5 -4
- data/lib/foreman_puppet/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ca/foreman_puppet.edit.po +1095 -0
- data/locale/ca/foreman_puppet.po +70 -1
- data/locale/ca/foreman_puppet.po.time_stamp +0 -0
- data/locale/cs_CZ/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/cs_CZ/foreman_puppet.edit.po +199 -184
- data/locale/cs_CZ/foreman_puppet.po +13 -2
- data/locale/de/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/de/foreman_puppet.edit.po +1122 -0
- data/locale/de/foreman_puppet.po +25 -13
- data/locale/de/foreman_puppet.po.time_stamp +0 -0
- data/locale/en/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/en/foreman_puppet.edit.po +33 -25
- data/locale/en/foreman_puppet.po +13 -1
- data/locale/en_GB/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/en_GB/foreman_puppet.edit.po +1097 -0
- data/locale/en_GB/foreman_puppet.po +13 -2
- data/locale/en_GB/foreman_puppet.po.time_stamp +0 -0
- data/locale/es/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/es/foreman_puppet.edit.po +1104 -0
- data/locale/es/foreman_puppet.po +13 -2
- data/locale/es/foreman_puppet.po.time_stamp +0 -0
- data/locale/foreman_puppet.pot +48 -25
- data/locale/fr/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/fr/foreman_puppet.edit.po +1112 -0
- data/locale/fr/foreman_puppet.po +13 -2
- data/locale/fr/foreman_puppet.po.time_stamp +0 -0
- data/locale/gl/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/gl/foreman_puppet.edit.po +1095 -0
- data/locale/gl/foreman_puppet.po +13 -2
- data/locale/gl/foreman_puppet.po.time_stamp +0 -0
- data/locale/it/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/it/foreman_puppet.edit.po +1099 -0
- data/locale/it/foreman_puppet.po +13 -2
- data/locale/it/foreman_puppet.po.time_stamp +0 -0
- data/locale/ja/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ja/foreman_puppet.edit.po +1107 -0
- data/locale/ja/foreman_puppet.po +15 -4
- data/locale/ja/foreman_puppet.po.time_stamp +0 -0
- data/locale/ko/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ko/foreman_puppet.edit.po +1096 -0
- data/locale/ko/foreman_puppet.po +13 -2
- data/locale/ko/foreman_puppet.po.time_stamp +0 -0
- data/locale/nl_NL/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/nl_NL/foreman_puppet.edit.po +1100 -0
- data/locale/nl_NL/foreman_puppet.po +13 -2
- data/locale/nl_NL/foreman_puppet.po.time_stamp +0 -0
- data/locale/pl/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/pl/foreman_puppet.edit.po +1099 -0
- data/locale/pl/foreman_puppet.po +13 -2
- data/locale/pl/foreman_puppet.po.time_stamp +0 -0
- data/locale/pt_BR/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/pt_BR/foreman_puppet.edit.po +1103 -0
- data/locale/pt_BR/foreman_puppet.po +13 -2
- data/locale/pt_BR/foreman_puppet.po.time_stamp +0 -0
- data/locale/ru/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ru/foreman_puppet.edit.po +1104 -0
- data/locale/ru/foreman_puppet.po +15 -4
- data/locale/ru/foreman_puppet.po.time_stamp +0 -0
- data/locale/sv_SE/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/sv_SE/foreman_puppet.edit.po +1099 -0
- data/locale/sv_SE/foreman_puppet.po +13 -2
- data/locale/sv_SE/foreman_puppet.po.time_stamp +0 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/zh_CN/foreman_puppet.edit.po +1108 -0
- data/locale/zh_CN/foreman_puppet.po +16 -5
- data/locale/zh_CN/foreman_puppet.po.time_stamp +0 -0
- data/locale/zh_TW/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/zh_TW/foreman_puppet.edit.po +1098 -0
- data/locale/zh_TW/foreman_puppet.po +13 -2
- data/locale/zh_TW/foreman_puppet.po.time_stamp +0 -0
- data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +24 -18
- data/test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb +10 -0
- data/test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/environments_controller_test.rb +1 -1
- data/test/controllers/foreman_puppet/hosts_controller_test.rb +4 -27
- data/test/graphql/queries/environment_query_test.rb +4 -4
- data/test/graphql/queries/puppetclass_query_test.rb +4 -4
- data/test/integration/foreman_puppet/dashboard_js_test.rb +1 -2
- data/test/integration/foreman_puppet/environment_js_test.rb +1 -2
- data/test/integration/foreman_puppet/host_js_test.rb +31 -27
- data/test/integration/foreman_puppet/hostgroup_js_test.rb +1 -2
- data/test/integration/foreman_puppet/puppetclass_js_test.rb +1 -2
- data/test/integration/foreman_puppet/smartclass_parameter_js_test.rb +1 -2
- data/test/integration_puppet_helper.rb +3 -0
- data/test/models/foreman_puppet/host_puppet_facet_test.rb +13 -2
- data/test/models/foreman_puppet/host_test.rb +22 -22
- data/test/models/foreman_puppet/provisioning_template_test.rb +3 -3
- data/test/models/foreman_puppet/puppetclass_test.rb +1 -1
- data/test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb +1 -1
- data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +3 -3
- data/test/unit/foreman_puppet/template_rendering_test.rb +1 -1
- metadata +36 -2
@@ -8,10 +8,9 @@
|
|
8
8
|
# 0868a4d1af5275b3f70b0a6dac4c99a4, 2021
|
9
9
|
# Bryan Kearney <bryan.kearney@gmail.com>, 2021
|
10
10
|
#
|
11
|
-
#, fuzzy
|
12
11
|
msgid ""
|
13
12
|
msgstr ""
|
14
|
-
"Project-Id-Version: foreman_puppet
|
13
|
+
"Project-Id-Version: foreman_puppet 3.0.2\n"
|
15
14
|
"Report-Msgid-Bugs-To: \n"
|
16
15
|
"PO-Revision-Date: 2021-02-03 16:30+0000\n"
|
17
16
|
"Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>, 2021\n"
|
@@ -89,6 +88,9 @@ msgstr "所有環境 -(未篩選)"
|
|
89
88
|
msgid "Allow assigning Puppet environments and classes to the Foreman Hosts."
|
90
89
|
msgstr ""
|
91
90
|
|
91
|
+
msgid "Autosign entries"
|
92
|
+
msgstr ""
|
93
|
+
|
92
94
|
msgid "Available Classes"
|
93
95
|
msgstr "可用類別"
|
94
96
|
|
@@ -104,6 +106,9 @@ msgstr ""
|
|
104
106
|
msgid "Cancel"
|
105
107
|
msgstr "取消"
|
106
108
|
|
109
|
+
msgid "Certificates"
|
110
|
+
msgstr ""
|
111
|
+
|
107
112
|
msgid "Change Environment"
|
108
113
|
msgstr "更改環境"
|
109
114
|
|
@@ -341,6 +346,9 @@ msgstr ""
|
|
341
346
|
msgid "If true, will raise an error if there is no default value and no matcher provide a value"
|
342
347
|
msgstr "若為真而沒有預設值並且比對器未提供值的話,將會造成錯誤發生。"
|
343
348
|
|
349
|
+
msgid "If you are planning to use Foreman as an external node classifier you should provide information about one or more environments.<br/> This information is commonly imported from a pre-existing Puppet configuration by the use of the <a target=\"_blank\" href=${getManualURL( '4.2.2Classes' )}>Puppet classes and environment importer.</a>"
|
350
|
+
msgstr ""
|
351
|
+
|
344
352
|
msgid "Ignored classes in the environments: %s"
|
345
353
|
msgstr ""
|
346
354
|
|
@@ -677,6 +685,9 @@ msgstr "智慧類別參數"
|
|
677
685
|
msgid "Smart Class Parameters"
|
678
686
|
msgstr ""
|
679
687
|
|
688
|
+
msgid "Some Puppet Classes are unavailable in the selected environment"
|
689
|
+
msgstr ""
|
690
|
+
|
680
691
|
msgid "Successfully overridden all parameters of Puppet class %s"
|
681
692
|
msgstr "已成功置換 Puppet 類別 %s 的所有參數"
|
682
693
|
|
File without changes
|
@@ -11,27 +11,33 @@ module ForemanPuppet
|
|
11
11
|
let(:environment_attrs) { { name: 'Development' } }
|
12
12
|
let(:environment) { FactoryBot.create(:environment) }
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
describe 'GET #index' do
|
15
|
+
it 'gets index' do
|
16
|
+
environment
|
17
|
+
get :index
|
18
|
+
assert_response :success
|
19
|
+
assert_not_nil assigns(:environments)
|
20
|
+
envs = ActiveSupport::JSON.decode(@response.body)
|
21
|
+
assert_not envs.empty?
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
it 'shows environment by id' do
|
25
|
+
get :show, params: { id: environment.id }
|
26
|
+
assert_response :success
|
27
|
+
assert_equal environment.name, JSON.parse(@response.body)['name']
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
it 'shows environment by to_param' do
|
31
|
+
get :show, params: { id: environment.to_param }
|
32
|
+
assert_response :success
|
33
|
+
assert_equal environment.name, JSON.parse(@response.body)['name']
|
34
|
+
end
|
31
35
|
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
it 'shows environment by name' do
|
37
|
+
get :show, params: { id: environment.name }
|
38
|
+
assert_response :success
|
39
|
+
assert_equal environment.name, JSON.parse(@response.body)['name']
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
test 'should create environment' do
|
@@ -79,12 +79,22 @@ module ForemanPuppet
|
|
79
79
|
|
80
80
|
test 'should update with puppet class' do
|
81
81
|
puppetclass = environment.puppetclasses.first
|
82
|
+
# uses the deprecated version of params passing without namespace, to test it works :)
|
82
83
|
put :update, params: { id: host.id, host: { environment_id: environment.id, puppetclass_ids: [puppetclass.id] } }
|
83
84
|
assert_response :success
|
84
85
|
response = JSON.parse(@response.body)
|
85
86
|
assert_equal environment.id, response['environment_id'], "Can't update host with environment #{environment}"
|
86
87
|
assert_equal puppetclass.id, response['puppetclasses'][0]['id'], "Can't update host with puppetclass #{puppetclass}"
|
87
88
|
end
|
89
|
+
|
90
|
+
test 'should remove puppetclass by passing empty array' do
|
91
|
+
host2 = FactoryBot.create(:host, :with_puppet_enc, :with_puppetclass)
|
92
|
+
|
93
|
+
put :update, params: { id: host2.id, host: { puppet_attributes: { puppetclass_ids: [] } } }
|
94
|
+
assert_response :success
|
95
|
+
response = JSON.parse(@response.body)
|
96
|
+
assert_empty(response['puppetclasses'], 'Can not remove puppetclasses')
|
97
|
+
end
|
88
98
|
end
|
89
99
|
|
90
100
|
describe '#enc' do
|
@@ -421,7 +421,7 @@ module ForemanPuppet
|
|
421
421
|
|
422
422
|
test_attributes pid: 'd5d5f084-fa62-4ec3-90ea-9fcabd7bda4f'
|
423
423
|
test 'validate default value with list' do
|
424
|
-
values_list = [RFauxFactory.gen_alpha, RFauxFactory.gen_alphanumeric, rand(100..1 << 64), [true, false].sample]
|
424
|
+
values_list = [RFauxFactory.gen_alpha, RFauxFactory.gen_alphanumeric, rand(100..(1 << 64)), [true, false].sample]
|
425
425
|
values_list_str = values_list.join(', ')
|
426
426
|
value = values_list.sample
|
427
427
|
put :update, params: { id: lookup_key.id, smart_class_parameter: { override: true,
|
@@ -437,7 +437,7 @@ module ForemanPuppet
|
|
437
437
|
|
438
438
|
test_attributes pid: 'd5df7804-9633-4ef8-a065-10807351d230'
|
439
439
|
test 'validate default value with regexp' do
|
440
|
-
value = rand(1..1 << 64)
|
440
|
+
value = rand(1..(1 << 64))
|
441
441
|
put :update, params: { id: lookup_key.id, smart_class_parameter: { override: true,
|
442
442
|
default_value: value,
|
443
443
|
validator_type: 'regexp',
|
@@ -107,7 +107,7 @@ module ForemanPuppet
|
|
107
107
|
{ 'env3' => '[]' } } }, session: set_session_user
|
108
108
|
assert_redirected_to environments_url
|
109
109
|
assert_equal 'Successfully updated environments and Puppet classes from the on-disk Puppet installation', flash[:success]
|
110
|
-
|
110
|
+
assert_empty Environment.unscoped.find_by(name: 'env3').puppetclasses.map(&:name).sort
|
111
111
|
end
|
112
112
|
|
113
113
|
test 'should fail to remove active environments' do
|
@@ -201,7 +201,6 @@ module ForemanPuppet
|
|
201
201
|
test 'hosts with a registered smart proxy on should get externalNodes successfully' do
|
202
202
|
User.current = nil
|
203
203
|
Setting[:restrict_registered_smart_proxies] = true
|
204
|
-
Setting[:require_ssl_smart_proxies] = false
|
205
204
|
|
206
205
|
Resolv.any_instance.stubs(:getnames).returns(['else.where'])
|
207
206
|
get :externalNodes, params: { name: host1.name, format: 'yml' }
|
@@ -211,7 +210,6 @@ module ForemanPuppet
|
|
211
210
|
test 'hosts without a registered smart proxy on should not be able to get externalNodes' do
|
212
211
|
User.current = nil
|
213
212
|
Setting[:restrict_registered_smart_proxies] = true
|
214
|
-
Setting[:require_ssl_smart_proxies] = false
|
215
213
|
|
216
214
|
Resolv.any_instance.stubs(:getnames).returns(['another.host'])
|
217
215
|
get :externalNodes, params: { name: host1.name, format: 'yml' }
|
@@ -221,7 +219,6 @@ module ForemanPuppet
|
|
221
219
|
test 'hosts with a registered smart proxy and SSL cert should get externalNodes successfully' do
|
222
220
|
User.current = nil
|
223
221
|
Setting[:restrict_registered_smart_proxies] = true
|
224
|
-
Setting[:require_ssl_smart_proxies] = true
|
225
222
|
|
226
223
|
@request.env['HTTPS'] = 'on'
|
227
224
|
@request.env['SSL_CLIENT_S_DN'] = 'CN=else.where'
|
@@ -234,7 +231,6 @@ module ForemanPuppet
|
|
234
231
|
test 'hosts in trusted hosts list and SSL cert should get externalNodes successfully' do
|
235
232
|
User.current = nil
|
236
233
|
Setting[:restrict_registered_smart_proxies] = true
|
237
|
-
Setting[:require_ssl_smart_proxies] = true
|
238
234
|
Setting[:trusted_hosts] = ['else.where']
|
239
235
|
|
240
236
|
@request.env['HTTPS'] = 'on'
|
@@ -248,7 +244,6 @@ module ForemanPuppet
|
|
248
244
|
test 'hosts with comma-separated SSL DN should get externalNodes successfully' do
|
249
245
|
User.current = nil
|
250
246
|
Setting[:restrict_registered_smart_proxies] = true
|
251
|
-
Setting[:require_ssl_smart_proxies] = true
|
252
247
|
Setting[:trusted_hosts] = ['foreman.example']
|
253
248
|
|
254
249
|
@request.env['HTTPS'] = 'on'
|
@@ -262,7 +257,6 @@ module ForemanPuppet
|
|
262
257
|
test 'hosts with slash-separated SSL DN should get externalNodes successfully' do
|
263
258
|
User.current = nil
|
264
259
|
Setting[:restrict_registered_smart_proxies] = true
|
265
|
-
Setting[:require_ssl_smart_proxies] = true
|
266
260
|
Setting[:trusted_hosts] = ['foreman.linux.lab.local']
|
267
261
|
|
268
262
|
@request.env['HTTPS'] = 'on'
|
@@ -276,53 +270,37 @@ module ForemanPuppet
|
|
276
270
|
test 'hosts without a registered smart proxy but with an SSL cert should not be able to get externalNodes' do
|
277
271
|
User.current = nil
|
278
272
|
Setting[:restrict_registered_smart_proxies] = true
|
279
|
-
Setting[:require_ssl_smart_proxies] = true
|
280
273
|
|
281
274
|
@request.env['HTTPS'] = 'on'
|
282
275
|
@request.env['SSL_CLIENT_S_DN'] = 'CN=another.host'
|
283
276
|
@request.env['SSL_CLIENT_VERIFY'] = 'SUCCESS'
|
284
277
|
get :externalNodes, params: { name: host1.name, format: 'yml' }
|
285
|
-
|
278
|
+
assert_response :forbidden
|
286
279
|
end
|
287
280
|
|
288
281
|
test 'hosts with an unverified SSL cert should not be able to get externalNodes' do
|
289
282
|
User.current = nil
|
290
283
|
Setting[:restrict_registered_smart_proxies] = true
|
291
|
-
Setting[:require_ssl_smart_proxies] = true
|
292
284
|
|
293
285
|
@request.env['HTTPS'] = 'on'
|
294
286
|
@request.env['SSL_CLIENT_S_DN'] = 'CN=else.where'
|
295
287
|
@request.env['SSL_CLIENT_VERIFY'] = 'FAILURE'
|
296
288
|
get :externalNodes, params: { name: host1.name, format: 'yml' }
|
297
|
-
|
289
|
+
assert_response :forbidden
|
298
290
|
end
|
299
291
|
|
300
|
-
test 'when "
|
292
|
+
test 'when "require_ssl" is true, HTTP requests should not be able to get externalNodes' do
|
301
293
|
User.current = nil
|
302
294
|
Setting[:restrict_registered_smart_proxies] = true
|
303
|
-
Setting[:require_ssl_smart_proxies] = true
|
304
295
|
SETTINGS[:require_ssl] = true
|
305
296
|
|
306
297
|
Resolv.any_instance.stubs(:getnames).returns(['else.where'])
|
307
298
|
get :externalNodes, params: { name: host1.name, format: 'yml' }
|
308
|
-
|
309
|
-
end
|
310
|
-
|
311
|
-
test 'when "require_ssl_smart_proxies" is true and "require_ssl" is false, HTTP requests should be able to get externalNodes' do
|
312
|
-
User.current = nil
|
313
|
-
# since require_ssl_smart_proxies is only applicable to HTTPS connections, both should be set
|
314
|
-
Setting[:restrict_registered_smart_proxies] = true
|
315
|
-
Setting[:require_ssl_smart_proxies] = true
|
316
|
-
SETTINGS[:require_ssl] = false
|
317
|
-
|
318
|
-
Resolv.any_instance.stubs(:getnames).returns(['else.where'])
|
319
|
-
get :externalNodes, params: { name: host1.name, format: 'yml' }
|
320
|
-
assert_response :success
|
299
|
+
assert_response :redirect
|
321
300
|
end
|
322
301
|
|
323
302
|
test 'authenticated users over HTTP should be able to get externalNodes' do
|
324
303
|
Setting[:restrict_registered_smart_proxies] = true
|
325
|
-
Setting[:require_ssl_smart_proxies] = true
|
326
304
|
SETTINGS[:require_ssl] = false
|
327
305
|
|
328
306
|
Resolv.any_instance.stubs(:getnames).returns(['users.host'])
|
@@ -332,7 +310,6 @@ module ForemanPuppet
|
|
332
310
|
|
333
311
|
test 'authenticated users over HTTPS should be able to get externalNodes' do
|
334
312
|
Setting[:restrict_registered_smart_proxies] = true
|
335
|
-
Setting[:require_ssl_smart_proxies] = true
|
336
313
|
SETTINGS[:require_ssl] = false
|
337
314
|
|
338
315
|
Resolv.any_instance.stubs(:getnames).returns(['users.host'])
|
@@ -42,10 +42,10 @@ module Queries
|
|
42
42
|
test 'fetching environment attributes' do
|
43
43
|
assert_empty result['errors']
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
expect(data['name']).must_equal(environment.name)
|
46
|
+
expect(data['id']).must_equal(global_id)
|
47
|
+
expect(data['createdAt']).must_equal(environment.created_at.utc.iso8601)
|
48
|
+
expect(data['updatedAt']).must_equal(environment.updated_at.utc.iso8601)
|
49
49
|
|
50
50
|
assert_collection environment.locations, data['locations']
|
51
51
|
assert_collection environment.organizations, data['organizations']
|
@@ -55,10 +55,10 @@ module Queries
|
|
55
55
|
test 'fetching puppetclass attributes' do
|
56
56
|
assert_empty result['errors']
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
expect(data['id']).must_equal global_id
|
59
|
+
expect(data['createdAt']).must_equal puppetclass.created_at.utc.iso8601
|
60
|
+
expect(data['updatedAt']).must_equal puppetclass.updated_at.utc.iso8601
|
61
|
+
expect(data['name']).must_equal puppetclass.name
|
62
62
|
|
63
63
|
assert_collection puppetclass.environments, data['environments']
|
64
64
|
assert_collection puppetclass.locations, data['locations']
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'integration_test_helper'
|
1
|
+
require 'integration_puppet_helper'
|
3
2
|
require 'integration/shared/host_finders'
|
4
3
|
require 'integration/shared/host_orchestration_stubs'
|
5
4
|
|
@@ -61,7 +60,8 @@ module ForemanPuppet
|
|
61
60
|
|
62
61
|
close_interfaces_modal
|
63
62
|
|
64
|
-
|
63
|
+
click_button('Submit')
|
64
|
+
find('h5', text: /myhost1*/)
|
65
65
|
|
66
66
|
host = Host::Managed.search_for('name ~ "myhost1"').first
|
67
67
|
assert_equal env2.name, host.puppet.environment.name
|
@@ -95,8 +95,8 @@ module ForemanPuppet
|
|
95
95
|
fill_in 'host_interfaces_attributes_0_mac', with: '00:11:11:11:11:11'
|
96
96
|
fill_in 'host_interfaces_attributes_0_ip', with: '1.1.1.1'
|
97
97
|
close_interfaces_modal
|
98
|
-
|
99
|
-
find('
|
98
|
+
click_button('Submit')
|
99
|
+
find('h5', text: /myhost1*/) # wait for host details page
|
100
100
|
|
101
101
|
host = Host::Managed.search_for('name ~ "myhost1"').first
|
102
102
|
assert_equal env.name, host.puppet.environment.name
|
@@ -112,8 +112,9 @@ module ForemanPuppet
|
|
112
112
|
visit edit_host_path(host)
|
113
113
|
|
114
114
|
select2 env1.name, from: 'host_puppet_attributes_environment_id'
|
115
|
-
|
116
|
-
|
115
|
+
click_button('Submit')
|
116
|
+
find('h5', text: /#{host.name}/)
|
117
|
+
assert_current_path(host_details_page_path(host), ignore_query: true)
|
117
118
|
|
118
119
|
host.reload
|
119
120
|
assert_equal env1.name, host.puppet.environment.name
|
@@ -202,7 +203,8 @@ module ForemanPuppet
|
|
202
203
|
assert puppetclass_params.has_selector?("a[data-tag='override']", visible: :hidden)
|
203
204
|
assert_equal('false', find("#s2id_host_lookup_values_attributes_#{lookup_key.id}_value .select2-chosen").text)
|
204
205
|
select2 'true', from: "host_lookup_values_attributes_#{lookup_key.id}_value"
|
205
|
-
|
206
|
+
click_button('Submit')
|
207
|
+
find('h5', text: /#{host.name}/)
|
206
208
|
|
207
209
|
visit edit_host_path(host)
|
208
210
|
switch_form_tab('Puppet ENC')
|
@@ -214,25 +216,27 @@ module ForemanPuppet
|
|
214
216
|
puppetclass: host.puppet.puppetclasses.first, overrides: { host.lookup_value_matcher => 'hostOverride' })
|
215
217
|
visit edit_host_path(host)
|
216
218
|
switch_form_tab('Puppet ENC')
|
217
|
-
|
219
|
+
expect(puppetclass_params.find('textarea').value).must_equal('hostOverride')
|
218
220
|
assert puppetclass_params.find('textarea:enabled')
|
219
221
|
puppetclass_params.find("a[data-tag='remove']").click
|
220
222
|
assert puppetclass_params.find('textarea:disabled')
|
221
|
-
|
223
|
+
click_button('Submit')
|
224
|
+
find('h5', text: /#{host.name}/)
|
222
225
|
|
223
226
|
visit edit_host_path(host)
|
224
227
|
switch_form_tab('Puppet ENC')
|
225
|
-
|
226
|
-
|
228
|
+
expect(puppetclass_params.find('textarea').value).must_equal('default')
|
229
|
+
expect(puppetclass_params).must_have_selector('textarea:disabled')
|
227
230
|
puppetclass_params.find("a[data-tag='override']").click
|
228
|
-
|
231
|
+
expect(puppetclass_params).must_have_selector('textarea:enabled')
|
229
232
|
puppetclass_params.find('textarea').set('userCustom')
|
230
|
-
|
233
|
+
click_button('Submit')
|
234
|
+
find('h5', text: /#{host.name}/)
|
231
235
|
|
232
236
|
visit edit_host_path(host)
|
233
237
|
switch_form_tab('Puppet ENC')
|
234
|
-
|
235
|
-
|
238
|
+
expect(puppetclass_params.find('textarea').value).must_equal('userCustom')
|
239
|
+
expect(puppetclass_params).must_have_selector('textarea:enabled')
|
236
240
|
end
|
237
241
|
|
238
242
|
test 'can override puppetclass lookup values' do
|
@@ -241,22 +245,22 @@ module ForemanPuppet
|
|
241
245
|
|
242
246
|
visit edit_host_path(host)
|
243
247
|
switch_form_tab('Puppet ENC')
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='remove']", visible: :visible)
|
249
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='override']", visible: :hidden)
|
250
|
+
expect(puppetclass_params.find('textarea').value).must_equal('hostOverride')
|
251
|
+
expect(puppetclass_params).must_have_selector('textarea:enabled')
|
248
252
|
|
249
253
|
puppetclass_params.find("a[data-tag='remove']").click
|
250
|
-
|
251
|
-
|
254
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='remove']", visible: :hidden)
|
255
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='override']", visible: :visible)
|
252
256
|
assert_equal('default', puppetclass_params.find('textarea').value)
|
253
257
|
assert puppetclass_params.find('textarea:disabled')
|
254
258
|
|
255
259
|
puppetclass_params.find("a[data-tag='override']").click
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='remove']", visible: :visible)
|
261
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='override']", visible: :hidden)
|
262
|
+
expect(puppetclass_params.find('textarea').value).must_equal('default')
|
263
|
+
expect(puppetclass_params).must_have_selector('textarea:enabled')
|
260
264
|
end
|
261
265
|
|
262
266
|
context 'with non-admin user' do
|
@@ -272,7 +276,7 @@ module ForemanPuppet
|
|
272
276
|
switch_form_tab('Puppet ENC')
|
273
277
|
assert puppetclass_params.find('textarea').disabled?
|
274
278
|
click_button('Submit')
|
275
|
-
|
279
|
+
find('h5', text: /#{host.name}/)
|
276
280
|
end
|
277
281
|
end
|
278
282
|
|
@@ -53,6 +53,17 @@ module ForemanPuppet
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
describe '#puppetclass_ids=' do
|
57
|
+
test 'allows empting classes' do
|
58
|
+
host = FactoryBot.create(:host, :with_puppet_enc,
|
59
|
+
environment: environment,
|
60
|
+
puppetclasses: [puppetclass_both])
|
61
|
+
host.attributes = { puppet_attributes: { puppetclass_ids: [] } }
|
62
|
+
assert host.save, 'Host could not be saved after updating puppetclasses'
|
63
|
+
assert_empty host.reload.all_puppetclasses, 'Puppetclasses were not removed successfuly'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
56
67
|
describe '#all_puppetclasses' do
|
57
68
|
test 'should return all classes for environment only' do
|
58
69
|
host = FactoryBot.create(:host, :with_puppet_enc,
|
@@ -107,13 +118,13 @@ module ForemanPuppet
|
|
107
118
|
test 'should return empty array if host has no hostgroup' do
|
108
119
|
host = FactoryBot.create(:host, :with_puppet_enc)
|
109
120
|
assert_not host.hostgroup
|
110
|
-
|
121
|
+
assert_empty host.puppet.parent_config_groups
|
111
122
|
end
|
112
123
|
|
113
124
|
test 'should return empty array if hostgroup do not have puppet data' do
|
114
125
|
hostgroup = FactoryBot.create(:hostgroup)
|
115
126
|
host = FactoryBot.create(:host, :with_puppet_enc, hostgroup: hostgroup)
|
116
|
-
|
127
|
+
assert_empty host.puppet.parent_config_groups
|
117
128
|
end
|
118
129
|
end
|
119
130
|
|
@@ -4,13 +4,13 @@ module ForemanPuppet
|
|
4
4
|
class HostTest < ActiveSupport::TestCase
|
5
5
|
test 'should read the Puppetserver URL from its proxy settings' do
|
6
6
|
host = FactoryBot.build_stubbed(:host)
|
7
|
-
|
8
|
-
|
7
|
+
expect(host.puppet_server_uri).must_be_nil
|
8
|
+
expect(host.puppetmaster).must_be_empty
|
9
9
|
|
10
10
|
proxy = FactoryBot.create(:puppet_smart_proxy, url: 'https://smartproxy.example.com:8443')
|
11
11
|
host.puppet_proxy = proxy
|
12
|
-
|
13
|
-
|
12
|
+
expect(host.puppet_server_uri.to_s).must_equal 'https://smartproxy.example.com:8140'
|
13
|
+
expect(host.puppetmaster).must_equal 'smartproxy.example.com'
|
14
14
|
|
15
15
|
features = {
|
16
16
|
'puppet' => {
|
@@ -18,8 +18,8 @@ module ForemanPuppet
|
|
18
18
|
},
|
19
19
|
}
|
20
20
|
SmartProxyFeature.import_features(proxy, features)
|
21
|
-
|
22
|
-
|
21
|
+
expect(host.puppet_server_uri.to_s).must_equal 'https://puppet.example.com:8140'
|
22
|
+
expect(host.puppetmaster).must_equal 'puppet.example.com'
|
23
23
|
end
|
24
24
|
|
25
25
|
test 'should find smart proxy ids' do
|
@@ -141,12 +141,12 @@ module ForemanPuppet
|
|
141
141
|
host = FactoryBot.create(:host, :with_puppet_enc, :with_config_group, :with_puppetclass, :with_parameter,
|
142
142
|
hostgroup: hostgroup, environment: hostgroup.puppet.environment)
|
143
143
|
copy = host.clone
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
144
|
+
expect(copy.puppet.individual_puppetclasses.map(&:id)).must_equal(host.puppet.individual_puppetclasses.map(&:id))
|
145
|
+
expect(copy.puppet.classes_in_groups.map(&:id)).must_equal(host.puppet.classes_in_groups.map(&:id))
|
146
|
+
expect(copy.puppet.classes.map(&:id)).must_equal(host.puppet.classes.map(&:id))
|
147
|
+
expect(copy.puppet.available_puppetclasses.map(&:id)).must_equal(host.puppet.available_puppetclasses.map(&:id))
|
148
|
+
expect(copy.puppet.host_classes.map(&:puppetclass_id)).must_equal(host.puppet.host_classes.map(&:puppetclass_id))
|
149
|
+
expect(copy.puppet.host_config_groups.map(&:config_group_id)).must_equal(host.puppet.host_config_groups.map(&:config_group_id))
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
@@ -232,20 +232,20 @@ module ForemanPuppet
|
|
232
232
|
nodeinfo['parameters']['special_info'] = 'secret' # smart variable on apache
|
233
233
|
|
234
234
|
info = host.info
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
235
|
+
expect(host.puppet.environment.name).must_equal(env.name)
|
236
|
+
expect(info.keys).must_include 'environment'
|
237
|
+
expect(info.keys).must_include 'parameters'
|
238
|
+
expect(info.keys).must_include 'classes'
|
239
239
|
# This worked in core, but it's beyond me how could have :shrug:
|
240
240
|
# assert_equal(classes_params, info['classes'])
|
241
241
|
# We are only importing classes in the method
|
242
|
-
|
242
|
+
expect(info['classes'].keys.sort).must_equal(classes_params.keys.sort)
|
243
243
|
parameters = info['parameters']
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
244
|
+
expect(parameters['puppetmaster']).must_equal 'puppet'
|
245
|
+
expect(parameters['root_pw']).must_equal 'xybxa6JUkz63w'
|
246
|
+
expect(parameters['foreman_interfaces'].first['ip']).must_equal '3.3.4.12'
|
247
|
+
expect(parameters.keys).must_include 'foreman_subnets'
|
248
|
+
expect(parameters.keys).must_include 'foreman_interfaces'
|
249
249
|
end
|
250
250
|
|
251
251
|
test 'should import from non-parameterized external nodes output' do
|
@@ -32,9 +32,9 @@ module ForemanPuppet
|
|
32
32
|
assert tmplt.save
|
33
33
|
end
|
34
34
|
assert_nil tmplt.template_kind
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
assert_empty tmplt.hostgroups
|
36
|
+
assert_empty tmplt.environments
|
37
|
+
assert_empty tmplt.template_combinations
|
38
38
|
end
|
39
39
|
|
40
40
|
test '#template_includes adds environment include' do
|
@@ -17,7 +17,7 @@ module ForemanPuppet
|
|
17
17
|
end
|
18
18
|
|
19
19
|
test 'looking for a nonexistent host returns no puppetclasses' do
|
20
|
-
|
20
|
+
assert_empty Puppetclass.search_for('host = imaginaryhost.nodomain.what')
|
21
21
|
end
|
22
22
|
|
23
23
|
test 'Puppetclass singularize from custom inflection' do
|