puppet 0.25.1 → 0.25.2
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 +159 -135
- data/Rakefile +4 -1
- data/conf/gentoo/conf.d/puppetmaster +1 -1
- data/conf/osx/createpackage.sh +12 -0
- data/conf/osx/preflight +4 -0
- data/conf/redhat/puppet.spec +12 -2
- data/conf/redhat/server.init +1 -0
- data/conf/redhat/server.sysconfig +1 -1
- data/ext/ldap/puppet.schema +5 -9
- data/ext/puppetlast +2 -1
- data/ext/rack/README +2 -2
- data/ext/regexp_nodes/classes/databases +2 -0
- data/ext/regexp_nodes/classes/webservers +2 -0
- data/ext/regexp_nodes/parameters/environment/prod +1 -0
- data/ext/regexp_nodes/parameters/environment/qa +3 -0
- data/ext/regexp_nodes/regexp_nodes.rb +215 -0
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +2 -2
- data/lib/puppet/application/puppet.rb +1 -1
- data/lib/puppet/application/puppetd.rb +1 -1
- data/lib/puppet/application/puppetdoc.rb +4 -3
- data/lib/puppet/application/puppetrun.rb +5 -14
- data/lib/puppet/application/ralsh.rb +9 -25
- data/lib/puppet/configurer.rb +2 -1
- data/lib/puppet/configurer/fact_handler.rb +8 -6
- data/lib/puppet/daemon.rb +2 -2
- data/lib/puppet/defaults.rb +21 -2
- data/lib/puppet/external/pson/common.rb +1 -1
- data/lib/puppet/external/pson/pure.rb +3 -3
- data/lib/puppet/feature/base.rb +3 -0
- data/lib/puppet/feature/selinux.rb +3 -0
- data/lib/puppet/feature/zlib.rb +6 -0
- data/lib/puppet/file_serving/base.rb +16 -1
- data/lib/puppet/file_serving/metadata.rb +46 -9
- data/lib/puppet/file_serving/mount/file.rb +4 -1
- data/lib/puppet/indirector/catalog/active_record.rb +5 -0
- data/lib/puppet/indirector/envelope.rb +1 -3
- data/lib/puppet/indirector/indirection.rb +13 -16
- data/lib/puppet/indirector/node/ldap.rb +7 -4
- data/lib/puppet/indirector/ssl_file.rb +1 -1
- data/lib/puppet/network/authstore.rb +48 -118
- data/lib/puppet/network/client/resource.rb +2 -15
- data/lib/puppet/network/format.rb +2 -12
- data/lib/puppet/network/format_handler.rb +15 -1
- data/lib/puppet/network/formats.rb +19 -4
- data/lib/puppet/network/handler/fileserver.rb +1 -0
- data/lib/puppet/network/http/handler.rb +1 -0
- data/lib/puppet/network/http/rack/httphandler.rb +0 -18
- data/lib/puppet/network/http/rack/rest.rb +4 -4
- data/lib/puppet/network/http/rack/xmlrpc.rb +4 -4
- data/lib/puppet/network/http/webrick.rb +2 -1
- data/lib/puppet/network/server.rb +1 -1
- data/lib/puppet/node/environment.rb +20 -9
- data/lib/puppet/parameter.rb +17 -1
- data/lib/puppet/parser/ast/boolean_operator.rb +2 -2
- data/lib/puppet/parser/ast/leaf.rb +5 -1
- data/lib/puppet/parser/ast/resourceparam.rb +4 -0
- data/lib/puppet/parser/ast/selector.rb +4 -0
- data/lib/puppet/parser/functions/generate.rb +2 -2
- data/lib/puppet/parser/functions/shellquote.rb +1 -1
- data/lib/puppet/property.rb +3 -11
- data/lib/puppet/provider/cron/crontab.rb +2 -0
- data/lib/puppet/provider/host/parsed.rb +9 -9
- data/lib/puppet/provider/package/blastwave.rb +7 -6
- data/lib/puppet/provider/package/portage.rb +23 -27
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +5 -3
- data/lib/puppet/provider/service/daemontools.rb +1 -1
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/runit.rb +1 -1
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -1
- data/lib/puppet/provider/sshkey/parsed.rb +3 -5
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/rails.rb +9 -2
- data/lib/puppet/rails/benchmark.rb +1 -1
- data/lib/puppet/rails/host.rb +2 -7
- data/lib/puppet/rails/resource.rb +20 -26
- data/lib/puppet/resource/catalog.rb +3 -3
- data/lib/puppet/resource/reference.rb +13 -25
- data/lib/puppet/ssl/certificate.rb +3 -2
- data/lib/puppet/ssl/host.rb +14 -33
- data/lib/puppet/sslcertificates.rb +1 -5
- data/lib/puppet/sslcertificates/ca.rb +8 -7
- data/lib/puppet/transaction.rb +15 -12
- data/lib/puppet/type.rb +12 -5
- data/lib/puppet/type/file.rb +26 -32
- data/lib/puppet/type/file/content.rb +5 -5
- data/lib/puppet/type/file/ensure.rb +6 -17
- data/lib/puppet/type/file/mode.rb +18 -1
- data/lib/puppet/type/file/source.rb +12 -12
- data/lib/puppet/type/host.rb +6 -9
- data/lib/puppet/type/k5login.rb +1 -1
- data/lib/puppet/type/maillist.rb +4 -7
- data/lib/puppet/type/port.rb +6 -5
- data/lib/puppet/type/resources.rb +12 -12
- data/lib/puppet/type/sshkey.rb +5 -5
- data/lib/puppet/type/tidy.rb +9 -2
- data/lib/puppet/type/yumrepo.rb +3 -1
- data/lib/puppet/util.rb +64 -56
- data/lib/puppet/util/backups.rb +2 -1
- data/lib/puppet/util/filetype.rb +46 -0
- data/lib/puppet/util/log.rb +10 -18
- data/lib/puppet/util/log_paths.rb +14 -0
- data/lib/puppet/util/methodhelper.rb +3 -4
- data/lib/puppet/util/monkey_patches.rb +8 -0
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +5 -3
- data/lib/puppet/util/rdoc/parser.rb +32 -16
- data/lib/puppet/util/reference.rb +6 -3
- data/lib/puppet/util/selinux.rb +21 -14
- data/lib/puppet/util/settings.rb +30 -25
- data/lib/puppet/util/settings/file_setting.rb +7 -4
- data/lib/puppet/util/subclass_loader.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +11 -1
- data/lib/puppet/util/tagging.rb +22 -4
- data/man/man8/filebucket.8 +23 -18
- data/man/man8/pi.8 +42 -20
- data/man/man8/puppet.8 +47 -32
- data/man/man8/puppet.conf.8 +807 -764
- data/man/man8/puppetca.8 +24 -14
- data/man/man8/puppetd.8 +33 -16
- data/man/man8/puppetdoc.8 +71 -18
- data/man/man8/puppetmasterd.8 +18 -25
- data/man/man8/puppetqd.8 +60 -0
- data/man/man8/puppetrun.8 +27 -14
- data/man/man8/ralsh.8 +33 -40
- data/spec/integration/bin/puppetmasterd.rb +3 -2
- data/spec/integration/defaults.rb +11 -0
- data/spec/integration/file_serving/metadata.rb +1 -0
- data/spec/integration/indirector/file_content/file_server.rb +2 -1
- data/spec/integration/ssl/certificate_request.rb +2 -0
- data/spec/integration/type/file.rb +20 -1
- data/spec/shared_behaviours/file_serving.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/application/puppet.rb +11 -30
- data/spec/unit/application/puppetd.rb +1 -0
- data/spec/unit/application/puppetdoc.rb +13 -4
- data/spec/unit/application/puppetmasterd.rb +1 -0
- data/spec/unit/application/puppetrun.rb +12 -2
- data/spec/unit/application/ralsh.rb +39 -22
- data/spec/unit/configurer.rb +6 -0
- data/spec/unit/configurer/fact_handler.rb +15 -1
- data/spec/unit/file_serving/metadata.rb +128 -16
- data/spec/unit/file_serving/mount/file.rb +8 -0
- data/spec/unit/indirector/catalog/active_record.rb +20 -1
- data/spec/unit/indirector/catalog/compiler.rb +2 -1
- data/spec/unit/indirector/indirection.rb +29 -18
- data/spec/unit/indirector/node/ldap.rb +20 -6
- data/spec/unit/network/authstore.rb +197 -0
- data/spec/unit/network/format_handler.rb +28 -8
- data/spec/unit/network/formats.rb +31 -0
- data/spec/unit/network/http/handler.rb +10 -0
- data/spec/unit/network/http/webrick.rb +2 -2
- data/spec/unit/network/rest_authconfig.rb +2 -2
- data/spec/unit/network/rights.rb +1 -1
- data/spec/unit/node/environment.rb +39 -23
- data/spec/unit/other/selinux.rb +2 -2
- data/spec/unit/parameter.rb +8 -0
- data/spec/unit/parser/ast/leaf.rb +9 -0
- data/spec/unit/parser/ast/selector.rb +8 -1
- data/spec/unit/parser/lexer.rb +1 -1
- data/spec/unit/parser/resource.rb +11 -0
- data/spec/unit/parser/resource/reference.rb +13 -1
- data/spec/unit/property.rb +6 -0
- data/spec/unit/provider/mount/parsed.rb +3 -1
- data/spec/unit/provider/service/debian.rb +1 -1
- data/spec/unit/provider/ssh_authorized_key/parsed.rb +9 -1
- data/spec/unit/provider/sshkey/parsed.rb +19 -0
- data/spec/unit/rails.rb +22 -9
- data/spec/unit/rails/resource.rb +20 -0
- data/spec/unit/ssl/host.rb +19 -57
- data/spec/unit/transaction.rb +39 -4
- data/spec/unit/type.rb +9 -0
- data/spec/unit/type/file/content.rb +29 -0
- data/spec/unit/type/maillist.rb +42 -0
- data/spec/unit/type/resources.rb +66 -1
- data/spec/unit/type/tidy.rb +14 -1
- data/spec/unit/util/autoload.rb +2 -0
- data/spec/unit/util/ldap/connection.rb +1 -1
- data/spec/unit/util/log.rb +14 -0
- data/spec/unit/util/monkey_patches.rb +103 -0
- data/spec/unit/util/queue.rb +10 -2
- data/spec/unit/util/selinux.rb +61 -2
- data/spec/unit/util/settings.rb +19 -0
- data/spec/unit/util/settings/file_setting.rb +25 -0
- data/spec/unit/util/tagging.rb +10 -0
- data/tasks/rake/changelog.rake +15 -0
- data/tasks/rake/ci.rake +22 -0
- data/tasks/rake/dailybuild.rake +9 -0
- data/tasks/rake/gem.rake +46 -0
- data/tasks/rake/git_workflow.rake +121 -0
- data/tasks/rake/metrics.rake +6 -0
- data/tasks/rake/sign.rake +14 -0
- data/tasks/rake/testbranch.rake +16 -0
- data/tasks/rake/tracdocs.rake +8 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -0
- metadata +1042 -1288
- data/ext/bin/sleeper +0 -67
- data/ext/module_puppet +0 -209
@@ -15,7 +15,7 @@ end
|
|
15
15
|
|
16
16
|
describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do
|
17
17
|
before do
|
18
|
-
@mock_webrick = stub('webrick', :[] => {})
|
18
|
+
@mock_webrick = stub('webrick', :[] => {}, :listeners => [], :status => :Running)
|
19
19
|
[:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
|
20
20
|
WEBrick::HTTPServer.stubs(:new).returns(@mock_webrick)
|
21
21
|
@server = Puppet::Network::HTTP::WEBrick.new
|
@@ -162,7 +162,7 @@ end
|
|
162
162
|
|
163
163
|
describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do
|
164
164
|
before do
|
165
|
-
@mock_webrick = stub('webrick', :[] => {})
|
165
|
+
@mock_webrick = stub('webrick', :[] => {}, :listeners => [], :status => :Running)
|
166
166
|
[:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
|
167
167
|
WEBrick::HTTPServer.stubs(:new).returns(@mock_webrick)
|
168
168
|
@server = Puppet::Network::HTTP::WEBrick.new
|
@@ -84,7 +84,7 @@ describe Puppet::Network::RestAuthConfig do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
DEFAULT_ACL.each do |acl|
|
87
|
-
it "should insert #{acl} if not present" do
|
87
|
+
it "should insert #{acl[:acl]} if not present" do
|
88
88
|
@authconfig.rights.stubs(:[]).returns(true)
|
89
89
|
@authconfig.rights.stubs(:[]).with(acl[:acl]).returns(nil)
|
90
90
|
|
@@ -93,7 +93,7 @@ describe Puppet::Network::RestAuthConfig do
|
|
93
93
|
@authconfig.insert_default_acl
|
94
94
|
end
|
95
95
|
|
96
|
-
it "should not insert #{acl} if present" do
|
96
|
+
it "should not insert #{acl[:acl]} if present" do
|
97
97
|
@authconfig.rights.stubs(:[]).returns(true)
|
98
98
|
@authconfig.rights.stubs(:[]).with(acl).returns(true)
|
99
99
|
|
data/spec/unit/network/rights.rb
CHANGED
@@ -22,6 +22,10 @@ describe Puppet::Node::Environment do
|
|
22
22
|
Puppet::Node::Environment.attr_ttl(:modules).should == Integer(Puppet[:filetimeout])
|
23
23
|
end
|
24
24
|
|
25
|
+
it "should use the filetimeout for the ttl for the manifestdir" do
|
26
|
+
Puppet::Node::Environment.attr_ttl(:manifestdir).should == Integer(Puppet[:filetimeout])
|
27
|
+
end
|
28
|
+
|
25
29
|
it "should use the default environment if no name is provided while initializing an environment" do
|
26
30
|
Puppet.settings.expects(:value).with(:environment).returns("one")
|
27
31
|
Puppet::Node::Environment.new().name.should == :one
|
@@ -39,45 +43,57 @@ describe Puppet::Node::Environment do
|
|
39
43
|
Puppet::Node::Environment.new(:one).to_s.should == "one"
|
40
44
|
end
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
[:modulepath, :manifestdir].each do |setting|
|
47
|
+
it "should validate the #{setting} directories" do
|
48
|
+
path = %w{/one /two}.join(File::PATH_SEPARATOR)
|
49
|
+
|
50
|
+
env = Puppet::Node::Environment.new("testing")
|
51
|
+
env.stubs(:[]).with(setting).returns path
|
52
|
+
|
53
|
+
env.expects(:validate_dirs).with(%w{/one /two})
|
54
|
+
|
55
|
+
env.send(setting)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should return the validated dirs for #{setting}" do
|
59
|
+
path = %w{/one /two}.join(File::PATH_SEPARATOR)
|
47
60
|
|
48
|
-
|
61
|
+
env = Puppet::Node::Environment.new("testing")
|
62
|
+
env.stubs(:[]).with(setting).returns path
|
63
|
+
env.stubs(:validate_dirs).returns %w{/one /two}
|
64
|
+
|
65
|
+
env.send(setting).should == %w{/one /two}
|
66
|
+
end
|
49
67
|
end
|
50
68
|
|
51
69
|
it "should prefix the value of the 'PUPPETLIB' environment variable to the module path if present" do
|
52
|
-
FileTest.stubs(:directory?).returns true
|
53
70
|
Puppet::Util::Execution.withenv("PUPPETLIB" => %w{/l1 /l2}.join(File::PATH_SEPARATOR)) do
|
54
71
|
env = Puppet::Node::Environment.new("testing")
|
55
72
|
module_path = %w{/one /two}.join(File::PATH_SEPARATOR)
|
73
|
+
env.expects(:validate_dirs).with(%w{/l1 /l2 /one /two}).returns %w{/l1 /l2 /one /two}
|
56
74
|
env.expects(:[]).with(:modulepath).returns module_path
|
57
75
|
|
58
76
|
env.modulepath.should == %w{/l1 /l2 /one /two}
|
59
77
|
end
|
60
78
|
end
|
61
79
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
env.expects(:[]).with(:modulepath).returns module_path
|
80
|
+
describe "when validating modulepath or manifestdir directories" do
|
81
|
+
it "should not return non-directories" do
|
82
|
+
env = Puppet::Node::Environment.new("testing")
|
66
83
|
|
67
|
-
|
68
|
-
|
84
|
+
FileTest.expects(:directory?).with("/one").returns true
|
85
|
+
FileTest.expects(:directory?).with("/two").returns false
|
69
86
|
|
70
|
-
|
71
|
-
|
87
|
+
env.validate_dirs(%w{/one /two}).should == %w{/one}
|
88
|
+
end
|
72
89
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
module_path = %w{/one two}.join(File::PATH_SEPARATOR)
|
77
|
-
env.expects(:[]).with(:modulepath).returns module_path
|
90
|
+
it "should use the current working directory to fully-qualify unqualified paths" do
|
91
|
+
FileTest.stubs(:directory?).returns true
|
92
|
+
env = Puppet::Node::Environment.new("testing")
|
78
93
|
|
79
|
-
|
80
|
-
|
94
|
+
two = File.join(Dir.getwd, "two")
|
95
|
+
env.validate_dirs(%w{/one two}).should == ["/one", two]
|
96
|
+
end
|
81
97
|
end
|
82
98
|
|
83
99
|
describe "when modeling a specific environment" do
|
@@ -155,7 +171,7 @@ describe Puppet::Node::Environment do
|
|
155
171
|
env.expects(:modulepath).returns %w{/a}
|
156
172
|
Dir.expects(:entries).with("/a").returns %w{foo}
|
157
173
|
|
158
|
-
env.modules.
|
174
|
+
env.modules.each {|mod| mod.environment.should == env }
|
159
175
|
end
|
160
176
|
|
161
177
|
it "should cache the module list" do
|
data/spec/unit/other/selinux.rb
CHANGED
@@ -28,7 +28,7 @@ end
|
|
28
28
|
describe Puppet::Type.type(:selboolean), " when manipulating booleans" do
|
29
29
|
before :each do
|
30
30
|
provider_class = Puppet::Type::Selboolean.provider(Puppet::Type::Selboolean.providers[0])
|
31
|
-
Puppet::Type::Selboolean.
|
31
|
+
Puppet::Type::Selboolean.stubs(:defaultprovider).returns provider_class
|
32
32
|
|
33
33
|
@bool = Puppet::Type::Selboolean.new(
|
34
34
|
:name => "foo",
|
@@ -57,7 +57,7 @@ end
|
|
57
57
|
describe Puppet::Type.type(:selmodule), " when checking policy modules" do
|
58
58
|
before :each do
|
59
59
|
provider_class = Puppet::Type::Selmodule.provider(Puppet::Type::Selmodule.providers[0])
|
60
|
-
Puppet::Type::Selmodule.
|
60
|
+
Puppet::Type::Selmodule.stubs(:defaultprovider).returns provider_class
|
61
61
|
|
62
62
|
@module = Puppet::Type::Selmodule.new(
|
63
63
|
:name => "foo",
|
data/spec/unit/parameter.rb
CHANGED
@@ -44,6 +44,14 @@ describe Puppet::Parameter do
|
|
44
44
|
@parameter.tags.should == %w{one two foo}
|
45
45
|
end
|
46
46
|
|
47
|
+
it "should provide source_descriptors" do
|
48
|
+
@resource.expects(:line).returns 10
|
49
|
+
@resource.expects(:file).returns "file"
|
50
|
+
@resource.expects(:tags).returns %w{one two}
|
51
|
+
@resource.expects(:version).returns 50
|
52
|
+
@parameter.source_descriptors.should == {:tags=>["one", "two", "foo"], :path=>"//foo", :version=>50, :file => "file", :line => 10}
|
53
|
+
end
|
54
|
+
|
47
55
|
describe "when returning the value" do
|
48
56
|
it "should return nil if no value is set" do
|
49
57
|
@parameter.value.should be_nil
|
@@ -72,6 +72,15 @@ describe Puppet::Parser::AST::String do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
describe Puppet::Parser::AST::Variable do
|
76
|
+
describe "when converting to string" do
|
77
|
+
it "should transform its value to a variable" do
|
78
|
+
value = stub 'value', :is_a? => true, :to_s => "myvar"
|
79
|
+
Puppet::Parser::AST::Variable.new( :value => value ).to_s.should == "\$myvar"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
75
84
|
describe Puppet::Parser::AST::Regex do
|
76
85
|
before :each do
|
77
86
|
@scope = stub 'scope'
|
@@ -151,6 +151,13 @@ describe Puppet::Parser::AST::Selector do
|
|
151
151
|
@selector.evaluate(@scope)
|
152
152
|
end
|
153
153
|
end
|
154
|
-
|
154
|
+
end
|
155
|
+
describe "when converting to string" do
|
156
|
+
it "should produce a string version of this selector" do
|
157
|
+
values = Puppet::Parser::AST::ASTArray.new :children => [ Puppet::Parser::AST::ResourceParam.new(:param => "type", :value => "value", :add => false) ]
|
158
|
+
param = Puppet::Parser::AST::Variable.new :value => "myvar"
|
159
|
+
selector = Puppet::Parser::AST::Selector.new :param => param, :values => values
|
160
|
+
selector.to_s.should == "$myvar ? { type => value }"
|
161
|
+
end
|
155
162
|
end
|
156
163
|
end
|
data/spec/unit/parser/lexer.rb
CHANGED
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
5
5
|
require 'puppet/parser/lexer'
|
6
6
|
|
7
7
|
# This is a special matcher to match easily lexer output
|
8
|
-
Spec::Matchers.
|
8
|
+
Spec::Matchers.define :be_like do |ary|
|
9
9
|
match do |result|
|
10
10
|
r = true
|
11
11
|
result.zip(ary) do |a,b|
|
@@ -101,6 +101,17 @@ describe Puppet::Parser::Resource do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
+
describe "when refering to a resource with name canonicalization" do
|
105
|
+
before do
|
106
|
+
@arguments = {:type => "file", :title => "/path/", :scope => stub('scope', :source => mock('source'))}
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should canonicalize its own name" do
|
110
|
+
res = Puppet::Parser::Resource.new(@arguments)
|
111
|
+
res.ref.should == "File[/path]"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
104
115
|
describe "when evaluating" do
|
105
116
|
before do
|
106
117
|
@type = Puppet::Parser::Resource
|
@@ -40,10 +40,22 @@ describe Puppet::Parser::Resource::Reference do
|
|
40
40
|
ref.to_s.should == "File[/tmp/yay]"
|
41
41
|
end
|
42
42
|
|
43
|
-
it "should canonize resource
|
43
|
+
it "should canonize resource reference types" do
|
44
44
|
ref = @type.new(:type => "foo::bar", :title => "/tmp/yay")
|
45
45
|
ref.to_s.should == "Foo::Bar[/tmp/yay]"
|
46
46
|
end
|
47
|
+
|
48
|
+
it "should canonize resource reference values" do
|
49
|
+
ref = @type.new(:type => "file", :title => "/tmp/yay/")
|
50
|
+
ref.to_s.should == "File[/tmp/yay]"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should canonize resource reference values without order dependencies" do
|
54
|
+
args = [[:title, "/tmp/yay/"], [:type, "file"]]
|
55
|
+
ref = @type.new(args)
|
56
|
+
ref.to_s.should == "File[/tmp/yay]"
|
57
|
+
end
|
58
|
+
|
47
59
|
end
|
48
60
|
|
49
61
|
describe Puppet::Parser::Resource::Reference, " when modeling defined types" do
|
data/spec/unit/property.rb
CHANGED
@@ -101,6 +101,12 @@ describe Puppet::Property do
|
|
101
101
|
@property.should.must == [:one, :two]
|
102
102
|
end
|
103
103
|
|
104
|
+
it "should munge the canonicalization of the value" do
|
105
|
+
@property.class.to_canonicalize { |x| x.reverse }
|
106
|
+
@property.value = 'data'
|
107
|
+
@property.should.must == 'atad'
|
108
|
+
end
|
109
|
+
|
104
110
|
it "should return any set value" do
|
105
111
|
(@property.value = :one).should == :one
|
106
112
|
end
|
@@ -140,10 +140,12 @@ describe provider_class do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
it "should write the mount to disk when :flush is called" do
|
143
|
+
old_text = @provider_class.target_object(@provider_class.default_target).read
|
144
|
+
|
143
145
|
@mount.flush
|
144
146
|
|
145
147
|
text = @provider_class.target_object(@provider_class.default_target).read
|
146
|
-
text.should == @mount.class.to_line(@mount.property_hash) + "\n"
|
148
|
+
text.should == old_text + @mount.class.to_line(@mount.property_hash) + "\n"
|
147
149
|
end
|
148
150
|
end
|
149
151
|
|
@@ -60,7 +60,7 @@ describe provider_class do
|
|
60
60
|
|
61
61
|
describe "when checking whether it is enabled" do
|
62
62
|
it "should call Kernel.system() with the appropriate parameters" do
|
63
|
-
@provider.expects(:system).with("/usr/sbin/invoke-rc.d", "--query", @resource[:name], "start").once
|
63
|
+
@provider.expects(:system).with("/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start").once
|
64
64
|
@provider.enabled?
|
65
65
|
end
|
66
66
|
|
@@ -33,7 +33,7 @@ describe provider_class do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def genkey(key)
|
36
|
-
@provider.filetype
|
36
|
+
@provider.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam)
|
37
37
|
file = @provider.default_target
|
38
38
|
|
39
39
|
key.flush
|
@@ -78,13 +78,21 @@ describe provider_class do
|
|
78
78
|
|
79
79
|
@provider.parse_options(optionstr).should == options
|
80
80
|
end
|
81
|
+
|
82
|
+
it "should use '' as name for entries that lack a comment" do
|
83
|
+
line = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAut8aOSxenjOqF527dlsdHWV4MNoAsX14l9M297+SQXaQ5Z3BedIxZaoQthkDALlV/25A1COELrg9J2MqJNQc8Xe9XQOIkBQWWinUlD/BXwoOTWEy8C8zSZPHZ3getMMNhGTBO+q/O+qiJx3y5cA4MTbw2zSxukfWC87qWwcZ64UUlegIM056vPsdZWFclS9hsROVEa57YUMrehQ1EGxT4Z5j6zIopufGFiAPjZigq/vqgcAqhAKP6yu4/gwO6S9tatBeEjZ8fafvj1pmvvIplZeMr96gHE7xS3pEEQqnB3nd4RY7AF6j9kFixnsytAUO7STPh/M3pLiVQBN89TvWPQ=="
|
84
|
+
|
85
|
+
@provider.parse(line)[0][:name].should == ""
|
86
|
+
end
|
81
87
|
end
|
82
88
|
|
83
89
|
describe provider_class do
|
84
90
|
before :each do
|
85
91
|
@resource = stub("resource", :name => "foo")
|
86
92
|
@resource.stubs(:[]).returns "foo"
|
93
|
+
|
87
94
|
@provider = provider_class.new(@resource)
|
95
|
+
provider_class.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam)
|
88
96
|
end
|
89
97
|
|
90
98
|
describe "when flushing" do
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
4
|
+
|
5
|
+
provider_class = Puppet::Type.type(:sshkey).provider(:parsed)
|
6
|
+
|
7
|
+
describe provider_class do
|
8
|
+
before do
|
9
|
+
@sshkey_class = Puppet::Type.type(:sshkey)
|
10
|
+
@provider_class = @sshkey_class.provider(:parsed)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should not drop an empty alias" do
|
14
|
+
line = 'test,alias, ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzwHhxXvIrtfIwrudFqc8yQcIfMudrgpnuh1F3AV6d2BrLgu/yQE7W5UyJMUjfj427sQudRwKW45O0Jsnr33F4mUw+GIMlAAmp9g24/OcrTiB8ZUKIjoPy/cO4coxGi8/NECtRzpD/ZUPFh6OEpyOwJPMb7/EC2Az6Otw4StHdXUYw22zHazBcPFnv6zCgPx1hA7QlQDWTu4YcL0WmTYQCtMUb3FUqrcFtzGDD0ytosgwSd+JyN5vj5UwIABjnNOHPZ62EY1OFixnfqX/+dUwrFSs5tPgBF/KkC6R7tmbUfnBON6RrGEmu+ajOTOLy23qUZB4CQ53V7nyAWhzqSK+hw=='
|
15
|
+
parsed = @provider_class.parse_line(line)
|
16
|
+
parsed[:alias].should == ["alias",""]
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/spec/unit/rails.rb
CHANGED
@@ -39,13 +39,24 @@ describe Puppet::Rails, "when initializing any connection" do
|
|
39
39
|
ActiveRecord::Base.stubs(:logger).returns(logger)
|
40
40
|
logger.expects(:level=).with(Logger::DEBUG)
|
41
41
|
|
42
|
+
ActiveRecord::Base.stubs(:allow_concurrency=)
|
42
43
|
ActiveRecord::Base.stubs(:verify_active_connections!)
|
43
44
|
ActiveRecord::Base.stubs(:establish_connection)
|
44
|
-
Puppet::Rails.stubs(:database_arguments)
|
45
|
+
Puppet::Rails.stubs(:database_arguments).returns({})
|
45
46
|
|
46
47
|
Puppet::Rails.connect
|
47
48
|
end
|
48
49
|
|
50
|
+
describe "on ActiveRecord 2.1.x" do
|
51
|
+
confine "ActiveRecord 2.1.x" => (::ActiveRecord::VERSION::MAJOR == 2 and ::ActiveRecord::VERSION::MINOR <= 1)
|
52
|
+
|
53
|
+
it "should set ActiveRecord::Base.allow_concurrency" do
|
54
|
+
ActiveRecord::Base.expects(:allow_concurrency=).with(true)
|
55
|
+
|
56
|
+
Puppet::Rails.connect
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
49
60
|
it "should call ActiveRecord::Base.verify_active_connections!" do
|
50
61
|
ActiveRecord::Base.expects(:verify_active_connections!)
|
51
62
|
|
@@ -53,7 +64,7 @@ describe Puppet::Rails, "when initializing any connection" do
|
|
53
64
|
end
|
54
65
|
|
55
66
|
it "should call ActiveRecord::Base.establish_connection with database_arguments" do
|
56
|
-
Puppet::Rails.expects(:database_arguments)
|
67
|
+
Puppet::Rails.expects(:database_arguments).returns({})
|
57
68
|
ActiveRecord::Base.expects(:establish_connection)
|
58
69
|
|
59
70
|
Puppet::Rails.connect
|
@@ -63,15 +74,15 @@ end
|
|
63
74
|
describe Puppet::Rails, "when initializing a sqlite3 connection" do
|
64
75
|
confine "Cannot test without ActiveRecord" => Puppet.features.rails?
|
65
76
|
|
66
|
-
it "should provide the adapter, log_level, and
|
77
|
+
it "should provide the adapter, log_level, and database arguments" do
|
67
78
|
Puppet.settings.expects(:value).with(:dbadapter).returns("sqlite3")
|
68
79
|
Puppet.settings.expects(:value).with(:rails_loglevel).returns("testlevel")
|
69
80
|
Puppet.settings.expects(:value).with(:dblocation).returns("testlocation")
|
70
81
|
|
71
82
|
Puppet::Rails.database_arguments.should == {
|
72
|
-
:adapter
|
83
|
+
:adapter => "sqlite3",
|
73
84
|
:log_level => "testlevel",
|
74
|
-
:
|
85
|
+
:database => "testlocation"
|
75
86
|
}
|
76
87
|
end
|
77
88
|
end
|
@@ -79,7 +90,7 @@ end
|
|
79
90
|
describe Puppet::Rails, "when initializing a mysql or postgresql connection" do
|
80
91
|
confine "Cannot test without ActiveRecord" => Puppet.features.rails?
|
81
92
|
|
82
|
-
it "should provide the adapter, log_level, and host, username, password, and
|
93
|
+
it "should provide the adapter, log_level, and host, username, password, database, and reconnect arguments" do
|
83
94
|
Puppet.settings.stubs(:value).with(:dbadapter).returns("mysql")
|
84
95
|
Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
|
85
96
|
Puppet.settings.stubs(:value).with(:dbserver).returns("testserver")
|
@@ -94,11 +105,12 @@ describe Puppet::Rails, "when initializing a mysql or postgresql connection" do
|
|
94
105
|
:host => "testserver",
|
95
106
|
:username => "testuser",
|
96
107
|
:password => "testpassword",
|
97
|
-
:database => "testname"
|
108
|
+
:database => "testname",
|
109
|
+
:reconnect => true
|
98
110
|
}
|
99
111
|
end
|
100
112
|
|
101
|
-
it "should provide the adapter, log_level, and host, username, password, database, and
|
113
|
+
it "should provide the adapter, log_level, and host, username, password, database, socket, and reconnect arguments" do
|
102
114
|
Puppet.settings.stubs(:value).with(:dbadapter).returns("mysql")
|
103
115
|
Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
|
104
116
|
Puppet.settings.stubs(:value).with(:dbserver).returns("testserver")
|
@@ -114,7 +126,8 @@ describe Puppet::Rails, "when initializing a mysql or postgresql connection" do
|
|
114
126
|
:username => "testuser",
|
115
127
|
:password => "testpassword",
|
116
128
|
:database => "testname",
|
117
|
-
:socket => "testsocket"
|
129
|
+
:socket => "testsocket",
|
130
|
+
:reconnect => true
|
118
131
|
}
|
119
132
|
end
|
120
133
|
end
|
data/spec/unit/rails/resource.rb
CHANGED
@@ -84,4 +84,24 @@ describe "Puppet::Rails::Resource" do
|
|
84
84
|
@resource.merge_parser_resource(@parser)
|
85
85
|
end
|
86
86
|
end
|
87
|
+
|
88
|
+
describe "merge_parameters" do
|
89
|
+
it "should replace values that have changed" do
|
90
|
+
@resource = Puppet::Rails::Resource.new
|
91
|
+
@resource.params_list = [{"name" => "replace", "value" => 1, "id" => 100 }]
|
92
|
+
|
93
|
+
Puppet::Rails::ParamValue.expects(:delete).with([100])
|
94
|
+
param_values = stub "param_values"
|
95
|
+
param_values.expects(:build).with({:value=>nil, :param_name=>nil, :line=>{"replace"=>2}})
|
96
|
+
@resource.stubs(:param_values).returns(param_values)
|
97
|
+
|
98
|
+
Puppet::Rails::ParamName.stubs(:accumulate_by_name)
|
99
|
+
|
100
|
+
merge_resource = stub "merge_resource"
|
101
|
+
merge_resource.expects(:line).returns({ "replace" => 2 })
|
102
|
+
merge_resource.stubs(:each).yields([["replace", 2]])
|
103
|
+
|
104
|
+
@resource.merge_parameters(merge_resource)
|
105
|
+
end
|
106
|
+
end
|
87
107
|
end
|