puppet 0.25.4 → 0.25.5
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 +679 -23
- data/LICENSE +2 -2
- data/README +2 -2
- data/README.queueing +1 -1
- data/README.rst +2 -2
- data/Rakefile +4 -2
- data/bin/filebucket +2 -2
- data/bin/pi +1 -1
- data/bin/puppet +2 -2
- data/bin/puppetca +2 -2
- data/bin/puppetd +5 -4
- data/bin/puppetdoc +4 -4
- data/bin/puppetmasterd +2 -2
- data/bin/puppetqd +2 -2
- data/bin/puppetrun +2 -2
- data/bin/ralsh +2 -2
- data/conf/epm.list +2 -2
- data/conf/gentoo/puppet/puppet.conf +0 -4
- data/conf/osx/PackageInfo.plist +1 -1
- data/conf/redhat/logrotate +1 -0
- data/conf/redhat/puppet.conf +0 -4
- data/conf/redhat/puppet.spec +16 -10
- data/conf/solaris/pkginfo +2 -2
- data/conf/solaris/smf/puppetd.xml +3 -3
- data/conf/solaris/smf/puppetmasterd.xml +3 -3
- data/conf/solaris/smf/svc-puppetd +1 -1
- data/conf/solaris/smf/svc-puppetmasterd +1 -1
- data/conf/suse/puppet.spec +16 -14
- data/conf/suse/puppet.suse.patch +16 -0
- data/examples/etc/puppet/fileserver.conf +5 -5
- data/examples/modules/sample-module/README.txt +3 -3
- data/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +1 -1
- data/ext/extlookup.rb +1 -1
- data/ext/nagios/check_puppet.rb +1 -1
- data/ext/nagios/naggen +2 -2
- data/ext/puppet-test +2 -2
- data/ext/puppetlast +1 -1
- data/ext/puppetstoredconfigclean.rb +1 -1
- data/ext/regexp_nodes/regexp_nodes.rb +4 -4
- data/ext/vim/syntax/puppet.vim +5 -3
- data/install.rb +11 -9
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/puppetd.rb +5 -4
- data/lib/puppet/configurer.rb +38 -31
- data/lib/puppet/defaults.rb +18 -13
- data/lib/puppet/file_serving/fileset.rb +2 -2
- data/lib/puppet/file_serving/terminus_helper.rb +1 -0
- data/lib/puppet/indirector/indirection.rb +20 -13
- data/lib/puppet/network/authstore.rb +3 -3
- data/lib/puppet/network/format_handler.rb +1 -1
- data/lib/puppet/network/handler/fileserver.rb +2 -2
- data/lib/puppet/network/handler/master.rb +1 -1
- data/lib/puppet/network/http_pool.rb +0 -2
- data/lib/puppet/network/http_server/webrick.rb +1 -1
- data/lib/puppet/parser/ast/casestatement.rb +4 -4
- data/lib/puppet/parser/ast/ifstatement.rb +2 -1
- data/lib/puppet/parser/ast/leaf.rb +1 -0
- data/lib/puppet/parser/ast/selector.rb +2 -3
- data/lib/puppet/parser/functions/generate.rb +3 -5
- data/lib/puppet/parser/functions/require.rb +8 -1
- data/lib/puppet/parser/functions/template.rb +1 -1
- data/lib/puppet/parser/lexer.rb +1 -7
- data/lib/puppet/parser/resource.rb +10 -4
- data/lib/puppet/parser/scope.rb +61 -9
- data/lib/puppet/provider/augeas/augeas.rb +23 -7
- data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
- data/lib/puppet/provider/maillist/mailman.rb +2 -2
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/service/debian.rb +2 -2
- data/lib/puppet/provider/service/redhat.rb +1 -1
- data/lib/puppet/provider/service/smf.rb +4 -1
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +9 -29
- data/lib/puppet/provider/user/user_role_add.rb +1 -1
- data/lib/puppet/reference/configuration.rb +1 -1
- data/lib/puppet/reference/providers.rb +1 -1
- data/lib/puppet/reports/tagmail.rb +1 -0
- data/lib/puppet/resource/catalog.rb +1 -8
- data/lib/puppet/simple_graph.rb +37 -12
- data/lib/puppet/ssl/certificate.rb +2 -3
- data/lib/puppet/ssl/certificate_authority.rb +1 -1
- data/lib/puppet/ssl/host.rb +19 -12
- data/lib/puppet/sslcertificates/ca.rb +5 -6
- data/lib/puppet/transaction.rb +11 -15
- data/lib/puppet/type/augeas.rb +2 -1
- data/lib/puppet/type/exec.rb +1 -1
- data/lib/puppet/type/file.rb +9 -2
- data/lib/puppet/type/file/checksum.rb +2 -1
- data/lib/puppet/type/file/source.rb +4 -4
- data/lib/puppet/type/maillist.rb +10 -0
- data/lib/puppet/type/mount.rb +5 -3
- data/lib/puppet/type/tidy.rb +36 -30
- data/lib/puppet/util/autoload.rb +2 -2
- data/lib/puppet/util/checksums.rb +5 -0
- data/lib/puppet/util/monkey_patches.rb +38 -0
- data/lib/puppet/util/nagios_maker.rb +1 -1
- data/lib/puppet/util/settings.rb +14 -4
- data/lib/puppet/util/suidmanager.rb +26 -2
- data/lib/puppet/util/zaml.rb +318 -0
- data/man/{man8/puppet.conf.8 → man5/puppet.conf.5} +594 -899
- data/man/man8/filebucket.8 +31 -45
- data/man/man8/pi.8 +16 -22
- data/man/man8/puppet.8 +26 -36
- data/man/man8/puppetca.8 +38 -51
- data/man/man8/puppetd.8 +48 -64
- data/man/man8/puppetdoc.8 +37 -48
- data/man/man8/puppetmasterd.8 +24 -32
- data/man/man8/puppetqd.8 +22 -27
- data/man/man8/puppetrun.8 +46 -58
- data/man/man8/ralsh.8 +43 -48
- data/spec/integration/bin/puppetmasterd.rb +20 -9
- data/spec/integration/defaults.rb +4 -0
- data/spec/integration/indirector/certificate/rest.rb +0 -1
- data/spec/integration/indirector/certificate_request/rest.rb +0 -1
- data/spec/integration/indirector/certificate_revocation_list/rest.rb +0 -1
- data/spec/integration/indirector/report/rest.rb +0 -1
- data/spec/integration/indirector/rest.rb +0 -1
- data/spec/integration/parser/functions/require.rb +18 -1
- data/spec/unit/application/filebucket.rb +2 -2
- data/spec/unit/application/puppetd.rb +4 -5
- data/spec/unit/configurer.rb +46 -8
- data/spec/unit/file_serving/fileset.rb +6 -0
- data/spec/unit/file_serving/terminus_helper.rb +10 -0
- data/spec/unit/indirector/indirection.rb +17 -28
- data/spec/unit/network/format_handler.rb +3 -2
- data/spec/unit/network/http_pool.rb +9 -17
- data/spec/unit/parser/ast/casestatement.rb +4 -12
- data/spec/unit/parser/ast/ifstatement.rb +2 -1
- data/spec/unit/parser/ast/leaf.rb +15 -2
- data/spec/unit/parser/ast/selector.rb +4 -12
- data/spec/unit/parser/functions/generate.rb +41 -0
- data/spec/unit/parser/functions/require.rb +23 -2
- data/spec/unit/parser/resource.rb +18 -0
- data/spec/unit/parser/scope.rb +94 -3
- data/spec/unit/provider/augeas/augeas.rb +27 -3
- data/spec/unit/provider/ssh_authorized_key/parsed.rb +30 -19
- data/spec/unit/resource/catalog.rb +16 -39
- data/spec/unit/simple_graph.rb +14 -0
- data/spec/unit/ssl/host.rb +55 -17
- data/spec/unit/type/file.rb +43 -11
- data/spec/unit/type/file/checksum.rb +28 -0
- data/spec/unit/type/tidy.rb +30 -1
- data/spec/unit/util/autoload.rb +2 -1
- data/spec/unit/util/checksums.rb +7 -1
- data/spec/unit/util/settings.rb +39 -2
- data/spec/unit/util/zaml.rb +38 -0
- data/tasks/rake/changelog.rake +1 -1
- data/tasks/rake/gem.rake +3 -3
- data/tasks/rake/git_workflow.rake +1 -1
- data/tasks/rake/sign.rake +1 -1
- data/tasks/rake/yard.rake +11 -0
- data/test/certmgr/certmgr.rb +1 -1
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -1
- data/test/lib/puppettest/support/utils.rb +2 -1
- data/test/network/handler/ca.rb +4 -4
- data/test/network/handler/fileserver.rb +15 -9
- data/test/other/transactions.rb +1 -6
- data/test/puppet/tc_suidmanager.rb +7 -2
- data/test/ral/providers/host/parsed.rb +6 -6
- data/test/ral/providers/package.rb +4 -0
- data/test/ral/providers/sshkey/parsed.rb +5 -5
- data/test/ral/type/file.rb +0 -21
- data/test/ral/type/host.rb +4 -4
- data/test/ral/type/resources.rb +0 -78
- data/test/ral/type/sshkey.rb +2 -2
- data/test/test +1 -1
- data/test/util/settings.rb +6 -6
- metadata +1065 -1050
- data/test/executables/puppetmodule.rb +0 -55
- data/test/ral/providers/service/debian.rb +0 -58
@@ -28,16 +28,6 @@ describe Puppet::Parser::AST::CaseStatement do
|
|
28
28
|
@casestmt.evaluate(@scope)
|
29
29
|
end
|
30
30
|
|
31
|
-
it "should downcase the evaluated test value if allowed" do
|
32
|
-
Puppet.stubs(:[]).with(:casesensitive).returns(false)
|
33
|
-
value = stub 'test'
|
34
|
-
@test.stubs(:safeevaluate).with(@scope).returns(value)
|
35
|
-
|
36
|
-
value.expects(:downcase)
|
37
|
-
|
38
|
-
@casestmt.evaluate(@scope)
|
39
|
-
end
|
40
|
-
|
41
31
|
it "should scan each option" do
|
42
32
|
@options.expects(:each).multiple_yields(@option1, @option2)
|
43
33
|
|
@@ -121,19 +111,21 @@ describe Puppet::Parser::AST::CaseStatement do
|
|
121
111
|
end
|
122
112
|
|
123
113
|
it "should unset scope ephemeral variables after option evaluation" do
|
114
|
+
@scope.stubs(:ephemeral_level).returns(:level)
|
124
115
|
@opval1.stubs(:evaluate_match).with { |*arg| arg[0] == "value" and arg[1] == @scope }.returns(true)
|
125
116
|
@option1.stubs(:safeevaluate).with(@scope).returns(:result)
|
126
117
|
|
127
|
-
@scope.expects(:unset_ephemeral_var)
|
118
|
+
@scope.expects(:unset_ephemeral_var).with(:level)
|
128
119
|
|
129
120
|
@casestmt.evaluate(@scope)
|
130
121
|
end
|
131
122
|
|
132
123
|
it "should not leak ephemeral variables even if evaluation fails" do
|
124
|
+
@scope.stubs(:ephemeral_level).returns(:level)
|
133
125
|
@opval1.stubs(:evaluate_match).with { |*arg| arg[0] == "value" and arg[1] == @scope }.returns(true)
|
134
126
|
@option1.stubs(:safeevaluate).with(@scope).raises
|
135
127
|
|
136
|
-
@scope.expects(:unset_ephemeral_var)
|
128
|
+
@scope.expects(:unset_ephemeral_var).with(:level)
|
137
129
|
|
138
130
|
lambda { @casestmt.evaluate(@scope) }.should raise_error
|
139
131
|
end
|
@@ -64,10 +64,11 @@ describe Puppet::Parser::AST::IfStatement do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should reset ephemeral statements after evaluation" do
|
67
|
+
@scope.expects(:ephemeral_level).returns(:level)
|
67
68
|
Puppet::Parser::Scope.stubs(:true?).returns(true)
|
68
69
|
|
69
70
|
@stmt.expects(:safeevaluate).with(@scope)
|
70
|
-
@scope.expects(:unset_ephemeral_var)
|
71
|
+
@scope.expects(:unset_ephemeral_var).with(:level)
|
71
72
|
|
72
73
|
@ifstmt.evaluate(@scope)
|
73
74
|
end
|
@@ -33,6 +33,13 @@ describe Puppet::Parser::AST::Leaf do
|
|
33
33
|
|
34
34
|
@leaf.evaluate_match("value", @scope, :insensitive => true)
|
35
35
|
end
|
36
|
+
|
37
|
+
it "should downcase the parameter value if wanted" do
|
38
|
+
parameter = stub 'parameter'
|
39
|
+
parameter.expects(:downcase).returns("value")
|
40
|
+
|
41
|
+
@leaf.evaluate_match(parameter, @scope, :insensitive => true)
|
42
|
+
end
|
36
43
|
end
|
37
44
|
|
38
45
|
describe "when converting to string" do
|
@@ -123,6 +130,12 @@ describe Puppet::Parser::AST::Regex do
|
|
123
130
|
@regex.evaluate_match("value", @scope)
|
124
131
|
end
|
125
132
|
|
133
|
+
it "should not downcase the paramater value" do
|
134
|
+
@value.expects(:match).with("VaLuE")
|
135
|
+
|
136
|
+
@regex.evaluate_match("VaLuE", @scope)
|
137
|
+
end
|
138
|
+
|
126
139
|
it "should set ephemeral scope vars if there is a match" do
|
127
140
|
@scope.expects(:ephemeral_from).with(true, nil, nil)
|
128
141
|
|
@@ -220,8 +233,8 @@ describe Puppet::Parser::AST::HostName do
|
|
220
233
|
end
|
221
234
|
|
222
235
|
it "should return a string usable as a tag when calling to_classname" do
|
223
|
-
host = Puppet::Parser::AST::HostName.new( :value => Puppet::Parser::AST::Regex.new(:value => "/.+.
|
224
|
-
host.to_classname.should == "
|
236
|
+
host = Puppet::Parser::AST::HostName.new( :value => Puppet::Parser::AST::Regex.new(:value => "/.+.puppetlabs\.com/") )
|
237
|
+
host.to_classname.should == "puppetlabs.com"
|
225
238
|
end
|
226
239
|
|
227
240
|
it "should delegate 'match' to the underlying value if it is an HostName" do
|
@@ -40,16 +40,6 @@ describe Puppet::Parser::AST::Selector do
|
|
40
40
|
@selector.evaluate(@scope)
|
41
41
|
end
|
42
42
|
|
43
|
-
it "should downcase the evaluated param value if allowed" do
|
44
|
-
Puppet.stubs(:[]).with(:casesensitive).returns(false)
|
45
|
-
value = stub 'param'
|
46
|
-
@param.stubs(:safeevaluate).with(@scope).returns(value)
|
47
|
-
|
48
|
-
value.expects(:downcase)
|
49
|
-
|
50
|
-
@selector.evaluate(@scope)
|
51
|
-
end
|
52
|
-
|
53
43
|
it "should scan each option" do
|
54
44
|
@values.expects(:each).multiple_yields(@value1, @value2)
|
55
45
|
|
@@ -128,19 +118,21 @@ describe Puppet::Parser::AST::Selector do
|
|
128
118
|
end
|
129
119
|
|
130
120
|
it "should unset scope ephemeral variables after option evaluation" do
|
121
|
+
@scope.stubs(:ephemeral_level).returns(:level)
|
131
122
|
@param1.stubs(:evaluate_match).with { |*arg| arg[0] == "value" and arg[1] == @scope }.returns(true)
|
132
123
|
@value1.stubs(:safeevaluate).with(@scope).returns(:result)
|
133
124
|
|
134
|
-
@scope.expects(:unset_ephemeral_var)
|
125
|
+
@scope.expects(:unset_ephemeral_var).with(:level)
|
135
126
|
|
136
127
|
@selector.evaluate(@scope)
|
137
128
|
end
|
138
129
|
|
139
130
|
it "should not leak ephemeral variables even if evaluation fails" do
|
131
|
+
@scope.stubs(:ephemeral_level).returns(:level)
|
140
132
|
@param1.stubs(:evaluate_match).with { |*arg| arg[0] == "value" and arg[1] == @scope }.returns(true)
|
141
133
|
@value1.stubs(:safeevaluate).with(@scope).raises
|
142
134
|
|
143
|
-
@scope.expects(:unset_ephemeral_var)
|
135
|
+
@scope.expects(:unset_ephemeral_var).with(:level)
|
144
136
|
|
145
137
|
lambda { @selector.evaluate(@scope) }.should raise_error
|
146
138
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
4
|
+
|
5
|
+
describe "the generate function" do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
@scope = Puppet::Parser::Scope.new()
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should exist" do
|
12
|
+
Puppet::Parser::Functions.function("generate").should == "function_generate"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should accept a fully-qualified path as a command" do
|
16
|
+
command = File::SEPARATOR + "command"
|
17
|
+
Puppet::Util.expects(:execute).with([command]).returns("yay")
|
18
|
+
lambda { @scope.function_generate([command]) }.should_not raise_error(Puppet::ParseError)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should not accept a relative path as a command" do
|
22
|
+
command = "command"
|
23
|
+
lambda { @scope.function_generate([command]) }.should raise_error(Puppet::ParseError)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Really not sure how to implement this test, just sure it needs
|
27
|
+
# to be implemented.
|
28
|
+
it "should not accept a command containing illegal characters"
|
29
|
+
|
30
|
+
it "should not accept a command containing '..'" do
|
31
|
+
command = File::SEPARATOR + "command" + File::SEPARATOR + ".." + File::SEPARATOR
|
32
|
+
lambda { @scope.function_generate([command]) }.should raise_error(Puppet::ParseError)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should execute the generate script with the correct working directory" do
|
36
|
+
command = File::SEPARATOR + "command"
|
37
|
+
Dir.expects(:chdir).with(File.dirname(command)).yields
|
38
|
+
Puppet::Util.expects(:execute).with([command]).returns("yay")
|
39
|
+
lambda { @scope.function_generate([command]) }.should_not raise_error(Puppet::ParseError)
|
40
|
+
end
|
41
|
+
end
|
@@ -8,11 +8,13 @@ describe "the require function" do
|
|
8
8
|
@catalog = stub 'catalog'
|
9
9
|
@compiler = stub 'compiler', :catalog => @catalog
|
10
10
|
|
11
|
-
@resource = stub 'resource', :set_parameter => nil, :metaparam_compatibility_mode? => false
|
11
|
+
@resource = stub 'resource', :set_parameter => nil, :metaparam_compatibility_mode? => false, :[] => nil
|
12
12
|
@scope = Puppet::Parser::Scope.new()
|
13
13
|
@scope.stubs(:resource).returns @resource
|
14
14
|
@scope.stubs(:findresource)
|
15
15
|
@scope.stubs(:compiler).returns(@compiler)
|
16
|
+
@klass = stub 'class', :classname => "myclass"
|
17
|
+
@scope.stubs(:find_hostclass).returns(@klass)
|
16
18
|
end
|
17
19
|
|
18
20
|
it "should exist" do
|
@@ -26,7 +28,7 @@ describe "the require function" do
|
|
26
28
|
end
|
27
29
|
|
28
30
|
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) }
|
31
|
+
@resource.expects(:set_parameter).with { |name, value| name == :require and value[0].is_a?(Puppet::Parser::Resource::Reference) }
|
30
32
|
@scope.stubs(:function_include)
|
31
33
|
@scope.function_require("myclass")
|
32
34
|
end
|
@@ -45,4 +47,23 @@ describe "the require function" do
|
|
45
47
|
|
46
48
|
@scope.function_require("myclass")
|
47
49
|
end
|
50
|
+
|
51
|
+
it "should lookup the absolute class path" do
|
52
|
+
@scope.stubs(:function_include)
|
53
|
+
|
54
|
+
@scope.expects(:find_hostclass).with("myclass").returns(@klass)
|
55
|
+
@klass.expects(:classname).returns("myclass")
|
56
|
+
|
57
|
+
@scope.function_require("myclass")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should append the required class to the require parameter" do
|
61
|
+
@scope.stubs(:function_include)
|
62
|
+
Puppet::Parser::Resource::Reference.stubs(:new).returns(:require2)
|
63
|
+
|
64
|
+
@resource.expects(:[]).with(:require).returns(:require1)
|
65
|
+
@resource.expects(:set_parameter).with(:require, [:require1, :require2])
|
66
|
+
|
67
|
+
@scope.function_require("myclass")
|
68
|
+
end
|
48
69
|
end
|
@@ -381,6 +381,24 @@ describe Puppet::Parser::Resource do
|
|
381
381
|
@resource[:testing].should == %w{other testing}
|
382
382
|
end
|
383
383
|
|
384
|
+
it "should not merge parameter values when multiple resources are overriden with '+>' at once " do
|
385
|
+
@resource_2 = mkresource :source => @source
|
386
|
+
|
387
|
+
@resource. set_parameter(:testing, "old_val_1")
|
388
|
+
@resource_2.set_parameter(:testing, "old_val_2")
|
389
|
+
|
390
|
+
@source.stubs(:child_of?).returns true
|
391
|
+
param = Puppet::Parser::Resource::Param.new(:name => :testing, :value => "new_val", :source => @resource.source)
|
392
|
+
param.add = true
|
393
|
+
@override.set_parameter(param)
|
394
|
+
|
395
|
+
@resource. merge(@override)
|
396
|
+
@resource_2.merge(@override)
|
397
|
+
|
398
|
+
@resource [:testing].should == %w{old_val_1 new_val}
|
399
|
+
@resource_2[:testing].should == %w{old_val_2 new_val}
|
400
|
+
end
|
401
|
+
|
384
402
|
it "should promote tag overrides to real tags" do
|
385
403
|
@source.stubs(:child_of?).returns true
|
386
404
|
param = Puppet::Parser::Resource::Param.new(:name => :tag, :value => "testing", :source => @resource.source)
|
data/spec/unit/parser/scope.rb
CHANGED
@@ -221,6 +221,85 @@ describe Puppet::Parser::Scope do
|
|
221
221
|
|
222
222
|
@scope.lookupvar("myvar", false).should == :value1
|
223
223
|
end
|
224
|
+
|
225
|
+
it "should raise an error when setting it again" do
|
226
|
+
@scope.setvar("1", :value2, :ephemeral => true)
|
227
|
+
lambda { @scope.setvar("1", :value3, :ephemeral => true) }.should raise_error
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should declare ephemeral number only variable names" do
|
231
|
+
@scope.ephemeral?("0").should be_true
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should not declare ephemeral other variable names" do
|
235
|
+
@scope.ephemeral?("abc0").should be_nil
|
236
|
+
end
|
237
|
+
|
238
|
+
describe "with more than one level" do
|
239
|
+
it "should prefer latest ephemeral scopes" do
|
240
|
+
@scope.setvar("0", :earliest, :ephemeral => true)
|
241
|
+
@scope.new_ephemeral
|
242
|
+
@scope.setvar("0", :latest, :ephemeral => true)
|
243
|
+
@scope.lookupvar("0", false).should == :latest
|
244
|
+
end
|
245
|
+
|
246
|
+
it "should be able to report the current level" do
|
247
|
+
@scope.ephemeral_level.should == 1
|
248
|
+
@scope.new_ephemeral
|
249
|
+
@scope.ephemeral_level.should == 2
|
250
|
+
end
|
251
|
+
|
252
|
+
it "should check presence of an ephemeral variable accross multiple levels" do
|
253
|
+
@scope.new_ephemeral
|
254
|
+
@scope.setvar("1", :value1, :ephemeral => true)
|
255
|
+
@scope.new_ephemeral
|
256
|
+
@scope.setvar("0", :value2, :ephemeral => true)
|
257
|
+
@scope.new_ephemeral
|
258
|
+
@scope.ephemeral_include?("1").should be_true
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should return false when an ephemeral variable doesn't exist in any ephemeral scope" do
|
262
|
+
@scope.new_ephemeral
|
263
|
+
@scope.setvar("1", :value1, :ephemeral => true)
|
264
|
+
@scope.new_ephemeral
|
265
|
+
@scope.setvar("0", :value2, :ephemeral => true)
|
266
|
+
@scope.new_ephemeral
|
267
|
+
@scope.ephemeral_include?("2").should be_false
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should get ephemeral values from earlier scope when not in later" do
|
271
|
+
@scope.setvar("1", :value1, :ephemeral => true)
|
272
|
+
@scope.new_ephemeral
|
273
|
+
@scope.setvar("0", :value2, :ephemeral => true)
|
274
|
+
@scope.lookupvar("1", false).should == :value1
|
275
|
+
end
|
276
|
+
|
277
|
+
describe "when calling unset_ephemeral_var without a level" do
|
278
|
+
it "should remove all the variables values" do
|
279
|
+
@scope.setvar("1", :value1, :ephemeral => true)
|
280
|
+
@scope.new_ephemeral
|
281
|
+
@scope.setvar("1", :value2, :ephemeral => true)
|
282
|
+
|
283
|
+
@scope.unset_ephemeral_var
|
284
|
+
|
285
|
+
@scope.lookupvar("1", false).should == :undefined
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
describe "when calling unset_ephemeral_var with a level" do
|
290
|
+
it "should remove ephemeral scopes up to this level" do
|
291
|
+
@scope.setvar("1", :value1, :ephemeral => true)
|
292
|
+
@scope.new_ephemeral
|
293
|
+
@scope.setvar("1", :value2, :ephemeral => true)
|
294
|
+
@scope.new_ephemeral
|
295
|
+
@scope.setvar("1", :value3, :ephemeral => true)
|
296
|
+
|
297
|
+
@scope.unset_ephemeral_var(2)
|
298
|
+
|
299
|
+
@scope.lookupvar("1", false).should == :value2
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
224
303
|
end
|
225
304
|
|
226
305
|
describe "when interpolating string" do
|
@@ -278,6 +357,11 @@ describe Puppet::Parser::Scope do
|
|
278
357
|
|
279
358
|
@scope.ephemeral_from(@match)
|
280
359
|
end
|
360
|
+
|
361
|
+
it "should create a new ephemeral level" do
|
362
|
+
@scope.expects(:new_ephemeral)
|
363
|
+
@scope.ephemeral_from(@match)
|
364
|
+
end
|
281
365
|
end
|
282
366
|
|
283
367
|
describe "when unsetting variables" do
|
@@ -288,9 +372,16 @@ describe Puppet::Parser::Scope do
|
|
288
372
|
end
|
289
373
|
|
290
374
|
it "should be able to unset ephemeral variables" do
|
291
|
-
@scope.setvar("
|
292
|
-
@scope.unsetvar("
|
293
|
-
@scope.lookupvar("
|
375
|
+
@scope.setvar("0", "bar", :ephemeral => true)
|
376
|
+
@scope.unsetvar("0")
|
377
|
+
@scope.lookupvar("0").should == ""
|
378
|
+
end
|
379
|
+
|
380
|
+
it "should not unset ephemeral variables in previous ephemeral scope" do
|
381
|
+
@scope.setvar("0", "bar", :ephemeral => true)
|
382
|
+
@scope.new_ephemeral
|
383
|
+
@scope.unsetvar("0")
|
384
|
+
@scope.lookupvar("0").should == "bar"
|
294
385
|
end
|
295
386
|
end
|
296
387
|
end
|
@@ -141,6 +141,20 @@ describe provider_class do
|
|
141
141
|
tokens.should == [ args ]
|
142
142
|
end
|
143
143
|
|
144
|
+
it "should allow single quoted escaped spaces in paths" do
|
145
|
+
@resource.stubs(:[]).returns("/foo/")
|
146
|
+
args = [ "set", "'/white\\ space/key'", "value" ]
|
147
|
+
tokens = @provider.parse_commands(args.join(" \t "))
|
148
|
+
tokens.should == [[ "set", "/white\\ space/key", "value" ]]
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should allow double quoted escaped spaces in paths" do
|
152
|
+
@resource.stubs(:[]).returns("/foo/")
|
153
|
+
args = [ "set", '"/white\\ space/key"', "value" ]
|
154
|
+
tokens = @provider.parse_commands(args.join(" \t "))
|
155
|
+
tokens.should == [[ "set", "/white\\ space/key", "value" ]]
|
156
|
+
end
|
157
|
+
|
144
158
|
it "should remove trailing slashes" do
|
145
159
|
@resource.stubs(:[]).returns("/foo/")
|
146
160
|
tokens = @provider.parse_commands("set foo/ bar")
|
@@ -204,6 +218,16 @@ describe provider_class do
|
|
204
218
|
@provider.process_match(command).should == false
|
205
219
|
end
|
206
220
|
|
221
|
+
it "should return true for includes match" do
|
222
|
+
command = ["match", "fake value", "not_include JarJar"]
|
223
|
+
@provider.process_match(command).should == true
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should return false for includes non match" do
|
227
|
+
command = ["match", "fake value", "not_include values"]
|
228
|
+
@provider.process_match(command).should == false
|
229
|
+
end
|
230
|
+
|
207
231
|
it "should return true for an array match" do
|
208
232
|
command = ["match", "fake value", "== ['set', 'of', 'values']"]
|
209
233
|
@provider.process_match(command).should == true
|
@@ -308,7 +332,7 @@ describe provider_class do
|
|
308
332
|
command = "set JarJar Binks"
|
309
333
|
context = "/some/path/"
|
310
334
|
@resource.expects(:[]).times(2).returns(command).then.returns(context)
|
311
|
-
@augeas.expects(:set).with("/some/path/JarJar", "Binks")
|
335
|
+
@augeas.expects(:set).with("/some/path/JarJar", "Binks").returns(true)
|
312
336
|
@augeas.expects(:save).returns(true)
|
313
337
|
@augeas.expects(:close)
|
314
338
|
@provider.execute_changes.should == :executed
|
@@ -338,7 +362,7 @@ describe provider_class do
|
|
338
362
|
command = "clear Jar/Jar"
|
339
363
|
context = "/foo/"
|
340
364
|
@resource.expects(:[]).times(2).returns(command).then.returns(context)
|
341
|
-
@augeas.expects(:clear).with("/foo/Jar/Jar")
|
365
|
+
@augeas.expects(:clear).with("/foo/Jar/Jar").returns(true)
|
342
366
|
@augeas.expects(:save).returns(true)
|
343
367
|
@augeas.expects(:close)
|
344
368
|
@provider.execute_changes.should == :executed
|
@@ -380,7 +404,7 @@ describe provider_class do
|
|
380
404
|
context = "/foo/"
|
381
405
|
@resource.expects(:[]).times(2).returns(command).then.returns(context)
|
382
406
|
@augeas.expects(:insert).with("/Jar/Jar", "Binks", false)
|
383
|
-
@augeas.expects(:clear).with("/foo/Jar/Jar")
|
407
|
+
@augeas.expects(:clear).with("/foo/Jar/Jar").returns(true)
|
384
408
|
@augeas.expects(:save).returns(true)
|
385
409
|
@augeas.expects(:close)
|
386
410
|
@provider.execute_changes.should == :executed
|
@@ -15,6 +15,9 @@ describe provider_class do
|
|
15
15
|
before :each do
|
16
16
|
@sshauthkey_class = Puppet::Type.type(:ssh_authorized_key)
|
17
17
|
@provider = @sshauthkey_class.provider(:parsed)
|
18
|
+
@keyfile = File.join(tmpdir, 'authorized_keys')
|
19
|
+
@user = 'random_bob'
|
20
|
+
Puppet::Util.stubs(:uid).with(@user).returns 12345
|
18
21
|
end
|
19
22
|
|
20
23
|
after :each do
|
@@ -23,22 +26,23 @@ describe provider_class do
|
|
23
26
|
|
24
27
|
def mkkey(args)
|
25
28
|
fakeresource = fakeresource(:ssh_authorized_key, args[:name])
|
29
|
+
fakeresource.stubs(:should).with(:user).returns @user
|
30
|
+
fakeresource.stubs(:should).with(:target).returns @keyfile
|
26
31
|
|
27
32
|
key = @provider.new(fakeresource)
|
28
33
|
args.each do |p,v|
|
29
34
|
key.send(p.to_s + "=", v)
|
30
35
|
end
|
31
36
|
|
32
|
-
|
37
|
+
key
|
33
38
|
end
|
34
39
|
|
35
40
|
def genkey(key)
|
36
41
|
@provider.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam)
|
37
|
-
|
38
|
-
|
42
|
+
File.stubs(:chown)
|
43
|
+
File.stubs(:chmod)
|
39
44
|
key.flush
|
40
|
-
|
41
|
-
return text
|
45
|
+
@provider.target_object(@keyfile).read
|
42
46
|
end
|
43
47
|
|
44
48
|
PuppetTest.fakedata("data/providers/ssh_authorized_key/parsed").each { |file|
|
@@ -73,7 +77,7 @@ describe provider_class do
|
|
73
77
|
end
|
74
78
|
|
75
79
|
it "'s parse_options method should be able to parse options containing commas" do
|
76
|
-
options = %w{from="host1.reductlivelabs.com,host.
|
80
|
+
options = %w{from="host1.reductlivelabs.com,host.puppetlabs.com" command="/usr/local/bin/run" ssh-pty}
|
77
81
|
optionstr = options.join(", ")
|
78
82
|
|
79
83
|
@provider.parse_options(optionstr).should == options
|
@@ -147,20 +151,35 @@ describe provider_class do
|
|
147
151
|
# but mocha objects strenuously to stubbing File.expand_path
|
148
152
|
# so I'm left with using nobody.
|
149
153
|
@dir = File.expand_path("~nobody/.ssh")
|
150
|
-
|
154
|
+
end
|
151
155
|
|
152
|
-
it "should create the directory" do
|
156
|
+
it "should create the directory if it doesn't exist" do
|
153
157
|
File.stubs(:exist?).with(@dir).returns false
|
154
158
|
Dir.expects(:mkdir).with(@dir,0700)
|
155
159
|
@provider.flush
|
156
160
|
end
|
157
161
|
|
158
|
-
it "should chown the directory
|
162
|
+
it "should not create or chown the directory if it already exist" do
|
163
|
+
File.stubs(:exist?).with(@dir).returns false
|
164
|
+
Dir.expects(:mkdir).never
|
165
|
+
@provider.flush
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should chown the directory to the user if it creates it" do
|
169
|
+
File.stubs(:exist?).with(@dir).returns false
|
170
|
+
Dir.stubs(:mkdir).with(@dir,0700)
|
159
171
|
uid = Puppet::Util.uid("nobody")
|
160
172
|
File.expects(:chown).with(uid, nil, @dir)
|
161
173
|
@provider.flush
|
162
174
|
end
|
163
175
|
|
176
|
+
it "should not create or chown the directory if it already exist" do
|
177
|
+
File.stubs(:exist?).with(@dir).returns false
|
178
|
+
Dir.expects(:mkdir).never
|
179
|
+
File.expects(:chown).never
|
180
|
+
@provider.flush
|
181
|
+
end
|
182
|
+
|
164
183
|
it "should chown the key file to the user" do
|
165
184
|
uid = Puppet::Util.uid("nobody")
|
166
185
|
File.expects(:chown).with(uid, nil, File.expand_path("~nobody/.ssh/authorized_keys"))
|
@@ -179,17 +198,9 @@ describe provider_class do
|
|
179
198
|
@resource.stubs(:should).with(:target).returns("/tmp/.ssh_dir/place_to_put_authorized_keys")
|
180
199
|
end
|
181
200
|
|
182
|
-
it "should
|
183
|
-
|
184
|
-
Dir.expects(:mkdir).with("/tmp/.ssh_dir", 0755)
|
185
|
-
@provider.flush
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should chmod the key file to 0644" do
|
189
|
-
File.expects(:chmod).with(0644, "/tmp/.ssh_dir/place_to_put_authorized_keys")
|
190
|
-
@provider.flush
|
201
|
+
it "should raise an error" do
|
202
|
+
proc { @provider.flush }.should raise_error
|
191
203
|
end
|
192
204
|
end
|
193
|
-
|
194
205
|
end
|
195
206
|
end
|