puppet 2.7.14 → 2.7.16
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +85 -0
- data/conf/redhat/puppet.spec +31 -4
- data/lib/puppet.rb +1 -1
- data/lib/puppet/defaults.rb +2 -3
- data/lib/puppet/face/module/install.rb +3 -3
- data/lib/puppet/face/module/search.rb +3 -3
- data/lib/puppet/indirector/face.rb +1 -1
- data/lib/puppet/network/http_pool.rb +17 -8
- data/lib/puppet/node/environment.rb +1 -3
- data/lib/puppet/parser/ast.rb +1 -1
- data/lib/puppet/parser/compiler.rb +2 -10
- data/lib/puppet/parser/functions/template.rb +2 -1
- data/lib/puppet/parser/lexer.rb +2 -2
- data/lib/puppet/parser/scope.rb +3 -2
- data/lib/puppet/provider/package/gem.rb +3 -1
- data/lib/puppet/provider/package/pkg.rb +18 -2
- data/lib/puppet/provider/service/gentoo.rb +5 -0
- data/lib/puppet/provider/service/init.rb +12 -14
- data/lib/puppet/provider/service/redhat.rb +1 -1
- data/lib/puppet/provider/service/upstart.rb +257 -7
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +6 -9
- data/lib/puppet/reports/http.rb +1 -1
- data/lib/puppet/reports/tagmail.rb +1 -1
- data/lib/puppet/type/cron.rb +5 -0
- data/lib/puppet/type/filebucket.rb +12 -0
- data/lib/puppet/util.rb +15 -9
- data/lib/puppet/util/colors.rb +94 -64
- data/lib/puppet/util/platform.rb +15 -0
- data/man/man5/puppet.conf.5 +73 -27
- data/man/man8/filebucket.8 +1 -1
- data/man/man8/pi.8 +1 -1
- data/man/man8/puppet-agent.8 +17 -17
- data/man/man8/puppet-apply.8 +8 -3
- data/man/man8/puppet-ca.8 +183 -0
- data/man/man8/puppet-catalog.8 +17 -10
- data/man/man8/puppet-cert.8 +1 -1
- data/man/man8/puppet-certificate.8 +27 -11
- data/man/man8/puppet-certificate_request.8 +12 -11
- data/man/man8/puppet-certificate_revocation_list.8 +11 -10
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +2 -2
- data/man/man8/puppet-doc.8 +15 -3
- data/man/man8/puppet-facts.8 +18 -8
- data/man/man8/puppet-file.8 +13 -22
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-inspect.8 +10 -2
- data/man/man8/puppet-instrumentation_data.8 +145 -0
- data/man/man8/puppet-instrumentation_listener.8 +222 -0
- data/man/man8/puppet-instrumentation_probe.8 +207 -0
- data/man/man8/puppet-key.8 +11 -7
- data/man/man8/puppet-kick.8 +35 -3
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-master.8 +1 -1
- data/man/man8/puppet-module.8 +451 -0
- data/man/man8/puppet-node.8 +64 -22
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-queue.8 +1 -1
- data/man/man8/puppet-report.8 +12 -8
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-resource_type.8 +11 -7
- data/man/man8/puppet-secret_agent.8 +1 -1
- data/man/man8/puppet-status.8 +11 -7
- data/man/man8/puppet.8 +1 -1
- data/man/man8/puppetca.8 +1 -1
- data/man/man8/puppetd.8 +17 -17
- data/man/man8/puppetdoc.8 +15 -3
- data/man/man8/puppetmasterd.8 +1 -1
- data/man/man8/puppetqd.8 +1 -1
- data/man/man8/puppetrun.8 +35 -3
- data/man/man8/ralsh.8 +1 -1
- data/spec/fixtures/unit/provider/package/gem/line-with-1.8.5-warning +14 -0
- data/spec/fixtures/unit/provider/package/pkg/{dummy → dummy_solaris10} +0 -0
- data/spec/fixtures/unit/provider/package/pkg/dummy_solaris11 +1 -0
- data/spec/fixtures/unit/provider/package/pkg/solaris11 +12 -0
- data/spec/fixtures/unit/provider/package/pkg/unknown_status +12 -0
- data/spec/fixtures/unit/provider/service/gentoo/rc_update_show +30 -0
- data/spec/integration/defaults_spec.rb +2 -7
- data/spec/integration/network/server/mongrel_spec.rb +16 -10
- data/spec/integration/network/server/webrick_spec.rb +16 -9
- data/spec/integration/provider/service/init_spec.rb +20 -4
- data/spec/integration/provider/ssh_authorized_key_spec.rb +119 -107
- data/spec/unit/face/module/install_spec.rb +16 -4
- data/spec/unit/network/http/api/v1_spec.rb +8 -0
- data/spec/unit/network/http_pool_spec.rb +80 -74
- data/spec/unit/node/environment_spec.rb +9 -4
- data/spec/unit/parser/ast/leaf_spec.rb +2 -2
- data/spec/unit/parser/ast_spec.rb +3 -3
- data/spec/unit/parser/compiler_spec.rb +0 -17
- data/spec/unit/parser/lexer_spec.rb +45 -2
- data/spec/unit/parser/scope_spec.rb +181 -14
- data/spec/unit/provider/package/gem_spec.rb +17 -1
- data/spec/unit/provider/package/pkg_spec.rb +70 -22
- data/spec/unit/provider/service/gentoo_spec.rb +237 -0
- data/spec/unit/provider/service/init_spec.rb +2 -2
- data/spec/unit/provider/service/redhat_spec.rb +2 -2
- data/spec/unit/provider/service/upstart_spec.rb +414 -5
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +24 -0
- data/spec/unit/reports/tagmail_spec.rb +50 -0
- data/spec/unit/type/cron_spec.rb +21 -1
- data/spec/unit/type/filebucket_spec.rb +39 -9
- data/spec/unit/util/colors_spec.rb +69 -0
- data/spec/unit/util/log/destinations_spec.rb +17 -9
- data/spec/unit/util/log_spec.rb +2 -1
- data/spec/unit/util_spec.rb +11 -0
- data/tasks/rake/gem.rake +1 -1
- data/tasks/rake/manpages.rake +11 -3
- data/test/network/handler/fileserver.rb +7 -1
- metadata +22 -10
@@ -4,25 +4,41 @@ require 'spec_helper'
|
|
4
4
|
provider = Puppet::Type.type(:service).provider(:init)
|
5
5
|
|
6
6
|
describe provider, :'fails_on_ruby_1.9.2' => true do
|
7
|
-
describe "when running on FreeBSD"
|
7
|
+
describe "when running on FreeBSD" do
|
8
|
+
before :each do
|
9
|
+
Facter.stubs(:value).with(:operatingsystem).returns 'FreeBSD'
|
10
|
+
end
|
11
|
+
|
8
12
|
it "should set its default path to include /etc/rc.d and /usr/local/etc/rc.d" do
|
9
13
|
provider.defpath.should == ["/etc/rc.d", "/usr/local/etc/rc.d"]
|
10
14
|
end
|
11
15
|
end
|
12
16
|
|
13
|
-
describe "when running on HP-UX"
|
17
|
+
describe "when running on HP-UX" do
|
18
|
+
before :each do
|
19
|
+
Facter.stubs(:value).with(:operatingsystem).returns 'HP-UX'
|
20
|
+
end
|
21
|
+
|
14
22
|
it "should set its default path to include /sbin/init.d" do
|
15
23
|
provider.defpath.should == "/sbin/init.d"
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
19
|
-
describe "when running on Archlinux"
|
27
|
+
describe "when running on Archlinux" do
|
28
|
+
before :each do
|
29
|
+
Facter.stubs(:value).with(:operatingsystem).returns 'Archlinux'
|
30
|
+
end
|
31
|
+
|
20
32
|
it "should set its default path to include /etc/rc.d" do
|
21
33
|
provider.defpath.should == "/etc/rc.d"
|
22
34
|
end
|
23
35
|
end
|
24
36
|
|
25
|
-
describe "when not running on FreeBSD, HP-UX or Archlinux"
|
37
|
+
describe "when not running on FreeBSD, HP-UX or Archlinux" do
|
38
|
+
before :each do
|
39
|
+
Facter.stubs(:value).with(:operatingsystem).returns 'RedHat'
|
40
|
+
end
|
41
|
+
|
26
42
|
it "should set its default path to include /etc/init.d" do
|
27
43
|
provider.defpath.should == "/etc/init.d"
|
28
44
|
end
|
@@ -1,39 +1,63 @@
|
|
1
|
-
#!/usr/bin/env
|
1
|
+
#!/usr/bin/env rspec
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'puppet/file_bucket/dipper'
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe Puppet::Type.type(:ssh_authorized_key).provider(:parsed), '(integration)', :unless => Puppet.features.microsoft_windows? do
|
7
7
|
include PuppetSpec::Files
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
let :fake_userfile do
|
10
|
+
tmpfile('authorized_keys.user')
|
11
|
+
end
|
12
|
+
|
13
|
+
let :fake_rootfile do
|
14
|
+
tmpfile('authorized_keys.root')
|
15
|
+
end
|
12
16
|
|
13
|
-
|
14
|
-
|
17
|
+
let :sample_rsa_keys do
|
18
|
+
[
|
15
19
|
'AAAAB3NzaC1yc2EAAAADAQABAAAAgQCi18JBZOq10X3w4f67nVhO0O3s5Y1vHH4UgMSM3ZnQwbC5hjGyYSi9UULOoQQoQynI/a0I9NL423/Xk/XJVIKCHcS8q6V2Wmjd+fLNelOjxxoW6mbIytEt9rDvwgq3Mof3/m21L3t2byvegR00a+ikKbmInPmKwjeWZpexCIsHzQ==', # 1024 bit
|
16
20
|
'AAAAB3NzaC1yc2EAAAADAQABAAAAgQDLClyvi3CsJw5Id6khZs2/+s11qOH4Gdp6iDioDsrIp0m8kSiPr71VGyQYAfPzzvHemHS7Xg0NkG1Kc8u9tRqBQfTvz7ubq0AT/g01+4P2hQ/soFkuwlUG/HVnnaYb6N0Qp5SHWvD5vBE2nFFQVpP5GrSctPtHSjzJq/i+6LYhmQ==', # 1024 bit
|
17
21
|
'AAAAB3NzaC1yc2EAAAADAQABAAABAQDLygAO6txXkh9FNV8xSsBkATeqLbHzS7sFjGI3gt0Dx6q3LjyKwbhQ1RLf28kd5G6VWiXmClU/RtiPdUz8nrGuun++2mrxzrXrvpR9dq1lygLQ2wn2cI35dN5bjRMtXy3decs6HUhFo9MoNwX250rUWfdCyNPhGIp6OOfmjdy+UeLGNxq9wDx6i4bT5tVVSqVRtsEfw9+ICXchzl85QudjneVVpP+thriPZXfXA5eaGwAo/dmoKOIhUwF96gpdLqzNtrGQuxPbV80PTbGv9ZtAtTictxaDz8muXO7he9pXmchUpxUKtMFjHkL0FAZ9tRPmv3RA30sEr2fZ8+LKvnE50w0' #2048 Bit
|
18
22
|
]
|
19
|
-
|
23
|
+
end
|
24
|
+
|
25
|
+
let :sample_dsa_keys do
|
26
|
+
[
|
20
27
|
'AAAAB3NzaC1kc3MAAACBAOPck2O8MIDSqxPSnvENt6tzRrKJ5oOhB6Nc6oEcWm+VEH1gvuxdiRqwoMgRwyEf1yUd+UAcLw3a6Jn+EtFyEBN/5WF+4Tt4xTxZ0Pfik2Wc5uqHbQ2dkmOoXiAOYPiD3JUQ1Xwm/J0CgetjitoLfzAGdCNhMqguqAuHcVJ78ZZbAAAAFQCIBKFYZ+I18I+dtgteirXh+VVEEwAAAIEAs1yvQ/wnLLrRCM660pF4kBiw3D6dJfMdCXWQpn0hZmkBQSIzZv4Wuk3giei5luxscDxNc+y3CTXtnyG4Kt1Yi2sOdvhRI3rX8tD+ejn8GHazM05l5VIo9uu4AQPIE32iV63IqgApSBbJ6vDJW91oDH0J492WdLCar4BS/KE3cRwAAACBAN0uSDyJqYLRsfYcFn4HyVf6TJxQm1IcwEt6GcJVzgjri9VtW7FqY5iBqa9B9Zdh5XXAYJ0XLsWQCcrmMHM2XGHGpA4gL9VlCJ/0QvOcXxD2uK7IXwAVUA7g4V4bw8EVnFv2Flufozhsp+4soo1xiYc5jiFVHwVlk21sMhAtKAeF' # 1024 Bit
|
21
28
|
]
|
29
|
+
end
|
22
30
|
|
23
|
-
|
24
|
-
|
25
|
-
"ssh-
|
26
|
-
"ssh-
|
31
|
+
let :sample_lines do
|
32
|
+
[
|
33
|
+
"ssh-rsa #{sample_rsa_keys[1]} root@someotherhost",
|
34
|
+
"ssh-dss #{sample_dsa_keys[0]} root@anywhere",
|
35
|
+
"ssh-rsa #{sample_rsa_keys[2]} paul",
|
36
|
+
"ssh-rsa #{sample_rsa_keys[2]} dummy"
|
27
37
|
]
|
38
|
+
end
|
28
39
|
|
40
|
+
let :dummy do
|
41
|
+
Puppet::Type.type(:ssh_authorized_key).new(
|
42
|
+
:name => 'dummy',
|
43
|
+
:target => fake_userfile,
|
44
|
+
:user => 'nobody',
|
45
|
+
:ensure => :absent
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
before :each do
|
50
|
+
File.stubs(:chown)
|
51
|
+
File.stubs(:chmod)
|
52
|
+
Puppet::Util::SUIDManager.stubs(:asuser).yields
|
29
53
|
end
|
30
54
|
|
31
55
|
after :each do
|
32
|
-
|
56
|
+
described_class.clear # Work around bug #6628
|
33
57
|
end
|
34
58
|
|
35
59
|
def create_fake_key(username, content)
|
36
|
-
filename = (username == :root ?
|
60
|
+
filename = (username == :root ? fake_rootfile : fake_userfile )
|
37
61
|
File.open(filename, 'w') do |f|
|
38
62
|
content.each do |line|
|
39
63
|
f.puts line
|
@@ -42,8 +66,8 @@ describe "ssh_authorized_key provider (integration)", :unless => Puppet.features
|
|
42
66
|
end
|
43
67
|
|
44
68
|
def check_fake_key(username, expected_content)
|
45
|
-
filename = (username == :root ?
|
46
|
-
content = File.readlines(filename).map(&:chomp).sort.reject{ |x| x =~
|
69
|
+
filename = (username == :root ? fake_rootfile : fake_userfile )
|
70
|
+
content = File.readlines(filename).map(&:chomp).sort.reject{ |x| x =~ /^# HEADER:/ }
|
47
71
|
content.join("\n").should == expected_content.sort.join("\n")
|
48
72
|
end
|
49
73
|
|
@@ -58,150 +82,138 @@ describe "ssh_authorized_key provider (integration)", :unless => Puppet.features
|
|
58
82
|
catalog.apply
|
59
83
|
end
|
60
84
|
|
61
|
-
|
85
|
+
it "should not complain about empty lines and comments" do
|
86
|
+
described_class.expects(:flush).never
|
87
|
+
sample = ['',sample_lines[0],' ',sample_lines[1],'# just a comment','#and another']
|
88
|
+
create_fake_key(:user,sample)
|
89
|
+
run_in_catalog(dummy)
|
90
|
+
check_fake_key(:user, sample)
|
91
|
+
end
|
62
92
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
93
|
+
it "should keep empty lines and comments when modifying a file" do
|
94
|
+
create_fake_key(:user, ['',sample_lines[0],' ',sample_lines[3],'# just a comment','#and another'])
|
95
|
+
run_in_catalog(dummy)
|
96
|
+
check_fake_key(:user, ['',sample_lines[0],' ','# just a comment','#and another'])
|
97
|
+
end
|
69
98
|
|
70
|
-
|
99
|
+
describe "when managing one resource" do
|
71
100
|
|
72
|
-
|
73
|
-
|
101
|
+
describe "with ensure set to absent" do
|
102
|
+
let :example do
|
103
|
+
Puppet::Type.type(:ssh_authorized_key).new(
|
74
104
|
:name => 'root@hostname',
|
75
105
|
:type => :rsa,
|
76
|
-
:key =>
|
77
|
-
:target =>
|
106
|
+
:key => sample_rsa_keys[0],
|
107
|
+
:target => fake_rootfile,
|
78
108
|
:user => 'root',
|
79
109
|
:ensure => :absent
|
80
110
|
)
|
81
111
|
end
|
82
112
|
|
83
113
|
it "should not modify root's keyfile if resource is currently not present" do
|
84
|
-
create_fake_key(:root,
|
85
|
-
run_in_catalog(
|
86
|
-
check_fake_key(:root,
|
114
|
+
create_fake_key(:root, sample_lines)
|
115
|
+
run_in_catalog(example)
|
116
|
+
check_fake_key(:root, sample_lines)
|
87
117
|
end
|
88
118
|
|
89
119
|
it "remove the key from root's keyfile if resource is currently present" do
|
90
|
-
create_fake_key(:root,
|
91
|
-
run_in_catalog(
|
92
|
-
check_fake_key(:root,
|
120
|
+
create_fake_key(:root, sample_lines + ["ssh-rsa #{sample_rsa_keys[0]} root@hostname"])
|
121
|
+
run_in_catalog(example)
|
122
|
+
check_fake_key(:root, sample_lines)
|
93
123
|
end
|
94
|
-
|
95
124
|
end
|
96
125
|
|
97
126
|
describe "when ensure is present" do
|
98
|
-
|
99
|
-
|
100
|
-
@example = Puppet::Type.type(:ssh_authorized_key).new(
|
127
|
+
let :example do
|
128
|
+
Puppet::Type.type(:ssh_authorized_key).new(
|
101
129
|
:name => 'root@hostname',
|
102
130
|
:type => :rsa,
|
103
|
-
:key =>
|
104
|
-
:target =>
|
131
|
+
:key => sample_rsa_keys[0],
|
132
|
+
:target => fake_rootfile,
|
105
133
|
:user => 'root',
|
106
134
|
:ensure => :present
|
107
135
|
)
|
108
|
-
|
109
|
-
# just a dummy so the parsedfile provider is aware
|
110
|
-
# of the user's authorized_keys file
|
111
|
-
@dummy = Puppet::Type.type(:ssh_authorized_key).new(
|
112
|
-
:name => 'dummy',
|
113
|
-
:target => @fake_userfile,
|
114
|
-
:user => 'nobody',
|
115
|
-
:ensure => :absent
|
116
|
-
)
|
117
136
|
end
|
118
137
|
|
138
|
+
# just a dummy so the parsedfile provider is aware
|
139
|
+
# of the user's authorized_keys file
|
140
|
+
|
119
141
|
it "should add the key if it is not present" do
|
120
|
-
create_fake_key(:root,
|
121
|
-
run_in_catalog(
|
122
|
-
check_fake_key(:root,
|
142
|
+
create_fake_key(:root, sample_lines)
|
143
|
+
run_in_catalog(example)
|
144
|
+
check_fake_key(:root, sample_lines + ["ssh-rsa #{sample_rsa_keys[0]} root@hostname" ])
|
123
145
|
end
|
124
146
|
|
125
147
|
it "should modify the type if type is out of sync" do
|
126
|
-
create_fake_key(:root
|
127
|
-
run_in_catalog(
|
128
|
-
check_fake_key(:root,
|
148
|
+
create_fake_key(:root,sample_lines + [ "ssh-dss #{sample_rsa_keys[0]} root@hostname" ])
|
149
|
+
run_in_catalog(example)
|
150
|
+
check_fake_key(:root, sample_lines + [ "ssh-rsa #{sample_rsa_keys[0]} root@hostname" ])
|
129
151
|
end
|
130
152
|
|
131
153
|
it "should modify the key if key is out of sync" do
|
132
|
-
create_fake_key(:root
|
133
|
-
run_in_catalog(
|
134
|
-
check_fake_key(:root,
|
154
|
+
create_fake_key(:root,sample_lines + [ "ssh-rsa #{sample_rsa_keys[1]} root@hostname" ])
|
155
|
+
run_in_catalog(example)
|
156
|
+
check_fake_key(:root, sample_lines + [ "ssh-rsa #{sample_rsa_keys[0]} root@hostname" ])
|
135
157
|
end
|
136
158
|
|
137
159
|
it "should remove the key from old file if target is out of sync" do
|
138
|
-
create_fake_key(:user, [
|
139
|
-
create_fake_key(:root, [
|
140
|
-
run_in_catalog(
|
141
|
-
check_fake_key(:user, [
|
142
|
-
#check_fake_key(:root, [
|
160
|
+
create_fake_key(:user, [ sample_lines[0], "ssh-rsa #{sample_rsa_keys[0]} root@hostname" ])
|
161
|
+
create_fake_key(:root, [ sample_lines[1], sample_lines[2] ])
|
162
|
+
run_in_catalog(example, dummy)
|
163
|
+
check_fake_key(:user, [ sample_lines[0] ])
|
164
|
+
#check_fake_key(:root, [ sample_lines[1], sample_lines[2], "ssh-rsa #{sample_rsa_keys[0]} root@hostname" ])
|
143
165
|
end
|
144
166
|
|
145
167
|
it "should add the key to new file if target is out of sync" do
|
146
|
-
create_fake_key(:user, [
|
147
|
-
create_fake_key(:root, [
|
148
|
-
run_in_catalog(
|
149
|
-
#check_fake_key(:user, [
|
150
|
-
check_fake_key(:root, [
|
168
|
+
create_fake_key(:user, [ sample_lines[0], "ssh-rsa #{sample_rsa_keys[0]} root@hostname" ])
|
169
|
+
create_fake_key(:root, [ sample_lines[1], sample_lines[2] ])
|
170
|
+
run_in_catalog(example, dummy)
|
171
|
+
#check_fake_key(:user, [ sample_lines[0] ])
|
172
|
+
check_fake_key(:root, [ sample_lines[1], sample_lines[2], "ssh-rsa #{sample_rsa_keys[0]} root@hostname" ])
|
151
173
|
end
|
152
174
|
|
153
175
|
it "should modify options if options are out of sync" do
|
154
|
-
|
155
|
-
create_fake_key(:root,
|
156
|
-
run_in_catalog(
|
157
|
-
check_fake_key(:root,
|
176
|
+
example[:options]=[ 'from="*.domain1,host1.domain2"', 'no-port-forwarding', 'no-pty' ]
|
177
|
+
create_fake_key(:root, sample_lines + [ "from=\"*.false,*.false2\",no-port-forwarding,no-pty ssh-rsa #{sample_rsa_keys[0]} root@hostname"])
|
178
|
+
run_in_catalog(example)
|
179
|
+
check_fake_key(:root, sample_lines + [ "from=\"*.domain1,host1.domain2\",no-port-forwarding,no-pty ssh-rsa #{sample_rsa_keys[0]} root@hostname"] )
|
158
180
|
end
|
159
|
-
|
160
181
|
end
|
161
|
-
|
162
182
|
end
|
163
183
|
|
164
184
|
describe "when managing two resource" do
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
:user => 'nobody',
|
186
|
-
:ensure => :present
|
187
|
-
)
|
188
|
-
end
|
185
|
+
let :examples do
|
186
|
+
resources = []
|
187
|
+
resources << Puppet::Type.type(:ssh_authorized_key).new(
|
188
|
+
:name => 'root@hostname',
|
189
|
+
:type => :rsa,
|
190
|
+
:key => sample_rsa_keys[0],
|
191
|
+
:target => fake_rootfile,
|
192
|
+
:user => 'root',
|
193
|
+
:ensure => :present
|
194
|
+
)
|
195
|
+
resources << Puppet::Type.type(:ssh_authorized_key).new(
|
196
|
+
:name => 'user@hostname',
|
197
|
+
:key => sample_rsa_keys[1],
|
198
|
+
:type => :rsa,
|
199
|
+
:target => fake_userfile,
|
200
|
+
:user => 'nobody',
|
201
|
+
:ensure => :present
|
202
|
+
)
|
203
|
+
resources
|
204
|
+
end
|
189
205
|
|
190
206
|
describe "and both keys are absent" do
|
191
|
-
|
192
207
|
before :each do
|
193
|
-
create_fake_key(:root,
|
194
|
-
create_fake_key(:user,
|
208
|
+
create_fake_key(:root, sample_lines)
|
209
|
+
create_fake_key(:user, sample_lines)
|
195
210
|
end
|
196
211
|
|
197
212
|
it "should add both keys" do
|
198
|
-
run_in_catalog(
|
199
|
-
check_fake_key(:root,
|
200
|
-
check_fake_key(:user,
|
213
|
+
run_in_catalog(*examples)
|
214
|
+
check_fake_key(:root, sample_lines + [ "ssh-rsa #{sample_rsa_keys[0]} root@hostname" ])
|
215
|
+
check_fake_key(:user, sample_lines + [ "ssh-rsa #{sample_rsa_keys[1]} user@hostname" ])
|
201
216
|
end
|
202
|
-
|
203
217
|
end
|
204
|
-
|
205
218
|
end
|
206
|
-
|
207
219
|
end
|
@@ -3,6 +3,7 @@ require 'puppet/face'
|
|
3
3
|
require 'puppet/module_tool'
|
4
4
|
|
5
5
|
describe "puppet module install" do
|
6
|
+
include PuppetSpec::Files
|
6
7
|
|
7
8
|
subject { Puppet::Face[:module, :current] }
|
8
9
|
|
@@ -24,10 +25,10 @@ describe "puppet module install" do
|
|
24
25
|
end
|
25
26
|
|
26
27
|
let(:sep) { File::PATH_SEPARATOR }
|
27
|
-
let(:fakefirstpath) { "/my/fake/modpath" }
|
28
|
-
let(:fakesecondpath) { "/other/fake/path" }
|
28
|
+
let(:fakefirstpath) { make_absolute("/my/fake/modpath") }
|
29
|
+
let(:fakesecondpath) { make_absolute("/other/fake/path") }
|
29
30
|
let(:fakemodpath) { "#{fakefirstpath}#{sep}#{fakesecondpath}" }
|
30
|
-
let(:fakedirpath) { "/my/fake/path" }
|
31
|
+
let(:fakedirpath) { make_absolute("/my/fake/path") }
|
31
32
|
|
32
33
|
context "without any options" do
|
33
34
|
it "should require a name" do
|
@@ -49,7 +50,7 @@ describe "puppet module install" do
|
|
49
50
|
end
|
50
51
|
|
51
52
|
it "should accept the --target-dir option" do
|
52
|
-
options[:target_dir] = "/foo/puppet/modules"
|
53
|
+
options[:target_dir] = make_absolute("/foo/puppet/modules")
|
53
54
|
expected_options.merge!(options)
|
54
55
|
expected_options[:modulepath] = "#{options[:target_dir]}#{sep}#{fakemodpath}"
|
55
56
|
|
@@ -90,6 +91,17 @@ describe "puppet module install" do
|
|
90
91
|
end
|
91
92
|
|
92
93
|
describe "when target-dir option is passed" do
|
94
|
+
it "should expand the target directory" do
|
95
|
+
options[:target_dir] = "modules"
|
96
|
+
expanded_path = File.expand_path("modules")
|
97
|
+
expected_options.merge!(options)
|
98
|
+
expected_options[:target_dir] = expanded_path
|
99
|
+
expected_options[:modulepath] = "#{expanded_path}#{sep}#{fakemodpath}"
|
100
|
+
|
101
|
+
Puppet::ModuleTool::Applications::Installer.expects(:run).with("puppetlabs-apache", expected_options).once
|
102
|
+
subject.install("puppetlabs-apache", options)
|
103
|
+
end
|
104
|
+
|
93
105
|
it "should set target-dir to be first path of modulepath" do
|
94
106
|
options[:target_dir] = fakedirpath
|
95
107
|
expected_options[:target_dir] = fakedirpath
|
@@ -54,6 +54,14 @@ describe Puppet::Network::HTTP::API::V1 do
|
|
54
54
|
@tester.uri2indirection("GET", "/env/foo/bar", {})[3][:environment].should be_a Puppet::Node::Environment
|
55
55
|
end
|
56
56
|
|
57
|
+
it "should not pass a buck_path parameter through (See Bugs #13553, #13518, #13511)" do
|
58
|
+
@tester.uri2indirection("GET", "/env/foo/bar", { :bucket_path => "/malicious/path" })[3].should_not include({ :bucket_path => "/malicious/path" })
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should pass allowed parameters through" do
|
62
|
+
@tester.uri2indirection("GET", "/env/foo/bar", { :allowed_param => "value" })[3].should include({ :allowed_param => "value" })
|
63
|
+
end
|
64
|
+
|
57
65
|
it "should use the second field of the URI as the indirection name" do
|
58
66
|
@tester.uri2indirection("GET", "/env/foo/bar", {})[0].should == "foo"
|
59
67
|
end
|
@@ -14,122 +14,128 @@ describe Puppet::Network::HttpPool do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "when managing http instances" do
|
17
|
-
|
18
|
-
settings.each do |param, value|
|
19
|
-
Puppet.settings.stubs(:value).with(param).returns(value)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
before do
|
17
|
+
before :each do
|
24
18
|
# All of the cert stuff is tested elsewhere
|
25
19
|
Puppet::Network::HttpPool.stubs(:cert_setup)
|
26
20
|
end
|
27
21
|
|
28
22
|
it "should return an http instance created with the passed host and port" do
|
29
|
-
http =
|
30
|
-
Net::HTTP
|
31
|
-
|
23
|
+
http = Puppet::Network::HttpPool.http_instance("me", 54321)
|
24
|
+
http.should be_an_instance_of Net::HTTP
|
25
|
+
http.address.should == 'me'
|
26
|
+
http.port.should == 54321
|
32
27
|
end
|
33
28
|
|
34
29
|
it "should enable ssl on the http instance" do
|
35
|
-
Puppet::Network::HttpPool.http_instance("me", 54321).
|
30
|
+
Puppet::Network::HttpPool.http_instance("me", 54321).should be_use_ssl
|
36
31
|
end
|
37
32
|
|
38
|
-
|
39
|
-
Puppet::Network::HttpPool.http_instance("me", 54321)
|
40
|
-
|
33
|
+
context "proxy and timeout settings should propagate" do
|
34
|
+
subject { Puppet::Network::HttpPool.http_instance("me", 54321) }
|
35
|
+
before :each do
|
36
|
+
Puppet[:http_proxy_host] = "myhost"
|
37
|
+
Puppet[:http_proxy_port] = 432
|
38
|
+
Puppet[:configtimeout] = 120
|
39
|
+
end
|
41
40
|
|
42
|
-
|
43
|
-
|
41
|
+
its(:open_timeout) { should == Puppet[:configtimeout] }
|
42
|
+
its(:read_timeout) { should == Puppet[:configtimeout] }
|
43
|
+
its(:proxy_address) { should == Puppet[:http_proxy_host] }
|
44
|
+
its(:proxy_port) { should == Puppet[:http_proxy_port] }
|
44
45
|
end
|
45
46
|
|
46
|
-
it "should
|
47
|
-
|
48
|
-
Puppet::Network::HttpPool.http_instance("me", 54321).
|
47
|
+
it "should not set a proxy if the value is 'none'" do
|
48
|
+
Puppet[:http_proxy_host] = 'none'
|
49
|
+
Puppet::Network::HttpPool.http_instance("me", 54321).proxy_address.should be_nil
|
49
50
|
end
|
50
51
|
|
51
52
|
it "should not cache http instances" do
|
52
|
-
|
53
|
-
|
54
|
-
Puppet::Network::HttpPool.http_instance("me", 54321).should_not equal(old)
|
53
|
+
Puppet::Network::HttpPool.http_instance("me", 54321).
|
54
|
+
should_not equal Puppet::Network::HttpPool.http_instance("me", 54321)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
describe "when
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
@cert = stub 'cert', :content => "real_cert"
|
65
|
-
@key = stub 'key', :content => "real_key"
|
66
|
-
@host = stub 'host', :certificate => @cert, :key => @key, :ssl_store => @store
|
67
|
-
|
68
|
-
Puppet[:confdir] = "/sometthing/else"
|
69
|
-
Puppet.settings.stubs(:value).returns "/some/file"
|
70
|
-
Puppet.settings.stubs(:value).with(:hostcert).returns "/host/cert"
|
71
|
-
Puppet.settings.stubs(:value).with(:localcacert).returns "/local/ca/cert"
|
72
|
-
|
73
|
-
FileTest.stubs(:exist?).with("/host/cert").returns true
|
74
|
-
FileTest.stubs(:exist?).with("/local/ca/cert").returns true
|
75
|
-
|
76
|
-
Puppet::Network::HttpPool.stubs(:ssl_host).returns @host
|
58
|
+
describe "when doing SSL setup for http instances" do
|
59
|
+
let :http do
|
60
|
+
http = Net::HTTP.new('localhost', 443)
|
61
|
+
http.use_ssl = true
|
62
|
+
http
|
77
63
|
end
|
78
64
|
|
79
|
-
|
80
|
-
Puppet.settings.clear
|
81
|
-
end
|
65
|
+
let :store do stub('store') end
|
82
66
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
Puppet::Network::HttpPool.cert_setup(@http)
|
87
|
-
end
|
67
|
+
before :each do
|
68
|
+
Puppet[:hostcert] = '/host/cert'
|
69
|
+
Puppet[:localcacert] = '/local/ca/cert'
|
88
70
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
Puppet::Network::HttpPool.
|
71
|
+
cert = stub 'cert', :content => 'real_cert'
|
72
|
+
key = stub 'key', :content => 'real_key'
|
73
|
+
host = stub 'host', :certificate => cert, :key => key, :ssl_store => store
|
74
|
+
Puppet::Network::HttpPool.stubs(:ssl_host).returns(host)
|
93
75
|
end
|
94
76
|
|
95
|
-
|
96
|
-
|
77
|
+
shared_examples "HTTPS setup without all certificates" do
|
78
|
+
subject { Puppet::Network::HttpPool.cert_setup(http); http }
|
97
79
|
|
98
|
-
|
80
|
+
it { should be_use_ssl }
|
81
|
+
its(:cert) { should be_nil }
|
82
|
+
its(:cert_store) { should be_nil }
|
83
|
+
its(:ca_file) { should be_nil }
|
84
|
+
its(:key) { should be_nil }
|
85
|
+
its(:verify_mode) { should == OpenSSL::SSL::VERIFY_NONE }
|
99
86
|
end
|
100
87
|
|
101
|
-
|
102
|
-
|
88
|
+
context "with neither a host cert or a local CA cert" do
|
89
|
+
before :each do
|
90
|
+
FileTest.stubs(:exist?).with(Puppet[:hostcert]).returns(false)
|
91
|
+
FileTest.stubs(:exist?).with(Puppet[:localcacert]).returns(false)
|
92
|
+
end
|
103
93
|
|
104
|
-
|
94
|
+
include_examples "HTTPS setup without all certificates"
|
105
95
|
end
|
106
96
|
|
107
|
-
|
108
|
-
|
97
|
+
context "with there is no host certificate" do
|
98
|
+
before :each do
|
99
|
+
FileTest.stubs(:exist?).with(Puppet[:hostcert]).returns(false)
|
100
|
+
FileTest.stubs(:exist?).with(Puppet[:localcacert]).returns(true)
|
101
|
+
end
|
109
102
|
|
110
|
-
|
103
|
+
include_examples "HTTPS setup without all certificates"
|
111
104
|
end
|
112
105
|
|
113
|
-
|
114
|
-
|
106
|
+
context "with there is no local CA certificate" do
|
107
|
+
before :each do
|
108
|
+
FileTest.stubs(:exist?).with(Puppet[:hostcert]).returns(true)
|
109
|
+
FileTest.stubs(:exist?).with(Puppet[:localcacert]).returns(false)
|
110
|
+
end
|
115
111
|
|
116
|
-
|
112
|
+
include_examples "HTTPS setup without all certificates"
|
117
113
|
end
|
118
114
|
|
119
|
-
|
120
|
-
Puppet.
|
121
|
-
FileTest.stubs(:exist?).with(Puppet[:hostcert]).returns true
|
115
|
+
context "with both the host and CA cert" do
|
116
|
+
subject { Puppet::Network::HttpPool.cert_setup(http); http }
|
122
117
|
|
123
|
-
|
124
|
-
|
125
|
-
|
118
|
+
before :each do
|
119
|
+
FileTest.expects(:exist?).with(Puppet[:hostcert]).returns(true)
|
120
|
+
FileTest.expects(:exist?).with(Puppet[:localcacert]).returns(true)
|
121
|
+
end
|
126
122
|
|
127
|
-
|
123
|
+
it { should be_use_ssl }
|
124
|
+
its(:cert_store) { should equal store }
|
125
|
+
its(:cert) { should == "real_cert" }
|
126
|
+
its(:key) { should == "real_key" }
|
127
|
+
its(:verify_mode) { should == OpenSSL::SSL::VERIFY_PEER }
|
128
|
+
its(:ca_file) { should == Puppet[:localcacert] }
|
128
129
|
end
|
129
130
|
|
130
131
|
it "should set up certificate information when creating http instances" do
|
131
|
-
Puppet::Network::HttpPool.expects(:cert_setup).with
|
132
|
-
|
132
|
+
Puppet::Network::HttpPool.expects(:cert_setup).with do |http|
|
133
|
+
http.should be_an_instance_of Net::HTTP
|
134
|
+
http.address.should == "one"
|
135
|
+
http.port.should == 2
|
136
|
+
end
|
137
|
+
|
138
|
+
Puppet::Network::HttpPool.http_instance("one", 2)
|
133
139
|
end
|
134
140
|
end
|
135
141
|
end
|