puppet 2.7.1 → 2.7.3
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 +225 -1
- data/CONTRIBUTING.md +299 -0
- data/README.md +0 -1
- data/conf/redhat/puppet.spec +132 -25
- data/conf/solaris/pkginfo +1 -1
- data/conf/suse/puppet.spec +5 -2
- data/ext/envpuppet +56 -3
- data/ext/vim/README +2 -1
- data/ext/vim/ftplugin/puppet.vim +94 -0
- data/ext/vim/indent/puppet.vim +76 -0
- data/lib/puppet.rb +2 -3
- data/lib/puppet/application/agent.rb +7 -7
- data/lib/puppet/application/apply.rb +20 -8
- data/lib/puppet/application/ca.rb +5 -0
- data/lib/puppet/application/cert.rb +2 -1
- data/lib/puppet/application/certificate.rb +0 -5
- data/lib/puppet/application/device.rb +4 -4
- data/lib/puppet/application/doc.rb +23 -12
- data/lib/puppet/application/face_base.rb +2 -1
- data/lib/puppet/application/inspect.rb +5 -2
- data/lib/puppet/configurer.rb +60 -56
- data/lib/puppet/configurer/fact_handler.rb +6 -1
- data/lib/puppet/defaults.rb +20 -1
- data/lib/puppet/face/ca.rb +233 -0
- data/lib/puppet/face/certificate.rb +15 -11
- data/lib/puppet/face/certificate_request.rb +9 -11
- data/lib/puppet/face/certificate_revocation_list.rb +5 -7
- data/lib/puppet/face/node/clean.rb +154 -0
- data/lib/puppet/face/status.rb +1 -0
- data/lib/puppet/file_serving/configuration/parser.rb +6 -13
- data/lib/puppet/indirector/exec.rb +3 -3
- data/lib/puppet/indirector/face.rb +17 -7
- data/lib/puppet/indirector/report/processor.rb +29 -16
- data/lib/puppet/indirector/rest.rb +42 -7
- data/lib/puppet/indirector/yaml.rb +5 -0
- data/lib/puppet/interface.rb +7 -2
- data/lib/puppet/interface/action.rb +57 -23
- data/lib/puppet/interface/action_manager.rb +10 -5
- data/lib/puppet/interface/face_collection.rb +43 -52
- data/lib/puppet/interface/option.rb +19 -0
- data/lib/puppet/interface/option_builder.rb +13 -0
- data/lib/puppet/interface/option_manager.rb +2 -1
- data/lib/puppet/metatype/manager.rb +7 -20
- data/lib/puppet/module.rb +4 -1
- data/lib/puppet/network/authconfig.rb +3 -1
- data/lib/puppet/network/authstore.rb +14 -5
- data/lib/puppet/network/handler/fileserver.rb +3 -0
- data/lib/puppet/network/http/webrick.rb +1 -1
- data/lib/puppet/network/rest_authconfig.rb +6 -1
- data/lib/puppet/network/rest_authorization.rb +1 -1
- data/lib/puppet/parser/compiler.rb +8 -11
- data/lib/puppet/parser/functions.rb +1 -6
- data/lib/puppet/parser/functions/create_resources.rb +6 -5
- data/lib/puppet/parser/functions/regsubst.rb +26 -0
- data/lib/puppet/parser/functions/shellquote.rb +26 -0
- data/lib/puppet/parser/functions/sprintf.rb +26 -0
- data/lib/puppet/parser/grammar.ra +34 -60
- data/lib/puppet/parser/lexer.rb +5 -5
- data/lib/puppet/parser/parser.rb +913 -1196
- data/lib/puppet/parser/resource.rb +18 -1
- data/lib/puppet/parser/scope.rb +2 -2
- data/lib/puppet/provider/augeas/augeas.rb +42 -17
- data/lib/puppet/provider/mount/parsed.rb +19 -1
- data/lib/puppet/provider/naginator.rb +9 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +11 -8
- data/lib/puppet/provider/network_device.rb +1 -1
- data/lib/puppet/provider/package/aptitude.rb +1 -0
- data/lib/puppet/provider/package/pacman.rb +94 -0
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +0 -6
- data/lib/puppet/rails/host.rb +7 -0
- data/lib/puppet/reports/store.rb +15 -0
- data/lib/puppet/resource/catalog.rb +15 -6
- data/lib/puppet/ssl/certificate.rb +6 -0
- data/lib/puppet/ssl/inventory.rb +2 -0
- data/lib/puppet/transaction.rb +9 -17
- data/lib/puppet/transaction/report.rb +3 -3
- data/lib/puppet/type.rb +13 -24
- data/lib/puppet/type/file.rb +8 -2
- data/lib/puppet/type/file/source.rb +2 -2
- data/lib/puppet/type/service.rb +20 -24
- data/lib/puppet/type/ssh_authorized_key.rb +12 -0
- data/lib/puppet/type/user.rb +8 -0
- data/lib/puppet/util.rb +0 -1
- data/lib/puppet/util/network_device.rb +3 -3
- data/lib/puppet/util/settings.rb +1 -1
- data/lib/puppet/util/settings/file_setting.rb +1 -0
- data/lib/semver.rb +65 -0
- data/spec/integration/defaults_spec.rb +23 -1
- data/spec/integration/network/rest_authconfig_spec.rb +145 -0
- data/spec/integration/node/facts_spec.rb +1 -1
- data/spec/integration/parser/functions_spec.rb +1 -1
- data/spec/integration/parser/parser_spec.rb +31 -0
- data/spec/integration/provider/ssh_authorized_key_spec.rb +207 -0
- data/spec/integration/type_spec.rb +11 -0
- data/spec/lib/puppet/face/1.0.0/huzzah.rb +8 -0
- data/spec/lib/puppet/face/huzzah.rb +1 -0
- data/spec/lib/puppet/face/huzzah/obsolete.rb +6 -0
- data/spec/shared_behaviours/things_that_declare_options.rb +115 -3
- data/spec/unit/application/agent_spec.rb +2 -2
- data/spec/unit/application/apply_spec.rb +74 -56
- data/spec/unit/application/cert_spec.rb +10 -0
- data/spec/unit/application/device_spec.rb +2 -3
- data/spec/unit/application/face_base_spec.rb +1 -0
- data/spec/unit/application/facts_spec.rb +1 -0
- data/spec/unit/application/inspect_spec.rb +5 -0
- data/spec/unit/configurer/fact_handler_spec.rb +45 -37
- data/spec/unit/configurer_spec.rb +405 -327
- data/spec/unit/face/ca_spec.rb +355 -0
- data/spec/unit/face/certificate_spec.rb +16 -4
- data/spec/unit/face/node_spec.rb +261 -1
- data/spec/unit/file_serving/configuration/parser_spec.rb +8 -0
- data/spec/unit/indirector/certificate/rest_spec.rb +1 -0
- data/spec/unit/indirector/certificate_status/file_spec.rb +4 -0
- data/spec/unit/indirector/exec_spec.rb +4 -4
- data/spec/unit/indirector/face_spec.rb +3 -1
- data/spec/unit/indirector/facts/couch_spec.rb +2 -2
- data/spec/unit/indirector/facts/network_device_spec.rb +2 -6
- data/spec/unit/indirector/node/exec_spec.rb +1 -1
- data/spec/unit/indirector/report/processor_spec.rb +31 -8
- data/spec/unit/indirector/rest_spec.rb +53 -5
- data/spec/unit/indirector/yaml_spec.rb +18 -0
- data/spec/unit/interface/action_spec.rb +112 -8
- data/spec/unit/interface/face_collection_spec.rb +46 -36
- data/spec/unit/interface/option_spec.rb +44 -0
- data/spec/unit/interface_spec.rb +11 -6
- data/spec/unit/module_spec.rb +38 -9
- data/spec/unit/network/authconfig_spec.rb +23 -0
- data/spec/unit/network/authstore_spec.rb +36 -4
- data/spec/unit/network/handler/fileserver_spec.rb +32 -0
- data/spec/unit/network/rest_authconfig_spec.rb +1 -1
- data/spec/unit/node_spec.rb +1 -0
- data/spec/unit/parser/compiler_spec.rb +8 -46
- data/spec/unit/parser/lexer_spec.rb +27 -17
- data/spec/unit/parser/resource_spec.rb +61 -3
- data/spec/unit/parser/scope_spec.rb +5 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +106 -1
- data/spec/unit/provider/cisco_spec.rb +3 -4
- data/spec/unit/provider/interface/cisco_spec.rb +1 -2
- data/spec/unit/provider/mount/parsed_spec.rb +41 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +60 -0
- data/spec/unit/provider/network_device_spec.rb +1 -2
- data/spec/unit/provider/package/pacman_spec.rb +237 -0
- data/spec/unit/provider/package/pkgutil_spec.rb +2 -3
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +21 -32
- data/spec/unit/provider/vlan/cisco_spec.rb +1 -2
- data/spec/unit/rails/host_spec.rb +8 -0
- data/spec/unit/resource/catalog_spec.rb +55 -8
- data/spec/unit/semver_spec.rb +187 -0
- data/spec/unit/ssl/certificate_spec.rb +25 -0
- data/spec/unit/transaction/report_spec.rb +3 -3
- data/spec/unit/transaction_spec.rb +8 -2
- data/spec/unit/type/file_spec.rb +57 -0
- data/spec/unit/type/interface_spec.rb +1 -2
- data/spec/unit/type/schedule_spec.rb +73 -42
- data/spec/unit/type/ssh_authorized_key_spec.rb +180 -70
- data/spec/unit/type/user_spec.rb +8 -0
- data/spec/unit/type/vlan_spec.rb +1 -2
- data/spec/unit/type_spec.rb +66 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -2
- data/spec/unit/util/network_device/cisco/facts_spec.rb +2 -3
- data/spec/unit/util/network_device/cisco/interface_spec.rb +1 -2
- data/spec/unit/util/network_device/config_spec.rb +3 -4
- data/spec/unit/util/network_device/ipcalc_spec.rb +1 -2
- data/spec/unit/util/network_device/transport/base_spec.rb +1 -2
- data/spec/unit/util/network_device/transport/ssh_spec.rb +1 -2
- data/spec/unit/util/network_device/transport/telnet_spec.rb +1 -2
- data/spec/unit/util/network_device_spec.rb +2 -2
- data/spec/unit/util/settings/file_setting_spec.rb +4 -0
- data/spec/unit/util/settings_spec.rb +11 -0
- data/test/lib/puppettest/railstesting.rb +0 -34
- metadata +19 -4
@@ -0,0 +1,237 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
provider = Puppet::Type.type(:package).provider(:pacman)
|
5
|
+
|
6
|
+
describe provider do
|
7
|
+
before do
|
8
|
+
provider.stubs(:command).with(:pacman).returns('/usr/bin/pacman')
|
9
|
+
@resource = stub 'resource'
|
10
|
+
@resource.stubs(:[]).returns("package")
|
11
|
+
@resource.stubs(:name).returns("name")
|
12
|
+
@provider = provider.new(@resource)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "when installing" do
|
16
|
+
before do
|
17
|
+
@provider.stubs(:query).returns({
|
18
|
+
:ensure => '1.0'
|
19
|
+
})
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should call pacman" do
|
23
|
+
provider.
|
24
|
+
expects(:execute).
|
25
|
+
at_least_once.
|
26
|
+
with { |args|
|
27
|
+
args[0] == "/usr/bin/pacman"
|
28
|
+
}.
|
29
|
+
returns ""
|
30
|
+
|
31
|
+
@provider.install
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be quiet" do
|
35
|
+
provider.
|
36
|
+
expects(:execute).
|
37
|
+
with { |args|
|
38
|
+
args[1,2] == ["--noconfirm", "--noprogressbar"]
|
39
|
+
}.
|
40
|
+
returns("")
|
41
|
+
|
42
|
+
@provider.install
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should install the right package" do
|
46
|
+
provider.
|
47
|
+
expects(:execute).
|
48
|
+
with { |args|
|
49
|
+
args[3,4] == ["-Sy", @resource[0]]
|
50
|
+
}.
|
51
|
+
returns("")
|
52
|
+
|
53
|
+
@provider.install
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should raise an ExecutionFailure if the installation failed" do
|
57
|
+
provider.stubs(:execute).returns("")
|
58
|
+
@provider.expects(:query).returns(nil)
|
59
|
+
|
60
|
+
lambda { @provider.install }.should raise_exception(Puppet::ExecutionFailure)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "when updating" do
|
65
|
+
it "should call install" do
|
66
|
+
@provider.expects(:install).returns("install return value")
|
67
|
+
@provider.update.should == "install return value"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "when uninstalling" do
|
72
|
+
it "should call pacman" do
|
73
|
+
provider.
|
74
|
+
expects(:execute).
|
75
|
+
with { |args|
|
76
|
+
args[0] == "/usr/bin/pacman"
|
77
|
+
}.
|
78
|
+
returns ""
|
79
|
+
|
80
|
+
@provider.uninstall
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should be quiet" do
|
84
|
+
provider.
|
85
|
+
expects(:execute).
|
86
|
+
with { |args|
|
87
|
+
args[1,2] == ["--noconfirm", "--noprogressbar"]
|
88
|
+
}.
|
89
|
+
returns("")
|
90
|
+
|
91
|
+
@provider.uninstall
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should remove the right package" do
|
95
|
+
provider.
|
96
|
+
expects(:execute).
|
97
|
+
with { |args|
|
98
|
+
args[3,4] == ["-R", @resource[0]]
|
99
|
+
}.
|
100
|
+
returns("")
|
101
|
+
|
102
|
+
@provider.uninstall
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "when querying" do
|
107
|
+
it "should query pacman" do
|
108
|
+
provider.
|
109
|
+
expects(:execute).
|
110
|
+
with(["/usr/bin/pacman", "-Qi", @resource[0]])
|
111
|
+
@provider.query
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should return the version" do
|
115
|
+
query_output = <<EOF
|
116
|
+
Name : package
|
117
|
+
Version : 1.01.3-2
|
118
|
+
URL : http://www.archlinux.org/pacman/
|
119
|
+
Licenses : GPL
|
120
|
+
Groups : base
|
121
|
+
Provides : None
|
122
|
+
Depends On : bash libarchive>=2.7.1 libfetch>=2.25 pacman-mirrorlist
|
123
|
+
Optional Deps : fakeroot: for makepkg usage as normal user
|
124
|
+
curl: for rankmirrors usage
|
125
|
+
Required By : None
|
126
|
+
Conflicts With : None
|
127
|
+
Replaces : None
|
128
|
+
Installed Size : 2352.00 K
|
129
|
+
Packager : Dan McGee <dan@archlinux.org>
|
130
|
+
Architecture : i686
|
131
|
+
Build Date : Sat 22 Jan 2011 03:56:41 PM EST
|
132
|
+
Install Date : Thu 27 Jan 2011 06:45:49 AM EST
|
133
|
+
Install Reason : Explicitly installed
|
134
|
+
Install Script : Yes
|
135
|
+
Description : A library-based package manager with dependency support
|
136
|
+
EOF
|
137
|
+
|
138
|
+
provider.expects(:execute).returns(query_output)
|
139
|
+
@provider.query.should == {:ensure => "1.01.3-2"}
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should return a nil if the package isn't found" do
|
143
|
+
provider.expects(:execute).returns("")
|
144
|
+
@provider.query.should be_nil
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should return a hash indicating that the package is missing on error" do
|
148
|
+
provider.expects(:execute).raises(Puppet::ExecutionFailure.new("ERROR!"))
|
149
|
+
@provider.query.should == {
|
150
|
+
:ensure => :purged,
|
151
|
+
:status => 'missing',
|
152
|
+
:name => @resource[0],
|
153
|
+
:error => 'ok',
|
154
|
+
}
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "when fetching a package list" do
|
159
|
+
it "should query pacman" do
|
160
|
+
provider.expects(:execpipe).with(["/usr/bin/pacman", ' -Q'])
|
161
|
+
provider.instances
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should return installed packages with their versions" do
|
165
|
+
provider.expects(:execpipe).yields("package1 1.23-4\npackage2 2.00\n")
|
166
|
+
packages = provider.instances
|
167
|
+
|
168
|
+
packages.length.should == 2
|
169
|
+
|
170
|
+
packages[0].properties.should == {
|
171
|
+
:provider => :pacman,
|
172
|
+
:ensure => '1.23-4',
|
173
|
+
:name => 'package1'
|
174
|
+
}
|
175
|
+
|
176
|
+
packages[1].properties.should == {
|
177
|
+
:provider => :pacman,
|
178
|
+
:ensure => '2.00',
|
179
|
+
:name => 'package2'
|
180
|
+
}
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should return nil on error" do
|
184
|
+
provider.expects(:execpipe).raises(Puppet::ExecutionFailure.new("ERROR!"))
|
185
|
+
provider.instances.should be_nil
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should warn on invalid input" do
|
189
|
+
provider.expects(:execpipe).yields("blah")
|
190
|
+
provider.expects(:warning).with("Failed to match line blah")
|
191
|
+
provider.instances.should == []
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
describe "when determining the latest version" do
|
196
|
+
it "should refresh package list" do
|
197
|
+
refreshed = states('refreshed').starts_as('unrefreshed')
|
198
|
+
provider.
|
199
|
+
expects(:execute).
|
200
|
+
when(refreshed.is('unrefreshed')).
|
201
|
+
with(['/usr/bin/pacman', '-Sy']).
|
202
|
+
then(refreshed.is('refreshed'))
|
203
|
+
|
204
|
+
provider.
|
205
|
+
stubs(:execute).
|
206
|
+
when(refreshed.is('refreshed')).
|
207
|
+
returns("")
|
208
|
+
|
209
|
+
@provider.latest
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should get query pacman for the latest version" do
|
213
|
+
refreshed = states('refreshed').starts_as('unrefreshed')
|
214
|
+
provider.
|
215
|
+
stubs(:execute).
|
216
|
+
when(refreshed.is('unrefreshed')).
|
217
|
+
then(refreshed.is('refreshed'))
|
218
|
+
|
219
|
+
provider.
|
220
|
+
expects(:execute).
|
221
|
+
when(refreshed.is('refreshed')).
|
222
|
+
with(['/usr/bin/pacman', '-Sp', '--print-format', '%v', @resource[0]]).
|
223
|
+
returns("")
|
224
|
+
|
225
|
+
@provider.latest
|
226
|
+
end
|
227
|
+
|
228
|
+
it "should return the version number from pacman" do
|
229
|
+
provider.
|
230
|
+
expects(:execute).
|
231
|
+
at_least_once().
|
232
|
+
returns("1.00.2-3\n")
|
233
|
+
|
234
|
+
@provider.latest.should == "1.00.2-3"
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
@@ -9,23 +9,19 @@ describe provider_class do
|
|
9
9
|
include PuppetSpec::Files
|
10
10
|
|
11
11
|
before :each do
|
12
|
-
@sshauthkey_class = Puppet::Type.type(:ssh_authorized_key)
|
13
|
-
@provider = @sshauthkey_class.provider(:parsed)
|
14
12
|
@keyfile = tmpfile('authorized_keys')
|
15
|
-
@
|
13
|
+
@provider_class = provider_class
|
14
|
+
@provider_class.initvars
|
15
|
+
@provider_class.any_instance.stubs(:target).returns @keyfile
|
16
16
|
@user = 'random_bob'
|
17
17
|
Puppet::Util.stubs(:uid).with(@user).returns 12345
|
18
18
|
end
|
19
19
|
|
20
|
-
after :each do
|
21
|
-
@provider.initvars
|
22
|
-
end
|
23
|
-
|
24
20
|
def mkkey(args)
|
25
21
|
args[:target] = @keyfile
|
26
22
|
args[:user] = @user
|
27
23
|
resource = Puppet::Type.type(:ssh_authorized_key).new(args)
|
28
|
-
key = @
|
24
|
+
key = @provider_class.new(resource)
|
29
25
|
args.each do |p,v|
|
30
26
|
key.send(p.to_s + "=", v)
|
31
27
|
end
|
@@ -33,26 +29,26 @@ describe provider_class do
|
|
33
29
|
end
|
34
30
|
|
35
31
|
def genkey(key)
|
36
|
-
@
|
32
|
+
@provider_class.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam)
|
37
33
|
File.stubs(:chown)
|
38
34
|
File.stubs(:chmod)
|
39
35
|
Puppet::Util::SUIDManager.stubs(:asuser).yields
|
40
36
|
key.flush
|
41
|
-
@
|
37
|
+
@provider_class.target_object(@keyfile).read
|
42
38
|
end
|
43
39
|
|
44
40
|
it_should_behave_like "all parsedfile providers", provider_class
|
45
41
|
|
46
42
|
it "should be able to generate a basic authorized_keys file" do
|
47
43
|
|
48
|
-
key = mkkey(:name => "
|
44
|
+
key = mkkey(:name => "Just_Testing",
|
49
45
|
:key => "AAAAfsfddsjldjgksdflgkjsfdlgkj",
|
50
46
|
:type => "ssh-dss",
|
51
47
|
:ensure => :present,
|
52
48
|
:options => [:absent]
|
53
49
|
)
|
54
50
|
|
55
|
-
genkey(key).should == "ssh-dss AAAAfsfddsjldjgksdflgkjsfdlgkj
|
51
|
+
genkey(key).should == "ssh-dss AAAAfsfddsjldjgksdflgkjsfdlgkj Just_Testing\n"
|
56
52
|
end
|
57
53
|
|
58
54
|
it "should be able to generate a authorized_keys file with options" do
|
@@ -71,25 +67,25 @@ describe provider_class do
|
|
71
67
|
options = %w{from="host1.reductlivelabs.com,host.reductivelabs.com" command="/usr/local/bin/run" ssh-pty}
|
72
68
|
optionstr = options.join(", ")
|
73
69
|
|
74
|
-
@
|
70
|
+
@provider_class.parse_options(optionstr).should == options
|
75
71
|
end
|
76
72
|
|
77
73
|
it "should use '' as name for entries that lack a comment" do
|
78
74
|
line = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAut8aOSxenjOqF527dlsdHWV4MNoAsX14l9M297+SQXaQ5Z3BedIxZaoQthkDALlV/25A1COELrg9J2MqJNQc8Xe9XQOIkBQWWinUlD/BXwoOTWEy8C8zSZPHZ3getMMNhGTBO+q/O+qiJx3y5cA4MTbw2zSxukfWC87qWwcZ64UUlegIM056vPsdZWFclS9hsROVEa57YUMrehQ1EGxT4Z5j6zIopufGFiAPjZigq/vqgcAqhAKP6yu4/gwO6S9tatBeEjZ8fafvj1pmvvIplZeMr96gHE7xS3pEEQqnB3nd4RY7AF6j9kFixnsytAUO7STPh/M3pLiVQBN89TvWPQ=="
|
79
75
|
|
80
|
-
@
|
76
|
+
@provider_class.parse(line)[0][:name].should == ""
|
81
77
|
end
|
82
78
|
end
|
83
79
|
|
84
80
|
describe provider_class do
|
85
81
|
before :each do
|
86
|
-
@resource =
|
87
|
-
@resource.stubs(:[]).returns "foo"
|
88
|
-
@resource.class.stubs(:key_attributes).returns( [:name] )
|
82
|
+
@resource = Puppet::Type.type(:ssh_authorized_key).new(:name => "foo", :user => "random_bob")
|
89
83
|
|
90
84
|
@provider = provider_class.new(@resource)
|
91
85
|
provider_class.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam)
|
92
86
|
Puppet::Util::SUIDManager.stubs(:asuser).yields
|
87
|
+
|
88
|
+
provider_class.initvars
|
93
89
|
end
|
94
90
|
|
95
91
|
describe "when flushing" do
|
@@ -103,9 +99,9 @@ describe provider_class do
|
|
103
99
|
describe "and both a user and a target have been specified" do
|
104
100
|
before :each do
|
105
101
|
Puppet::Util.stubs(:uid).with("random_bob").returns 12345
|
106
|
-
@resource
|
102
|
+
@resource[:user] = "random_bob"
|
107
103
|
target = "/tmp/.ssh_dir/place_to_put_authorized_keys"
|
108
|
-
@resource
|
104
|
+
@resource[:target] = target
|
109
105
|
end
|
110
106
|
|
111
107
|
it "should create the directory" do
|
@@ -134,8 +130,7 @@ describe provider_class do
|
|
134
130
|
|
135
131
|
describe "and a user has been specified with no target" do
|
136
132
|
before :each do
|
137
|
-
@resource
|
138
|
-
@resource.stubs(:should).with(:target).returns nil
|
133
|
+
@resource[:user] = "nobody"
|
139
134
|
#
|
140
135
|
# I'd like to use random_bob here and something like
|
141
136
|
#
|
@@ -186,26 +181,20 @@ describe provider_class do
|
|
186
181
|
end
|
187
182
|
|
188
183
|
describe "and a target has been specified with no user" do
|
189
|
-
before :each do
|
190
|
-
@resource.stubs(:should).with(:user).returns nil
|
191
|
-
@resource.stubs(:should).with(:target).returns("/tmp/.ssh_dir/place_to_put_authorized_keys")
|
192
|
-
end
|
193
|
-
|
194
184
|
it "should raise an error" do
|
185
|
+
@resource = Puppet::Type.type(:ssh_authorized_key).new(:name => "foo", :target => "/tmp/.ssh_dir/place_to_put_authorized_keys")
|
186
|
+
@provider = provider_class.new(@resource)
|
187
|
+
|
195
188
|
proc { @provider.flush }.should raise_error
|
196
189
|
end
|
197
190
|
end
|
198
191
|
|
199
192
|
describe "and a invalid user has been specified with no target" do
|
200
|
-
before :each do
|
201
|
-
@resource.stubs(:should).with(:user).returns "thisusershouldnotexist"
|
202
|
-
@resource.stubs(:should).with(:target).returns nil
|
203
|
-
end
|
204
|
-
|
205
193
|
it "should catch an exception and raise a Puppet error" do
|
194
|
+
@resource[:user] = "thisusershouldnotexist"
|
195
|
+
|
206
196
|
lambda { @provider.flush }.should raise_error(Puppet::Error)
|
207
197
|
end
|
208
198
|
end
|
209
|
-
|
210
199
|
end
|
211
200
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env rspec
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
+
require 'puppet/node/environment'
|
5
|
+
|
4
6
|
describe "Puppet::Rails::Host", :if => Puppet.features.rails? do
|
5
7
|
def column(name, type)
|
6
8
|
ActiveRecord::ConnectionAdapters::Column.new(name, nil, type, false)
|
@@ -42,6 +44,12 @@ describe "Puppet::Rails::Host", :if => Puppet.features.rails? do
|
|
42
44
|
Puppet::Rails::Host.from_puppet(@node)
|
43
45
|
end
|
44
46
|
|
47
|
+
it "should stringify the environment" do
|
48
|
+
host = Puppet::Rails::Host.new
|
49
|
+
host.environment = Puppet::Node::Environment.new("production")
|
50
|
+
host.environment.class.should == String
|
51
|
+
end
|
52
|
+
|
45
53
|
it "should copy the ipaddress from the Puppet instance" do
|
46
54
|
Puppet::Rails::Host.expects(:find_by_name).with("foo").returns @host
|
47
55
|
|
@@ -500,7 +500,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
500
500
|
lambda { @catalog.alias(@one, "other") }.should_not raise_error
|
501
501
|
end
|
502
502
|
|
503
|
-
it "should create aliases for
|
503
|
+
it "should create aliases for isomorphic resources whose names do not match their titles" do
|
504
504
|
resource = Puppet::Type::File.new(:title => "testing", :path => @basepath+"/something")
|
505
505
|
|
506
506
|
@catalog.add_resource(resource)
|
@@ -508,7 +508,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
508
508
|
@catalog.resource(:file, @basepath+"/something").should equal(resource)
|
509
509
|
end
|
510
510
|
|
511
|
-
it "should not create aliases for
|
511
|
+
it "should not create aliases for non-isomorphic resources whose names do not match their titles" do
|
512
512
|
resource = Puppet::Type.type(:exec).new(:title => "testing", :command => "echo", :path => %w{/bin /usr/bin /usr/local/bin})
|
513
513
|
|
514
514
|
@catalog.add_resource(resource)
|
@@ -524,11 +524,6 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
524
524
|
@catalog.resource("notify", "other").should equal(@one)
|
525
525
|
end
|
526
526
|
|
527
|
-
it "should ignore conflicting aliases that point to the aliased resource" do
|
528
|
-
@catalog.alias(@one, "other")
|
529
|
-
lambda { @catalog.alias(@one, "other") }.should_not raise_error
|
530
|
-
end
|
531
|
-
|
532
527
|
it "should fail to add an alias if the aliased name already exists" do
|
533
528
|
@catalog.add_resource @one
|
534
529
|
proc { @catalog.alias @two, "one" }.should raise_error(ArgumentError)
|
@@ -582,13 +577,65 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
582
577
|
@catalog.create_resource :file, args
|
583
578
|
@catalog.resource("File[/yay]").should equal(resource)
|
584
579
|
end
|
580
|
+
|
581
|
+
describe "when adding resources with multiple namevars" do
|
582
|
+
before :each do
|
583
|
+
Puppet::Type.newtype(:multiple) do
|
584
|
+
newparam(:color, :namevar => true)
|
585
|
+
newparam(:designation, :namevar => true)
|
586
|
+
|
587
|
+
def self.title_patterns
|
588
|
+
[ [
|
589
|
+
/^(\w+) (\w+)$/,
|
590
|
+
[
|
591
|
+
[:color, lambda{|x| x}],
|
592
|
+
[:designation, lambda{|x| x}]
|
593
|
+
]
|
594
|
+
] ]
|
595
|
+
end
|
596
|
+
end
|
597
|
+
end
|
598
|
+
|
599
|
+
it "should add an alias using the uniqueness key" do
|
600
|
+
@resource = Puppet::Type.type(:multiple).new(:title => "some resource", :color => "red", :designation => "5")
|
601
|
+
|
602
|
+
@catalog.add_resource(@resource)
|
603
|
+
@catalog.resource(:multiple, "some resource").must == @resource
|
604
|
+
@catalog.resource("Multiple[some resource]").must == @resource
|
605
|
+
@catalog.resource("Multiple[red 5]").must == @resource
|
606
|
+
end
|
607
|
+
|
608
|
+
it "should conflict with a resource with the same uniqueness key" do
|
609
|
+
@resource = Puppet::Type.type(:multiple).new(:title => "some resource", :color => "red", :designation => "5")
|
610
|
+
@other = Puppet::Type.type(:multiple).new(:title => "another resource", :color => "red", :designation => "5")
|
611
|
+
|
612
|
+
@catalog.add_resource(@resource)
|
613
|
+
expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, /Cannot alias Multiple\[another resource\] to \["red", "5"\].*resource \["Multiple", "red", "5"\] already defined/)
|
614
|
+
end
|
615
|
+
|
616
|
+
it "should conflict when its uniqueness key matches another resource's title" do
|
617
|
+
@resource = Puppet::Type.type(:file).new(:title => "/tmp/foo")
|
618
|
+
@other = Puppet::Type.type(:file).new(:title => "another file", :path => "/tmp/foo")
|
619
|
+
|
620
|
+
@catalog.add_resource(@resource)
|
621
|
+
expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, /Cannot alias File\[another file\] to \["\/tmp\/foo"\].*resource \["File", "\/tmp\/foo"\] already defined/)
|
622
|
+
end
|
623
|
+
|
624
|
+
it "should conflict when its uniqueness key matches the uniqueness key derived from another resource's title" do
|
625
|
+
@resource = Puppet::Type.type(:multiple).new(:title => "red leader")
|
626
|
+
@other = Puppet::Type.type(:multiple).new(:title => "another resource", :color => "red", :designation => "leader")
|
627
|
+
|
628
|
+
@catalog.add_resource(@resource)
|
629
|
+
expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, /Cannot alias Multiple\[another resource\] to \["red", "leader"\].*resource \["Multiple", "red", "leader"\] already defined/)
|
630
|
+
end
|
631
|
+
end
|
585
632
|
end
|
586
633
|
|
587
634
|
describe "when applying" do
|
588
635
|
before :each do
|
589
636
|
@catalog = Puppet::Resource::Catalog.new("host")
|
590
637
|
|
591
|
-
@transaction =
|
638
|
+
@transaction = Puppet::Transaction.new(@catalog)
|
592
639
|
Puppet::Transaction.stubs(:new).returns(@transaction)
|
593
640
|
@transaction.stubs(:evaluate)
|
594
641
|
@transaction.stubs(:add_times)
|