foreman_puppet 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccf0e28e1eb6fd2a88980db29a6c6f30d1bb972bd58800d444c4507bad61b771
|
4
|
+
data.tar.gz: a4828f6dd4e0df4e6210c2bbcfe624c247758a3566dcb5f514dcc2de6246ed45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9df9c3ae3fb503fd9c3f21bd692af6a194eab2ec021846ab4089d8b21d55dcb7d68ee6b33467d98f308401abf4aad2a22dd89ca8ae78bb0555760b3ed29ca787
|
7
|
+
data.tar.gz: 2a17492b79af4c0c53523b678f05b632d61e436421f19c1af37f8baa6e2259ca719416b08fe3555aab4f1533b09641feba575e60b2498747a040c41aa78c4dde
|
@@ -4,68 +4,88 @@ module ForemanPuppet
|
|
4
4
|
class HostgroupsControllerTest < ActionController::TestCase
|
5
5
|
tests ::HostgroupsController
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
context 'with core routes' do
|
8
|
+
describe '#nest' do
|
9
|
+
it 'works without puppetclasses' do
|
10
|
+
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_puppetclass)
|
11
|
+
|
12
|
+
post :nest, params: { id: hostgroup.id }, session: set_session_user
|
13
|
+
assert_template 'new'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'works with puppetclasses' do
|
17
|
+
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_puppetclass)
|
18
|
+
|
19
|
+
post :nest, params: { id: hostgroup.id }, session: set_session_user
|
20
|
+
assert_template 'new'
|
21
|
+
end
|
22
|
+
end
|
9
23
|
end
|
10
24
|
|
11
|
-
|
25
|
+
context 'with plugin routes' do
|
12
26
|
setup do
|
13
|
-
@
|
14
|
-
@puppetclass = FactoryBot.create(:puppetclass)
|
15
|
-
@hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, environment: @environment)
|
16
|
-
@params = {
|
17
|
-
id: @hostgroup.id,
|
18
|
-
hostgroup: {
|
19
|
-
name: @hostgroup.name,
|
20
|
-
environment_id: '',
|
21
|
-
puppetclass_ids: [@puppetclass.id],
|
22
|
-
},
|
23
|
-
}
|
27
|
+
@routes = ForemanPuppet::Engine.routes
|
24
28
|
end
|
25
29
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
describe '#environment_selected' do
|
31
|
+
setup do
|
32
|
+
@environment = FactoryBot.create(:environment)
|
33
|
+
@puppetclass = FactoryBot.create(:puppetclass)
|
34
|
+
@hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, environment: @environment)
|
35
|
+
@params = {
|
36
|
+
id: @hostgroup.id,
|
37
|
+
hostgroup: {
|
38
|
+
name: @hostgroup.name,
|
39
|
+
environment_id: '',
|
40
|
+
puppetclass_ids: [@puppetclass.id],
|
41
|
+
},
|
42
|
+
}
|
43
|
+
end
|
33
44
|
|
34
|
-
|
35
|
-
|
36
|
-
other_environment = FactoryBot.create(:environment)
|
37
|
-
@params[:hostgroup][:environment_id] = other_environment.id
|
45
|
+
test 'should return the selected puppet classes on environment change' do
|
46
|
+
assert_equal 0, @hostgroup.puppet.puppetclasses.length
|
38
47
|
|
39
48
|
post :environment_selected, params: @params, session: set_session_user, xhr: true
|
40
|
-
assert_equal assigns(:
|
49
|
+
assert_equal(1, assigns(:hostgroup).puppet.puppetclasses.length)
|
50
|
+
assert_include assigns(:hostgroup).puppet.puppetclasses, @puppetclass
|
41
51
|
end
|
42
|
-
end
|
43
52
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
53
|
+
context 'environment_id param is set' do
|
54
|
+
test 'it will take the hostgroup params environment_id' do
|
55
|
+
other_environment = FactoryBot.create(:environment)
|
56
|
+
@params[:hostgroup][:environment_id] = other_environment.id
|
57
|
+
|
58
|
+
post :environment_selected, params: @params, session: set_session_user, xhr: true
|
59
|
+
assert_equal assigns(:environment), other_environment
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
test 'should not escape lookup values on environment change' do
|
64
|
+
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, environment: @environment, puppetclasses: [@puppetclass])
|
65
|
+
lookup_key = FactoryBot.create(:puppetclass_lookup_key, :array, default_value: %w[a b],
|
66
|
+
override: true,
|
67
|
+
puppetclass: @puppetclass,
|
68
|
+
overrides: { "hostgroup=#{hostgroup.name}" => %w[c d] })
|
69
|
+
lookup_value = lookup_key.lookup_values.first
|
70
|
+
FactoryBot.create(:environment_class, puppetclass: @puppetclass, environment: @environment, puppetclass_lookup_key: lookup_key)
|
71
|
+
|
72
|
+
# sending exactly what the host form would send which is lookup_value.value_before_type_cast
|
73
|
+
lk = { 'lookup_values_attributes' => { lookup_key.id.to_s => { 'value' => lookup_value.value_before_type_cast,
|
74
|
+
'id' => lookup_value.id,
|
75
|
+
'lookup_key_id' => lookup_key.id,
|
76
|
+
'_destroy' => false } } }
|
77
|
+
|
78
|
+
params = {
|
79
|
+
hostgroup_id: hostgroup.id,
|
80
|
+
hostgroup: hostgroup.attributes.merge(lk),
|
81
|
+
}
|
82
|
+
|
83
|
+
# environment change calls puppetclass_parameters which caused the extra escaping
|
84
|
+
post :puppetclass_parameters, params: params, session: set_session_user, xhr: true
|
85
|
+
|
86
|
+
# if this was escaped during refresh_host the value in response.body after unescapeHTML would include "[\\\"c\\\",\\\"d\\\"]"
|
87
|
+
assert_includes CGI.unescapeHTML(response.body), '["c","d"]'
|
88
|
+
end
|
69
89
|
end
|
70
90
|
end
|
71
91
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-09-
|
12
|
+
date: 2021-09-16 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Allow assigning Puppet environmets and classes to the Foreman Hosts.
|
15
15
|
email:
|