puppet 0.25.0 → 0.25.1
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 +4772 -19114
- data/README +1 -1
- data/Rakefile +7 -25
- data/{sbin → bin}/puppetca +0 -0
- data/{sbin → bin}/puppetd +0 -0
- data/{sbin → bin}/puppetmasterd +0 -0
- data/{sbin → bin}/puppetqd +0 -0
- data/{sbin → bin}/puppetrun +0 -0
- data/conf/osx/createpackage.sh +1 -1
- data/conf/redhat/client.init +6 -3
- data/conf/redhat/puppet.spec +26 -14
- data/conf/redhat/server.init +3 -2
- data/ext/vim/syntax/puppet.vim +4 -1
- data/install.rb +25 -7
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +2 -2
- data/lib/puppet/application/puppet.rb +3 -3
- data/lib/puppet/application/puppetd.rb +0 -7
- data/lib/puppet/application/puppetdoc.rb +1 -0
- data/lib/puppet/application/puppetmasterd.rb +2 -2
- data/lib/puppet/configurer.rb +6 -1
- data/lib/puppet/configurer/fact_handler.rb +2 -2
- data/lib/puppet/defaults.rb +2 -2
- data/lib/puppet/external/nagios/base.rb +4 -3
- data/lib/puppet/external/pson/common.rb +367 -0
- data/lib/puppet/external/pson/pure.rb +77 -0
- data/lib/puppet/external/pson/pure/generator.rb +429 -0
- data/lib/puppet/external/pson/pure/parser.rb +269 -0
- data/lib/puppet/external/pson/version.rb +8 -0
- data/lib/puppet/feature/pson.rb +6 -0
- data/lib/puppet/feature/rails.rb +1 -5
- data/lib/puppet/file_serving/configuration.rb +2 -2
- data/lib/puppet/indirector/certificate/rest.rb +6 -0
- data/lib/puppet/indirector/facts/facter.rb +1 -1
- data/lib/puppet/indirector/ldap.rb +1 -1
- data/lib/puppet/indirector/queue.rb +3 -3
- data/lib/puppet/indirector/rest.rb +1 -1
- data/lib/puppet/network/authstore.rb +34 -53
- data/lib/puppet/network/formats.rb +59 -9
- data/lib/puppet/network/http/mongrel/rest.rb +10 -9
- data/lib/puppet/network/http/webrick.rb +8 -1
- data/lib/puppet/network/http/webrick/rest.rb +2 -5
- data/lib/puppet/network/http_server/webrick.rb +1 -4
- data/lib/puppet/parser/ast/leaf.rb +1 -3
- data/lib/puppet/parser/collector.rb +14 -8
- data/lib/puppet/parser/compiler.rb +7 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +4 -10
- data/lib/puppet/parser/functions/regsubst.rb +44 -30
- data/lib/puppet/parser/functions/require.rb +18 -3
- data/lib/puppet/parser/functions/versioncmp.rb +1 -1
- data/lib/puppet/parser/interpreter.rb +1 -1
- data/lib/puppet/parser/lexer.rb +29 -31
- data/lib/puppet/parser/loaded_code.rb +4 -0
- data/lib/puppet/parser/parser_support.rb +5 -2
- data/lib/puppet/parser/resource.rb +31 -6
- data/lib/puppet/property.rb +3 -2
- data/lib/puppet/provider/macauthorization/macauthorization.rb +14 -14
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +15 -5
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/up2date.rb +1 -1
- data/lib/puppet/provider/package/urpmi.rb +1 -1
- data/lib/puppet/provider/service/daemontools.rb +7 -10
- data/lib/puppet/provider/service/runit.rb +7 -17
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +7 -47
- data/lib/puppet/provider/zone/solaris.rb +12 -3
- data/lib/puppet/relationship.rb +12 -12
- data/lib/puppet/reports/rrdgraph.rb +1 -1
- data/lib/puppet/reports/store.rb +2 -2
- data/lib/puppet/reports/tagmail.rb +5 -16
- data/lib/puppet/resource.rb +15 -20
- data/lib/puppet/resource/catalog.rb +40 -29
- data/lib/puppet/ssl/certificate_revocation_list.rb +0 -2
- data/lib/puppet/ssl/host.rb +2 -3
- data/lib/puppet/sslcertificates/ca.rb +0 -5
- data/lib/puppet/type/cron.rb +1 -1
- data/lib/puppet/type/file/owner.rb +7 -4
- data/lib/puppet/type/resources.rb +17 -17
- data/lib/puppet/type/yumrepo.rb +10 -3
- data/lib/puppet/util.rb +6 -11
- data/lib/puppet/util/inifile.rb +8 -0
- data/lib/puppet/util/log.rb +2 -2
- data/lib/puppet/util/monkey_patches.rb +0 -43
- data/lib/puppet/util/{json.rb → pson.rb} +6 -6
- data/lib/puppet/util/rdoc.rb +5 -3
- data/lib/puppet/util/selinux.rb +12 -6
- data/lib/puppet/util/settings.rb +25 -16
- data/lib/puppet/util/settings/file_setting.rb +4 -2
- data/spec/integration/application/puppet.rb +4 -4
- data/spec/integration/defaults.rb +2 -2
- data/spec/integration/indirector/catalog/queue.rb +5 -5
- data/spec/integration/indirector/certificate/rest.rb +3 -1
- data/spec/integration/network/formats.rb +36 -36
- data/spec/integration/parser/functions/require.rb +5 -3
- data/spec/integration/provider/mailalias/aliases.rb +4 -4
- data/spec/integration/resource/catalog.rb +4 -4
- data/spec/unit/application/puppet.rb +16 -15
- data/spec/unit/application/puppetd.rb +1 -1
- data/spec/unit/application/puppetdoc.rb +6 -0
- data/spec/unit/application/puppetmasterd.rb +6 -6
- data/spec/unit/configurer/fact_handler.rb +3 -3
- data/spec/unit/file_serving/configuration.rb +16 -2
- data/spec/unit/indirector/certificate/rest.rb +34 -0
- data/spec/unit/indirector/queue.rb +15 -15
- data/spec/unit/indirector/rest.rb +31 -9
- data/spec/unit/network/authstore.rb +105 -26
- data/spec/unit/network/formats.rb +124 -39
- data/spec/unit/parser/ast/leaf.rb +15 -0
- data/spec/unit/parser/collector.rb +20 -9
- data/spec/unit/parser/compiler.rb +19 -0
- data/spec/unit/parser/functions/fqdn_rand.rb +62 -0
- data/spec/unit/parser/functions/regsubst.rb +80 -0
- data/spec/unit/parser/functions/require.rb +19 -7
- data/spec/unit/parser/interpreter.rb +2 -2
- data/spec/unit/parser/lexer.rb +32 -7
- data/spec/unit/parser/loaded_code.rb +18 -1
- data/spec/unit/parser/parser.rb +10 -2
- data/spec/unit/parser/resource.rb +53 -2
- data/spec/unit/parser/scope.rb +1 -1
- data/spec/unit/property.rb +14 -4
- data/spec/unit/provider/package/dpkg.rb +7 -0
- data/spec/unit/provider/service/daemontools.rb +19 -2
- data/spec/unit/provider/service/redhat.rb +2 -0
- data/spec/unit/provider/service/runit.rb +15 -4
- data/spec/unit/provider/ssh_authorized_key/parsed.rb +32 -55
- data/spec/unit/relationship.rb +21 -46
- data/spec/unit/resource.rb +30 -39
- data/spec/unit/resource/catalog.rb +66 -51
- data/spec/unit/ssl/certificate_revocation_list.rb +0 -12
- data/spec/unit/type/cron.rb +33 -0
- data/spec/unit/type/file/owner.rb +10 -4
- data/spec/unit/util/json.rb +9 -9
- data/spec/unit/util/log.rb +36 -0
- data/spec/unit/util/settings.rb +6 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys2 +1 -0
- data/test/lib/puppettest/support/utils.rb +8 -16
- metadata +36 -13
- data/lib/puppet/feature/json.rb +0 -2
@@ -7,8 +7,10 @@ describe "the require function" do
|
|
7
7
|
before :each do
|
8
8
|
@catalog = stub 'catalog'
|
9
9
|
@compiler = stub 'compiler', :catalog => @catalog
|
10
|
+
|
11
|
+
@resource = stub 'resource', :set_parameter => nil, :metaparam_compatibility_mode? => false
|
10
12
|
@scope = Puppet::Parser::Scope.new()
|
11
|
-
@scope.stubs(:resource).returns
|
13
|
+
@scope.stubs(:resource).returns @resource
|
12
14
|
@scope.stubs(:findresource)
|
13
15
|
@scope.stubs(:compiler).returns(@compiler)
|
14
16
|
end
|
@@ -18,19 +20,29 @@ describe "the require function" do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
it "should delegate to the 'include' puppet function" do
|
21
|
-
@catalog.stubs(:add_edge)
|
22
23
|
@scope.expects(:function_include).with("myclass")
|
23
24
|
|
24
25
|
@scope.function_require("myclass")
|
25
26
|
end
|
26
27
|
|
27
|
-
it "should
|
28
|
-
@
|
29
|
-
@scope.stubs(:
|
30
|
-
|
31
|
-
|
28
|
+
it "should set the 'require' prarameter on the resource to a resource reference" do
|
29
|
+
@resource.expects(:set_parameter).with { |name, value| name == :require and value.is_a?(Puppet::Parser::Resource::Reference) }
|
30
|
+
@scope.stubs(:function_include)
|
31
|
+
@scope.function_require("myclass")
|
32
|
+
end
|
32
33
|
|
34
|
+
it "should verify the 'include' function is loaded" do
|
35
|
+
Puppet::Parser::Functions.expects(:function).with(:include).returns(:function_include)
|
36
|
+
@scope.stubs(:function_include)
|
33
37
|
@scope.function_require("myclass")
|
34
38
|
end
|
35
39
|
|
40
|
+
it "should include the class but not add a dependency if used on a client not at least version 0.25" do
|
41
|
+
@resource.expects(:metaparam_compatibility_mode?).returns true
|
42
|
+
@scope.expects(:warning)
|
43
|
+
@resource.expects(:set_parameter).never
|
44
|
+
@scope.expects(:function_include)
|
45
|
+
|
46
|
+
@scope.function_require("myclass")
|
47
|
+
end
|
36
48
|
end
|
@@ -10,7 +10,7 @@ describe Puppet::Parser::Interpreter do
|
|
10
10
|
|
11
11
|
describe "when creating parser instances" do
|
12
12
|
it "should create a parser with code if there is code defined in the :code setting" do
|
13
|
-
Puppet.settings.stubs(:
|
13
|
+
Puppet.settings.stubs(:uninterpolated_value).with(:code, :myenv).returns("mycode")
|
14
14
|
@parser.expects(:string=).with("mycode")
|
15
15
|
@parser.expects(:parse)
|
16
16
|
Puppet::Parser::Parser.expects(:new).with(:environment => :myenv).returns(@parser)
|
@@ -18,7 +18,7 @@ describe Puppet::Parser::Interpreter do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should create a parser with the main manifest when the code setting is an empty string" do
|
21
|
-
Puppet.settings.stubs(:
|
21
|
+
Puppet.settings.stubs(:uninterpolated_value).with(:code, :myenv).returns("")
|
22
22
|
Puppet.settings.stubs(:value).with(:manifest, :myenv).returns("/my/file")
|
23
23
|
@parser.expects(:parse)
|
24
24
|
@parser.expects(:file=).with("/my/file")
|
data/spec/unit/parser/lexer.rb
CHANGED
@@ -460,18 +460,43 @@ describe Puppet::Parser::Lexer::TOKENS[:REGEX] do
|
|
460
460
|
@token.regex.should =~ '/this is a regex/'
|
461
461
|
end
|
462
462
|
|
463
|
-
|
464
|
-
|
463
|
+
it 'should not match if there is \n in the regex' do
|
464
|
+
@token.regex.should_not =~ "/this is \n a regex/"
|
465
|
+
end
|
465
466
|
|
466
|
-
|
467
|
-
|
467
|
+
describe "when scanning" do
|
468
|
+
def tokens_scanned_from(s)
|
469
|
+
lexer = Puppet::Parser::Lexer.new
|
470
|
+
lexer.string = s
|
468
471
|
tokens = []
|
469
|
-
|
472
|
+
lexer.scan do |name, value|
|
470
473
|
tokens << value
|
471
474
|
end
|
472
|
-
tokens[0]
|
475
|
+
tokens[0..-2]
|
473
476
|
end
|
474
|
-
|
477
|
+
|
478
|
+
it "should not consider escaped slashes to be the end of a regex" do
|
479
|
+
tokens_scanned_from("$x =~ /this \\/ foo/").last[:value].should == Regexp.new("this / foo")
|
480
|
+
end
|
481
|
+
|
482
|
+
it "should not lex chained division as a regex" do
|
483
|
+
tokens_scanned_from("$x = $a/$b/$c").any? {|t| t[:value].class == Regexp }.should == false
|
484
|
+
end
|
485
|
+
|
486
|
+
it "should accept a regular expression after NODE" do
|
487
|
+
tokens_scanned_from("node /www.*\.mysite\.org/").last[:value].should == Regexp.new("www.*\.mysite\.org")
|
488
|
+
end
|
489
|
+
|
490
|
+
it "should accept regular expressions in a CASE" do
|
491
|
+
s = %q{case $variable {
|
492
|
+
"something": {$othervar = 4096 / 2}
|
493
|
+
/regex/: {notice("this notably sucks")}
|
494
|
+
}
|
495
|
+
}
|
496
|
+
tokens_scanned_from(s)[12][:value].should == Regexp.new("regex")
|
497
|
+
end
|
498
|
+
|
499
|
+
end
|
475
500
|
|
476
501
|
|
477
502
|
it "should return the REGEX token and a Regexp" do
|
@@ -156,7 +156,24 @@ describe Puppet::Parser::LoadedCode do
|
|
156
156
|
nameout = Puppet::Parser::AST::HostName.new(:value => "foo")
|
157
157
|
|
158
158
|
@loader.add_node(namein, "bar")
|
159
|
-
@loader.node(nameout) == "bar"
|
159
|
+
@loader.node(nameout).should == "bar"
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should be able to find node by HostName strict equality" do
|
163
|
+
namein = Puppet::Parser::AST::HostName.new(:value => "foo")
|
164
|
+
nameout = Puppet::Parser::AST::HostName.new(:value => "foo")
|
165
|
+
|
166
|
+
@loader.add_node(namein, "bar")
|
167
|
+
@loader.node_exists?(nameout).should == "bar"
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should not use node name matching when finding with strict node HostName" do
|
171
|
+
name1 = Puppet::Parser::AST::HostName.new(:value => "foo")
|
172
|
+
name2 = Puppet::Parser::AST::HostName.new(:value => Puppet::Parser::AST::Regex.new(:value => /foo/))
|
173
|
+
|
174
|
+
@loader.add_node(name1, "bar")
|
175
|
+
@loader.add_node(name2, "baz")
|
176
|
+
@loader.node_exists?(name1).should == "bar"
|
160
177
|
end
|
161
178
|
|
162
179
|
it "should return the first matching regex nodename" do
|
data/spec/unit/parser/parser.rb
CHANGED
@@ -253,7 +253,7 @@ describe Puppet::Parser do
|
|
253
253
|
end
|
254
254
|
|
255
255
|
it "should raise an error if the node already exists" do
|
256
|
-
@loaded_code.stubs(:
|
256
|
+
@loaded_code.stubs(:node_exists?).with(@nodename).returns(@node)
|
257
257
|
|
258
258
|
lambda { @parser.newnode(@nodename) }.should raise_error
|
259
259
|
end
|
@@ -324,9 +324,17 @@ describe Puppet::Parser do
|
|
324
324
|
it "should use the output of the config_version setting if one is provided" do
|
325
325
|
Puppet.settings.stubs(:[]).with(:config_version).returns("/my/foo")
|
326
326
|
|
327
|
-
|
327
|
+
Puppet::Util.expects(:execute).with(["/my/foo"]).returns "output\n"
|
328
328
|
@parser.version.should == "output"
|
329
329
|
end
|
330
|
+
|
331
|
+
it "should raise a puppet parser error if executing config_version fails" do
|
332
|
+
Puppet.settings.stubs(:[]).with(:config_version).returns("test")
|
333
|
+
Puppet::Util.expects(:execute).raises(Puppet::ExecutionFailure.new("msg"))
|
334
|
+
|
335
|
+
lambda { @parser.version }.should raise_error(Puppet::ParseError)
|
336
|
+
end
|
337
|
+
|
330
338
|
end
|
331
339
|
|
332
340
|
describe Puppet::Parser,"when looking up definitions" do
|
@@ -25,7 +25,7 @@ describe Puppet::Parser::Resource do
|
|
25
25
|
params = args[:params] || {:one => "yay", :three => "rah"}
|
26
26
|
if args[:params] == :none
|
27
27
|
args.delete(:params)
|
28
|
-
|
28
|
+
elsif not args[:params].is_a? Array
|
29
29
|
args[:params] = paramify(args[:source], params)
|
30
30
|
end
|
31
31
|
|
@@ -170,6 +170,24 @@ describe Puppet::Parser::Resource do
|
|
170
170
|
@resource[:owner].should == "other"
|
171
171
|
end
|
172
172
|
|
173
|
+
it "should be running in metaparam compatibility mode if running a version below 0.25" do
|
174
|
+
catalog = stub 'catalog', :client_version => "0.24.8"
|
175
|
+
@resource.stubs(:catalog).returns catalog
|
176
|
+
@resource.should be_metaparam_compatibility_mode
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should be running in metaparam compatibility mode if running no client version is available" do
|
180
|
+
catalog = stub 'catalog', :client_version => nil
|
181
|
+
@resource.stubs(:catalog).returns catalog
|
182
|
+
@resource.should be_metaparam_compatibility_mode
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should not be running in metaparam compatibility mode if running a version at or above 0.25" do
|
186
|
+
catalog = stub 'catalog', :client_version => "0.25.0"
|
187
|
+
@resource.stubs(:catalog).returns catalog
|
188
|
+
@resource.should_not be_metaparam_compatibility_mode
|
189
|
+
end
|
190
|
+
|
173
191
|
it "should copy metaparams from its scope" do
|
174
192
|
@scope.setvar("noop", "true")
|
175
193
|
|
@@ -187,14 +205,34 @@ describe Puppet::Parser::Resource do
|
|
187
205
|
@resource["noop"].should == "false"
|
188
206
|
end
|
189
207
|
|
190
|
-
it "should not copy relationship metaparams" do
|
208
|
+
it "should not copy relationship metaparams when not in metaparam compatibility mode" do
|
191
209
|
@scope.setvar("require", "bar")
|
192
210
|
|
211
|
+
@resource.stubs(:metaparam_compatibility_mode?).returns false
|
193
212
|
@resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams }
|
194
213
|
|
195
214
|
@resource["require"].should be_nil
|
196
215
|
end
|
197
216
|
|
217
|
+
it "should copy relationship metaparams when in metaparam compatibility mode" do
|
218
|
+
@scope.setvar("require", "bar")
|
219
|
+
|
220
|
+
@resource.stubs(:metaparam_compatibility_mode?).returns true
|
221
|
+
@resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams }
|
222
|
+
|
223
|
+
@resource["require"].should == "bar"
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should stack relationship metaparams when in metaparam compatibility mode" do
|
227
|
+
@resource.set_parameter("require", "foo")
|
228
|
+
@scope.setvar("require", "bar")
|
229
|
+
|
230
|
+
@resource.stubs(:metaparam_compatibility_mode?).returns true
|
231
|
+
@resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams }
|
232
|
+
|
233
|
+
@resource["require"].should == ["foo", "bar"]
|
234
|
+
end
|
235
|
+
|
198
236
|
it "should copy all metaparams that it finds" do
|
199
237
|
@scope.setvar("noop", "foo")
|
200
238
|
@scope.setvar("schedule", "bar")
|
@@ -445,5 +483,18 @@ describe Puppet::Parser::Resource do
|
|
445
483
|
result = @parser_resource.to_resource
|
446
484
|
result[:fee].should == ["a", Puppet::Resource::Reference.new(:file, "/my/file1"), Puppet::Resource::Reference.new(:file, "/my/file2")]
|
447
485
|
end
|
486
|
+
|
487
|
+
it "should fail if the same param is declared twice" do
|
488
|
+
lambda do
|
489
|
+
@parser_resource = mkresource :source => @source, :params => [
|
490
|
+
Puppet::Parser::Resource::Param.new(
|
491
|
+
:name => :foo, :value => "bar", :source => @source
|
492
|
+
),
|
493
|
+
Puppet::Parser::Resource::Param.new(
|
494
|
+
:name => :foo, :value => "baz", :source => @source
|
495
|
+
)
|
496
|
+
]
|
497
|
+
end.should raise_error(Puppet::ParseError)
|
498
|
+
end
|
448
499
|
end
|
449
500
|
end
|
data/spec/unit/parser/scope.rb
CHANGED
@@ -43,7 +43,7 @@ describe Puppet::Parser::Scope do
|
|
43
43
|
describe "and the variable is qualified" do
|
44
44
|
before do
|
45
45
|
@parser = Puppet::Parser::Parser.new()
|
46
|
-
@compiler = Puppet::Parser::Compiler.new(stub("node", :name => "foonode"), @parser)
|
46
|
+
@compiler = Puppet::Parser::Compiler.new(stub("node", :name => "foonode", :classes => []), @parser)
|
47
47
|
@scope.compiler = @compiler
|
48
48
|
@scope.parser = @parser
|
49
49
|
end
|
data/spec/unit/property.rb
CHANGED
@@ -34,10 +34,12 @@ describe Puppet::Property do
|
|
34
34
|
@class.should respond_to(:required_features=)
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
{"one" => [:one],:one => [:one],%w{a} => [:a],[:b] => [:b],%w{one two} => [:one,:two],[:a,:b] => [:a,:b]}.each { |in_value,out_value|
|
38
|
+
it "should always convert required features into an array of symbols (e.g. #{in_value.inspect} --> #{out_value.inspect})" do
|
39
|
+
@class.required_features = in_value
|
40
|
+
@class.required_features.should == out_value
|
41
|
+
end
|
42
|
+
}
|
41
43
|
|
42
44
|
it "should be able to shadow metaparameters" do
|
43
45
|
@property.must respond_to(:shadow)
|
@@ -200,6 +202,14 @@ describe Puppet::Property do
|
|
200
202
|
lambda { @property.should = :foo }.should raise_error(Puppet::Error)
|
201
203
|
end
|
202
204
|
|
205
|
+
it "should internally raise an ArgumentError if required features are missing" do
|
206
|
+
@class.newvalue(:foo, :required_features => [:a, :b])
|
207
|
+
|
208
|
+
@provider.expects(:satisfies?).with([:a, :b]).returns false
|
209
|
+
|
210
|
+
lambda { @property.validate_features_per_value :foo }.should raise_error(ArgumentError)
|
211
|
+
end
|
212
|
+
|
203
213
|
it "should validate that all required features are present for regexes" do
|
204
214
|
value = @class.newvalue(/./, :required_features => [:a, :b])
|
205
215
|
|
@@ -149,6 +149,13 @@ describe provider do
|
|
149
149
|
@provider.expects(:warning)
|
150
150
|
@provider.latest
|
151
151
|
end
|
152
|
+
|
153
|
+
it "should cope with names containing ++" do
|
154
|
+
@resource = stub 'resource', :[] => "asdf++"
|
155
|
+
@provider = provider.new(@resource)
|
156
|
+
@provider.expects(:dpkg_deb).returns "asdf++\t1.0"
|
157
|
+
@provider.latest.should == "1.0"
|
158
|
+
end
|
152
159
|
end
|
153
160
|
|
154
161
|
it "should use 'dpkg -r' to uninstall" do
|
@@ -65,7 +65,7 @@ describe provider_class do
|
|
65
65
|
|
66
66
|
describe "when starting" do
|
67
67
|
it "should use 'svc' to start the service" do
|
68
|
-
@provider.stubs(:enabled?).returns true
|
68
|
+
@provider.stubs(:enabled?).returns :true
|
69
69
|
@provider.expects(:svc).with("-u", "/etc/service/myservice")
|
70
70
|
|
71
71
|
@provider.start
|
@@ -74,7 +74,7 @@ describe provider_class do
|
|
74
74
|
it "should enable the service if it is not enabled" do
|
75
75
|
@provider.stubs(:svc)
|
76
76
|
|
77
|
-
@provider.expects(:enabled?).returns false
|
77
|
+
@provider.expects(:enabled?).returns :false
|
78
78
|
@provider.expects(:enable)
|
79
79
|
|
80
80
|
@provider.start
|
@@ -124,6 +124,23 @@ describe provider_class do
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
+
describe "when checking if the service is enabled?" do
|
128
|
+
it "should return true if it is running" do
|
129
|
+
@provider.stubs(:status).returns(:running)
|
130
|
+
|
131
|
+
@provider.enabled?.should == :true
|
132
|
+
end
|
133
|
+
|
134
|
+
[true, false].each do |t|
|
135
|
+
it "should return #{t} if the symlink exists" do
|
136
|
+
@provider.stubs(:status).returns(:stopped)
|
137
|
+
FileTest.stubs(:symlink?).returns(t)
|
138
|
+
|
139
|
+
@provider.enabled?.should == "#{t}".to_sym
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
127
144
|
describe "when checking status" do
|
128
145
|
it "should call the external command 'svstat /etc/service/myservice'" do
|
129
146
|
@provider.expects(:svstat).with(File.join(@servicedir,"myservice"))
|
@@ -16,6 +16,8 @@ describe provider_class do
|
|
16
16
|
|
17
17
|
@provider = provider_class.new
|
18
18
|
@provider.resource = @resource
|
19
|
+
FileTest.stubs(:file?).with('/sbin/service').returns true
|
20
|
+
FileTest.stubs(:executable?).with('/sbin/service').returns true
|
19
21
|
end
|
20
22
|
|
21
23
|
it "should have an enabled? method" do
|
@@ -35,6 +35,10 @@ describe provider_class do
|
|
35
35
|
@provider.stubs(:resource).returns @resource
|
36
36
|
end
|
37
37
|
|
38
|
+
it "should have a restart method" do
|
39
|
+
@provider.should respond_to(:restart)
|
40
|
+
end
|
41
|
+
|
38
42
|
it "should have a restartcmd method" do
|
39
43
|
@provider.should respond_to(:restartcmd)
|
40
44
|
end
|
@@ -62,27 +66,34 @@ describe provider_class do
|
|
62
66
|
describe "when starting" do
|
63
67
|
it "should enable the service if it is not enabled" do
|
64
68
|
@provider.stubs(:sv)
|
65
|
-
@provider.stubs(:ucommand)
|
66
69
|
|
67
|
-
@provider.expects(:enabled?).returns false
|
70
|
+
@provider.expects(:enabled?).returns :false
|
68
71
|
@provider.expects(:enable)
|
69
72
|
|
70
73
|
@provider.start
|
71
74
|
end
|
72
75
|
|
73
76
|
it "should execute external command 'sv start /etc/service/myservice'" do
|
74
|
-
@provider.
|
77
|
+
@provider.stubs(:enabled?).returns :true
|
78
|
+
@provider.expects(:sv).with("start", "/etc/service/myservice")
|
75
79
|
@provider.start
|
76
80
|
end
|
77
81
|
end
|
78
82
|
|
79
83
|
describe "when stopping" do
|
80
84
|
it "should execute external command 'sv stop /etc/service/myservice'" do
|
81
|
-
@provider.expects(:
|
85
|
+
@provider.expects(:sv).with("stop", "/etc/service/myservice")
|
82
86
|
@provider.stop
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
90
|
+
describe "when restarting" do
|
91
|
+
it "should call 'sv restart /etc/service/myservice'" do
|
92
|
+
@provider.expects(:sv).with("restart","/etc/service/myservice")
|
93
|
+
@provider.restart
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
86
97
|
describe "when enabling" do
|
87
98
|
it "should create a symlink between daemon dir and service dir" do
|
88
99
|
FileTest.stubs(:symlink?).returns(false)
|
@@ -41,12 +41,12 @@ describe provider_class do
|
|
41
41
|
return text
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
PuppetTest.fakedata("data/providers/ssh_authorized_key/parsed").each { |file|
|
45
|
+
it "should be able to parse example data in #{file}" do
|
46
46
|
puts "Parsing %s" % file
|
47
47
|
fakedataparse(file)
|
48
|
-
|
49
|
-
|
48
|
+
end
|
49
|
+
}
|
50
50
|
|
51
51
|
it "should be able to generate a basic authorized_keys file" do
|
52
52
|
key = mkkey({
|
@@ -95,85 +95,61 @@ describe provider_class do
|
|
95
95
|
File.stubs(:chown)
|
96
96
|
end
|
97
97
|
|
98
|
-
describe "and a user
|
98
|
+
describe "and both a user and a target have been specified" do
|
99
99
|
before :each do
|
100
|
-
|
101
|
-
|
100
|
+
Puppet::Util.stubs(:uid).with("random_bob").returns 12345
|
101
|
+
@resource.stubs(:should).with(:user).returns "random_bob"
|
102
|
+
target = "/tmp/.ssh_dir/place_to_put_authorized_keys"
|
102
103
|
@resource.stubs(:should).with(:target).returns target
|
103
104
|
end
|
104
105
|
|
105
106
|
it "should create the directory" do
|
106
|
-
|
107
|
+
File.stubs(:exist?).with("/tmp/.ssh_dir").returns false
|
108
|
+
Dir.expects(:mkdir).with("/tmp/.ssh_dir", 0700)
|
107
109
|
@provider.flush
|
108
110
|
end
|
109
111
|
|
110
112
|
it "should chown the directory to the user" do
|
111
|
-
uid = Puppet::Util.uid("
|
112
|
-
File.expects(:chown).with(uid, nil,
|
113
|
+
uid = Puppet::Util.uid("random_bob")
|
114
|
+
File.expects(:chown).with(uid, nil, "/tmp/.ssh_dir")
|
113
115
|
@provider.flush
|
114
116
|
end
|
115
117
|
|
116
118
|
it "should chown the key file to the user" do
|
117
|
-
uid = Puppet::Util.uid("
|
118
|
-
File.expects(:chown).with(uid, nil,
|
119
|
+
uid = Puppet::Util.uid("random_bob")
|
120
|
+
File.expects(:chown).with(uid, nil, "/tmp/.ssh_dir/place_to_put_authorized_keys")
|
119
121
|
@provider.flush
|
120
122
|
end
|
121
123
|
|
122
124
|
it "should chmod the key file to 0600" do
|
123
|
-
File.expects(:chmod).with(0600,
|
124
|
-
@provider.flush
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "and a target has been specified" do
|
129
|
-
before :each do
|
130
|
-
@resource.stubs(:should).with(:user).returns nil
|
131
|
-
@resource.stubs(:should).with(:target).returns "/tmp/.ssh/authorized_keys"
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should make the directory" do
|
135
|
-
Dir.expects(:mkdir).with("/tmp/.ssh", 0755)
|
136
|
-
@provider.flush
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should chmod the key file to 0644" do
|
140
|
-
File.expects(:chmod).with(0644, "/tmp/.ssh/authorized_keys")
|
125
|
+
File.expects(:chmod).with(0600, "/tmp/.ssh_dir/place_to_put_authorized_keys")
|
141
126
|
@provider.flush
|
142
127
|
end
|
143
128
|
end
|
144
129
|
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
describe provider_class do
|
149
|
-
before :each do
|
150
|
-
@resource = stub("resource", :name => "foo")
|
151
|
-
@resource.stubs(:[]).returns "foo"
|
152
|
-
@provider = provider_class.new(@resource)
|
153
|
-
end
|
154
|
-
|
155
|
-
describe "when flushing" do
|
156
|
-
before :each do
|
157
|
-
# Stub file and directory operations
|
158
|
-
Dir.stubs(:mkdir)
|
159
|
-
File.stubs(:chmod)
|
160
|
-
File.stubs(:chown)
|
161
|
-
end
|
162
|
-
|
163
|
-
describe "and a user has been specified" do
|
130
|
+
describe "and a user has been specified with no target" do
|
164
131
|
before :each do
|
165
132
|
@resource.stubs(:should).with(:user).returns "nobody"
|
166
133
|
@resource.stubs(:should).with(:target).returns nil
|
134
|
+
#
|
135
|
+
# I'd like to use random_bob here and something like
|
136
|
+
#
|
137
|
+
# File.stubs(:expand_path).with("~random_bob/.ssh").returns "/users/r/random_bob/.ssh"
|
138
|
+
#
|
139
|
+
# but mocha objects strenuously to stubbing File.expand_path
|
140
|
+
# so I'm left with using nobody.
|
141
|
+
@dir = File.expand_path("~nobody/.ssh")
|
167
142
|
end
|
168
143
|
|
169
144
|
it "should create the directory" do
|
170
|
-
|
145
|
+
File.stubs(:exist?).with(@dir).returns false
|
146
|
+
Dir.expects(:mkdir).with(@dir,0700)
|
171
147
|
@provider.flush
|
172
148
|
end
|
173
149
|
|
174
150
|
it "should chown the directory to the user" do
|
175
151
|
uid = Puppet::Util.uid("nobody")
|
176
|
-
File.expects(:chown).with(uid, nil,
|
152
|
+
File.expects(:chown).with(uid, nil, @dir)
|
177
153
|
@provider.flush
|
178
154
|
end
|
179
155
|
|
@@ -189,19 +165,20 @@ describe provider_class do
|
|
189
165
|
end
|
190
166
|
end
|
191
167
|
|
192
|
-
describe "and a target has been specified" do
|
168
|
+
describe "and a target has been specified with no user" do
|
193
169
|
before :each do
|
194
170
|
@resource.stubs(:should).with(:user).returns nil
|
195
|
-
@resource.stubs(:should).with(:target).returns
|
171
|
+
@resource.stubs(:should).with(:target).returns("/tmp/.ssh_dir/place_to_put_authorized_keys")
|
196
172
|
end
|
197
173
|
|
198
174
|
it "should make the directory" do
|
199
|
-
|
175
|
+
File.stubs(:exist?).with("/tmp/.ssh_dir").returns false
|
176
|
+
Dir.expects(:mkdir).with("/tmp/.ssh_dir", 0755)
|
200
177
|
@provider.flush
|
201
178
|
end
|
202
179
|
|
203
180
|
it "should chmod the key file to 0644" do
|
204
|
-
File.expects(:chmod).with(0644, "/tmp/.
|
181
|
+
File.expects(:chmod).with(0644, "/tmp/.ssh_dir/place_to_put_authorized_keys")
|
205
182
|
@provider.flush
|
206
183
|
end
|
207
184
|
end
|