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
data/spec/unit/ssl/host.rb
CHANGED
@@ -90,55 +90,6 @@ describe Puppet::SSL::Host do
|
|
90
90
|
Puppet::SSL::Host.localhost.should equal(two)
|
91
91
|
end
|
92
92
|
|
93
|
-
it "should be able to verify its certificate matches its key" do
|
94
|
-
Puppet::SSL::Host.new("foo").should respond_to(:certificate_matches_key?)
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should consider the certificate invalid if it cannot find a key" do
|
98
|
-
host = Puppet::SSL::Host.new("foo")
|
99
|
-
host.expects(:key).returns nil
|
100
|
-
|
101
|
-
host.should_not be_certificate_matches_key
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should consider the certificate invalid if it cannot find a certificate" do
|
105
|
-
host = Puppet::SSL::Host.new("foo")
|
106
|
-
host.expects(:key).returns mock("key")
|
107
|
-
host.expects(:certificate).returns nil
|
108
|
-
|
109
|
-
host.should_not be_certificate_matches_key
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should consider the certificate invalid if the SSL certificate's key verification fails" do
|
113
|
-
host = Puppet::SSL::Host.new("foo")
|
114
|
-
|
115
|
-
key = mock 'key', :content => "private_key"
|
116
|
-
sslcert = mock 'sslcert'
|
117
|
-
certificate = mock 'cert', :content => sslcert
|
118
|
-
|
119
|
-
host.stubs(:key).returns key
|
120
|
-
host.stubs(:certificate).returns certificate
|
121
|
-
|
122
|
-
sslcert.expects(:check_private_key).with("private_key").returns false
|
123
|
-
|
124
|
-
host.should_not be_certificate_matches_key
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should consider the certificate valid if the SSL certificate's key verification succeeds" do
|
128
|
-
host = Puppet::SSL::Host.new("foo")
|
129
|
-
|
130
|
-
key = mock 'key', :content => "private_key"
|
131
|
-
sslcert = mock 'sslcert'
|
132
|
-
certificate = mock 'cert', :content => sslcert
|
133
|
-
|
134
|
-
host.stubs(:key).returns key
|
135
|
-
host.stubs(:certificate).returns certificate
|
136
|
-
|
137
|
-
sslcert.expects(:check_private_key).with("private_key").returns true
|
138
|
-
|
139
|
-
host.should be_certificate_matches_key
|
140
|
-
end
|
141
|
-
|
142
93
|
describe "when specifying the CA location" do
|
143
94
|
before do
|
144
95
|
[Puppet::SSL::Key, Puppet::SSL::Certificate, Puppet::SSL::CertificateRequest, Puppet::SSL::CertificateRevocationList].each do |klass|
|
@@ -408,10 +359,11 @@ describe Puppet::SSL::Host do
|
|
408
359
|
describe "when managing its certificate" do
|
409
360
|
before do
|
410
361
|
@realcert = mock 'certificate'
|
411
|
-
@
|
362
|
+
@realcert.stubs(:check_private_key).with('private key').returns true
|
363
|
+
|
364
|
+
@cert = stub 'cert', :content => @realcert, :expired? => false
|
412
365
|
|
413
|
-
@host.stubs(:key).returns
|
414
|
-
@host.stubs(:certificate_matches_key?).returns true
|
366
|
+
@host.stubs(:key).returns stub("key",:content => 'private key' )
|
415
367
|
end
|
416
368
|
|
417
369
|
it "should find the CA certificate if it does not have a certificate" do
|
@@ -459,12 +411,22 @@ describe Puppet::SSL::Host do
|
|
459
411
|
@host.certificate.should equal(@cert)
|
460
412
|
end
|
461
413
|
|
462
|
-
it "should
|
463
|
-
@
|
414
|
+
it "should immediately expire the cached copy if the found certificate does not match the private key" do
|
415
|
+
@realcert.expects(:check_private_key).with('private key').returns false
|
416
|
+
|
417
|
+
Puppet::SSL::Certificate.stubs(:find).returns @cert
|
418
|
+
Puppet::SSL::Certificate.expects(:expire).with("myname")
|
419
|
+
|
420
|
+
@host.certificate
|
421
|
+
end
|
422
|
+
|
423
|
+
it "should not return a certificate if it does not match the private key" do
|
424
|
+
@realcert.expects(:check_private_key).with('private key').returns false
|
464
425
|
|
465
426
|
Puppet::SSL::Certificate.stubs(:find).returns @cert
|
427
|
+
Puppet::SSL::Certificate.stubs(:expire).with("myname")
|
466
428
|
|
467
|
-
|
429
|
+
@host.certificate.should == nil
|
468
430
|
end
|
469
431
|
|
470
432
|
it "should return any previously found certificate" do
|
@@ -654,14 +616,14 @@ describe Puppet::SSL::Host do
|
|
654
616
|
|
655
617
|
it "should catch and log errors during CSR saving" do
|
656
618
|
@host.expects(:certificate).times(2).returns(nil).then.returns "foo"
|
657
|
-
@host.expects(:generate).
|
619
|
+
@host.expects(:generate).raises(RuntimeError).then.returns nil
|
658
620
|
@host.stubs(:sleep)
|
659
621
|
@host.wait_for_cert(1)
|
660
622
|
end
|
661
623
|
|
662
624
|
it "should sleep and retry after failures saving the CSR if waitforcert is enabled" do
|
663
625
|
@host.expects(:certificate).times(2).returns(nil).then.returns "foo"
|
664
|
-
@host.expects(:generate).
|
626
|
+
@host.expects(:generate).raises(RuntimeError).then.returns nil
|
665
627
|
@host.expects(:sleep).with(1)
|
666
628
|
@host.wait_for_cert(1)
|
667
629
|
end
|
data/spec/unit/transaction.rb
CHANGED
@@ -20,8 +20,8 @@ describe Puppet::Transaction do
|
|
20
20
|
|
21
21
|
describe "when generating resources" do
|
22
22
|
it "should finish all resources" do
|
23
|
-
generator = stub 'generator', :depthfirst? => true
|
24
|
-
resource = stub 'resource'
|
23
|
+
generator = stub 'generator', :depthfirst? => true, :tags => []
|
24
|
+
resource = stub 'resource', :tag => nil
|
25
25
|
|
26
26
|
@catalog = Puppet::Resource::Catalog.new
|
27
27
|
@transaction = Puppet::Transaction.new(@catalog)
|
@@ -36,8 +36,8 @@ describe Puppet::Transaction do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should skip generated resources that conflict with existing resources" do
|
39
|
-
generator = mock 'generator'
|
40
|
-
resource = stub 'resource'
|
39
|
+
generator = mock 'generator', :tags => []
|
40
|
+
resource = stub 'resource', :tag => nil
|
41
41
|
|
42
42
|
@catalog = Puppet::Resource::Catalog.new
|
43
43
|
@transaction = Puppet::Transaction.new(@catalog)
|
@@ -51,6 +51,21 @@ describe Puppet::Transaction do
|
|
51
51
|
|
52
52
|
@transaction.generate_additional_resources(generator, :generate).should be_empty
|
53
53
|
end
|
54
|
+
|
55
|
+
it "should copy all tags to the newly generated resources" do
|
56
|
+
child = stub 'child'
|
57
|
+
generator = stub 'resource', :tags => ["one", "two"]
|
58
|
+
|
59
|
+
@catalog = Puppet::Resource::Catalog.new
|
60
|
+
@transaction = Puppet::Transaction.new(@catalog)
|
61
|
+
|
62
|
+
generator.stubs(:generate).returns [child]
|
63
|
+
@catalog.stubs(:add_resource)
|
64
|
+
|
65
|
+
child.expects(:tag).with("one", "two")
|
66
|
+
|
67
|
+
@transaction.generate_additional_resources(generator, :generate)
|
68
|
+
end
|
54
69
|
end
|
55
70
|
|
56
71
|
describe "when skipping a resource" do
|
@@ -65,6 +80,16 @@ describe Puppet::Transaction do
|
|
65
80
|
@transaction.skip?(@resource).should be_true
|
66
81
|
end
|
67
82
|
|
83
|
+
it "should ask the resource if it's tagged with any of the tags" do
|
84
|
+
tags = ['one', 'two']
|
85
|
+
@transaction.stubs(:ignore_tags?).returns(false)
|
86
|
+
@transaction.stubs(:tags).returns(tags)
|
87
|
+
|
88
|
+
@resource.expects(:tagged?).with(*tags).returns(true)
|
89
|
+
|
90
|
+
@transaction.missing_tags?(@resource).should be_false
|
91
|
+
end
|
92
|
+
|
68
93
|
it "should skip not scheduled resources" do
|
69
94
|
@transaction.stubs(:scheduled?).returns(false)
|
70
95
|
@transaction.skip?(@resource).should be_true
|
@@ -108,4 +133,14 @@ describe Puppet::Transaction, " when determining tags" do
|
|
108
133
|
@transaction.tags = "one::two"
|
109
134
|
@transaction.tags.should == %w{one::two}
|
110
135
|
end
|
136
|
+
|
137
|
+
it "should accept a comma-delimited string" do
|
138
|
+
@transaction.tags = "one, two"
|
139
|
+
@transaction.tags.should == %w{one two}
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should accept an empty string" do
|
143
|
+
@transaction.tags = ""
|
144
|
+
@transaction.tags.should == []
|
145
|
+
end
|
111
146
|
end
|
data/spec/unit/type.rb
CHANGED
@@ -89,6 +89,15 @@ describe Puppet::Type do
|
|
89
89
|
Puppet::Type.type(:mount).new(:name => "foo").version.should == 0
|
90
90
|
end
|
91
91
|
|
92
|
+
it "should provide source_descriptors" do
|
93
|
+
resource = Puppet::Type.type(:mount).new(:name => "foo")
|
94
|
+
catalog = Puppet::Resource::Catalog.new
|
95
|
+
catalog.version = 50
|
96
|
+
catalog.add_resource resource
|
97
|
+
|
98
|
+
resource.source_descriptors.should == {:version=>50, :tags=>["mount", "foo"], :path=>"/Mount[foo]"}
|
99
|
+
end
|
100
|
+
|
92
101
|
describe "when choosing a default provider" do
|
93
102
|
it "should choose the provider with the highest specificity" do
|
94
103
|
# Make a fake type
|
@@ -119,6 +119,15 @@ describe content do
|
|
119
119
|
@content.retrieve.should be_nil
|
120
120
|
end
|
121
121
|
|
122
|
+
it "should not manage content on links" do
|
123
|
+
@content = content.new(:resource => @resource)
|
124
|
+
|
125
|
+
stat = mock 'stat', :ftype => "link"
|
126
|
+
@resource.expects(:stat).returns stat
|
127
|
+
|
128
|
+
@content.retrieve.should be_nil
|
129
|
+
end
|
130
|
+
|
122
131
|
it "should always return the checksum as a string" do
|
123
132
|
@content = content.new(:resource => @resource)
|
124
133
|
@content.stubs(:checksum_type).returns "mtime"
|
@@ -188,6 +197,26 @@ describe content do
|
|
188
197
|
@content.must be_insync("{md5}" + Digest::MD5.hexdigest("some content"))
|
189
198
|
end
|
190
199
|
|
200
|
+
describe "and Puppet[:show_diff] is set" do
|
201
|
+
before do
|
202
|
+
Puppet[:show_diff] = true
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should display a diff if the current contents are different from the desired content" do
|
206
|
+
@content.should = "some content"
|
207
|
+
@content.expects(:string_file_diff).once
|
208
|
+
|
209
|
+
@content.insync?("other content")
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should not display a diff if the sum for the current contents is the same as the sum for the desired content" do
|
213
|
+
@content.should = "some content"
|
214
|
+
@content.expects(:string_file_diff).never
|
215
|
+
|
216
|
+
@content.insync?("{md5}" + Digest::MD5.hexdigest("some content"))
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
191
220
|
describe "and the content is specified via a remote source" do
|
192
221
|
before do
|
193
222
|
@metadata = stub 'metadata'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
|
4
|
+
|
5
|
+
maillist = Puppet::Type.type(:maillist)
|
6
|
+
|
7
|
+
describe maillist do
|
8
|
+
before do
|
9
|
+
@provider_class = Puppet::Type.type(:maillist).provider(:mailman)
|
10
|
+
|
11
|
+
@provider = stub 'provider', :class => @provider_class, :clear => nil
|
12
|
+
@provider.stubs(:respond_to).with(:aliases).returns(true)
|
13
|
+
|
14
|
+
@provider_class.stubs(:new).returns(@provider)
|
15
|
+
|
16
|
+
Puppet::Type.type(:maillist).stubs(:defaultprovider).returns(@provider_class)
|
17
|
+
|
18
|
+
@maillist = Puppet::Type.type(:maillist).new( :name => 'test' )
|
19
|
+
|
20
|
+
@catalog = Puppet::Resource::Catalog.new
|
21
|
+
@maillist.catalog = @catalog
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should generate aliases unless they already exist" do
|
25
|
+
# Mail List aliases are careful not to stomp on managed Mail Alias aliases
|
26
|
+
|
27
|
+
# test1 is an unmanaged alias from /etc/aliases
|
28
|
+
Puppet::Type.type(:mailalias).provider(:aliases).stubs(:target_object).returns( StringIO.new("test1: root\n") )
|
29
|
+
|
30
|
+
# test2 is a managed alias from the manifest
|
31
|
+
dupe = Puppet::Type.type(:mailalias).new( :name => 'test2' )
|
32
|
+
@catalog.add_resource dupe
|
33
|
+
|
34
|
+
@provider.stubs(:aliases).returns({"test1" => 'this will get included', "test2" => 'this will dropped', "test3" => 'this will get included'})
|
35
|
+
|
36
|
+
generated = @maillist.generate
|
37
|
+
generated.map{ |x| x.name }.sort.should == ['test1', 'test3']
|
38
|
+
generated.map{ |x| x.class }.should == [Puppet::Type::Mailalias, Puppet::Type::Mailalias]
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/spec/unit/type/resources.rb
CHANGED
@@ -8,7 +8,7 @@ resources = Puppet::Type.type(:resources)
|
|
8
8
|
describe resources do
|
9
9
|
describe "when initializing" do
|
10
10
|
it "should fail if the specified resource type does not exist" do
|
11
|
-
Puppet::Type.stubs(:type).with
|
11
|
+
Puppet::Type.stubs(:type).with { |x| x.to_s.downcase == "resources"}.returns resources
|
12
12
|
Puppet::Type.expects(:type).with("nosuchtype").returns nil
|
13
13
|
lambda { resources.new :name => "nosuchtype" }.should raise_error(Puppet::Error)
|
14
14
|
end
|
@@ -21,4 +21,69 @@ describe resources do
|
|
21
21
|
resources.new(:name => "file").resource_type.should == Puppet::Type.type(:file)
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
describe "#generate" do
|
26
|
+
before do
|
27
|
+
@host1 = Puppet::Type.type(:host).new(:name => 'localhost', :ip => '127.0.0.1')
|
28
|
+
@catalog = Puppet::Resource::Catalog.new
|
29
|
+
@context = Puppet::Transaction.new(@catalog)
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "when dealing with non-purging resources" do
|
33
|
+
before do
|
34
|
+
@resources = Puppet::Type.type(:resources).new(:name => 'host')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not generate any resource" do
|
38
|
+
@resources.generate.should be_empty
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "when the catalog contains a purging resource" do
|
43
|
+
before do
|
44
|
+
@resources = Puppet::Type.type(:resources).new(:name => 'host', :purge => true)
|
45
|
+
@purgeable_resource = Puppet::Type.type(:host).new(:name => 'localhost', :ip => '127.0.0.1')
|
46
|
+
@catalog.add_resource @resources
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should not generate a duplicate of that resource" do
|
50
|
+
Puppet::Type.type(:host).stubs(:instances).returns [@host1]
|
51
|
+
@catalog.add_resource @host1
|
52
|
+
@resources.generate.collect { |r| r.ref }.should_not include(@host1.ref)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
describe "when generating a purgeable resource" do
|
57
|
+
it "should be included in the generated resources" do
|
58
|
+
Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
|
59
|
+
@resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "when the instance's do not have an ensure property" do
|
64
|
+
it "should not be included in the generated resources" do
|
65
|
+
@no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo')
|
66
|
+
Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]
|
67
|
+
@resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "when the instance's ensure property does not accept absent" do
|
72
|
+
it "should not be included in the generated resources" do
|
73
|
+
@no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar')
|
74
|
+
Puppet::Type.type(:host).stubs(:instances).returns [@no_absent_resource]
|
75
|
+
@resources.generate.collect { |r| r.ref }.should_not include(@no_absent_resource.ref)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "when checking the instance fails" do
|
80
|
+
it "should not be included in the generated resources" do
|
81
|
+
@purgeable_resource = Puppet::Type.type(:host).new(:name => 'foobar')
|
82
|
+
Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
|
83
|
+
@resources.expects(:check).with(@purgeable_resource).returns(false)
|
84
|
+
@resources.generate.collect { |r| r.ref }.should_not include(@purgeable_resource.ref)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
24
89
|
end
|
data/spec/unit/type/tidy.rb
CHANGED
@@ -7,6 +7,10 @@ tidy = Puppet::Type.type(:tidy)
|
|
7
7
|
describe tidy do
|
8
8
|
before do
|
9
9
|
Puppet.settings.stubs(:use)
|
10
|
+
|
11
|
+
# for an unknown reason some of these specs fails when run individually
|
12
|
+
# with a failed expectation on File.lstat in the autoloader.
|
13
|
+
File.stubs(:lstat)
|
10
14
|
end
|
11
15
|
|
12
16
|
it "should use :lstat when stating a file" do
|
@@ -161,7 +165,7 @@ describe tidy do
|
|
161
165
|
Puppet::FileServing::Fileset.stubs(:new).returns @fileset
|
162
166
|
end
|
163
167
|
|
164
|
-
it "should use a Fileset for recursion" do
|
168
|
+
it "should use a Fileset for infinite recursion" do
|
165
169
|
Puppet::FileServing::Fileset.expects(:new).with("/what/ever", :recurse => true).returns @fileset
|
166
170
|
@fileset.expects(:files).returns %w{. one two}
|
167
171
|
@tidy.stubs(:tidy?).returns false
|
@@ -169,6 +173,15 @@ describe tidy do
|
|
169
173
|
@tidy.generate
|
170
174
|
end
|
171
175
|
|
176
|
+
it "should use a Fileset for limited recursion" do
|
177
|
+
@tidy[:recurse] = 42
|
178
|
+
Puppet::FileServing::Fileset.expects(:new).with("/what/ever", :recurse => true, :recurselimit => 42).returns @fileset
|
179
|
+
@fileset.expects(:files).returns %w{. one two}
|
180
|
+
@tidy.stubs(:tidy?).returns false
|
181
|
+
|
182
|
+
@tidy.generate
|
183
|
+
end
|
184
|
+
|
172
185
|
it "should generate a file resource for every file that should be tidied but not for files that should not be tidied" do
|
173
186
|
@fileset.expects(:files).returns %w{. one two}
|
174
187
|
|
data/spec/unit/util/autoload.rb
CHANGED
@@ -111,6 +111,8 @@ describe Puppet::Util::Autoload do
|
|
111
111
|
before do
|
112
112
|
@autoload.stubs(:searchpath).returns %w{/a}
|
113
113
|
Dir.stubs(:glob).returns "/path/to/file.rb"
|
114
|
+
|
115
|
+
@autoload.class.stubs(:loaded?).returns(false)
|
114
116
|
end
|
115
117
|
|
116
118
|
[RuntimeError, LoadError, SyntaxError].each do |error|
|
@@ -8,7 +8,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
8
8
|
require 'puppet/util/ldap/connection'
|
9
9
|
|
10
10
|
# So our mocks and such all work, even when ldap isn't available.
|
11
|
-
unless
|
11
|
+
unless Puppet.features.ldap?
|
12
12
|
class LDAP
|
13
13
|
class Conn
|
14
14
|
def initialize(*args)
|
data/spec/unit/util/log.rb
CHANGED
@@ -157,6 +157,20 @@ describe Puppet::Util::Log do
|
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
+
it "should use the source_descriptors" do
|
161
|
+
source = stub "source"
|
162
|
+
source.stubs(:source_descriptors).returns(:tags => ["tag","tag2"], :path => "path", :version => 100)
|
163
|
+
|
164
|
+
log = Puppet::Util::Log.new(:level => "notice", :message => :foo)
|
165
|
+
log.expects(:tag).with("tag")
|
166
|
+
log.expects(:tag).with("tag2")
|
167
|
+
log.expects(:version=).with(100)
|
168
|
+
|
169
|
+
log.source = source
|
170
|
+
|
171
|
+
log.source.should == "path"
|
172
|
+
end
|
173
|
+
|
160
174
|
it "should copy over any version information" do
|
161
175
|
catalog = Puppet::Resource::Catalog.new
|
162
176
|
catalog.version = 25
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
|
4
|
+
|
5
|
+
require 'puppet/util/monkey_patches'
|
6
|
+
|
7
|
+
describe RDoc do
|
8
|
+
it "should return the call stack if a script is called directly" do
|
9
|
+
stack = [
|
10
|
+
"/usr/lib/ruby/1.8/rdoc/usage.rb:99:in `usage_no_exit'",
|
11
|
+
"/usr/lib/ruby/1.8/rdoc/usage.rb:93:in `usage'",
|
12
|
+
"./puppet/application.rb:295:in `help'",
|
13
|
+
"./puppet/application.rb:207:in `handle_help'",
|
14
|
+
"./puppet/application.rb:141:in `send'",
|
15
|
+
"./puppet/application.rb:141:in `option'",
|
16
|
+
"/usr/lib/ruby/1.8/optparse.rb:1267:in `call'",
|
17
|
+
"/usr/lib/ruby/1.8/optparse.rb:1267:in `parse_in_order'",
|
18
|
+
"/usr/lib/ruby/1.8/optparse.rb:1254:in `catch'",
|
19
|
+
"/usr/lib/ruby/1.8/optparse.rb:1254:in `parse_in_order'",
|
20
|
+
"/usr/lib/ruby/1.8/optparse.rb:1248:in `order!'",
|
21
|
+
"/usr/lib/ruby/1.8/optparse.rb:1339:in `permute!'",
|
22
|
+
"/usr/lib/ruby/1.8/optparse.rb:1360:in `parse!'",
|
23
|
+
"./puppet/application.rb:262:in `parse_options'",
|
24
|
+
"./puppet/application.rb:214:in `run'",
|
25
|
+
"./puppet/application.rb:306:in `exit_on_fail'",
|
26
|
+
"./puppet/application.rb:214:in `run'",
|
27
|
+
"../bin/puppet:71"
|
28
|
+
]
|
29
|
+
|
30
|
+
old_dollar_zero = $0
|
31
|
+
$0 = "../bin/puppet"
|
32
|
+
|
33
|
+
# Mocha explodes if you try to mock :caller directly
|
34
|
+
Kernel.expects( :mock_caller ).returns( stack )
|
35
|
+
Kernel.instance_eval { alias orig_caller caller }
|
36
|
+
Kernel.instance_eval { alias caller mock_caller }
|
37
|
+
|
38
|
+
RDoc.caller.must == stack
|
39
|
+
|
40
|
+
$0 = old_dollar_zero
|
41
|
+
Kernel.instance_eval { alias caller orig_caller }
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return a truncated call stack if a script is called from a rubygems stub" do
|
45
|
+
gem_stack = [
|
46
|
+
"/usr/lib/ruby/1.8/rdoc/usage.rb:99:in `usage_no_exit'",
|
47
|
+
"/usr/lib/ruby/1.8/rdoc/usage.rb:93:in `usage'",
|
48
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:295:in `help'",
|
49
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:207:in `handle_help'",
|
50
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:141:in `send'",
|
51
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:141:in `option'",
|
52
|
+
"/usr/lib/ruby/1.8/optparse.rb:1267:in `call'",
|
53
|
+
"/usr/lib/ruby/1.8/optparse.rb:1267:in `parse_in_order'",
|
54
|
+
"/usr/lib/ruby/1.8/optparse.rb:1254:in `catch'",
|
55
|
+
"/usr/lib/ruby/1.8/optparse.rb:1254:in `parse_in_order'",
|
56
|
+
"/usr/lib/ruby/1.8/optparse.rb:1248:in `order!'",
|
57
|
+
"/usr/lib/ruby/1.8/optparse.rb:1339:in `permute!'",
|
58
|
+
"/usr/lib/ruby/1.8/optparse.rb:1360:in `parse!'",
|
59
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:262:in `parse_options'",
|
60
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:214:in `run'",
|
61
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:306:in `exit_on_fail'",
|
62
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:214:in `run'",
|
63
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/bin/puppet:71",
|
64
|
+
"/usr/bin/puppet:19:in `load'",
|
65
|
+
"/usr/bin/puppet:19"
|
66
|
+
]
|
67
|
+
|
68
|
+
real_stack = [
|
69
|
+
"/usr/lib/ruby/1.8/rdoc/usage.rb:99:in `usage_no_exit'",
|
70
|
+
"/usr/lib/ruby/1.8/rdoc/usage.rb:93:in `usage'",
|
71
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:295:in `help'",
|
72
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:207:in `handle_help'",
|
73
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:141:in `send'",
|
74
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:141:in `option'",
|
75
|
+
"/usr/lib/ruby/1.8/optparse.rb:1267:in `call'",
|
76
|
+
"/usr/lib/ruby/1.8/optparse.rb:1267:in `parse_in_order'",
|
77
|
+
"/usr/lib/ruby/1.8/optparse.rb:1254:in `catch'",
|
78
|
+
"/usr/lib/ruby/1.8/optparse.rb:1254:in `parse_in_order'",
|
79
|
+
"/usr/lib/ruby/1.8/optparse.rb:1248:in `order!'",
|
80
|
+
"/usr/lib/ruby/1.8/optparse.rb:1339:in `permute!'",
|
81
|
+
"/usr/lib/ruby/1.8/optparse.rb:1360:in `parse!'",
|
82
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:262:in `parse_options'",
|
83
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:214:in `run'",
|
84
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:306:in `exit_on_fail'",
|
85
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/lib/puppet/application.rb:214:in `run'",
|
86
|
+
"/usr/lib/ruby/gems/1.8/gems/puppet-0.25.1/bin/puppet:71",
|
87
|
+
]
|
88
|
+
|
89
|
+
old_dollar_zero = $0
|
90
|
+
$0 = '/usr/bin/puppet'
|
91
|
+
|
92
|
+
# Mocha explodes if you try to mock :caller directly
|
93
|
+
Kernel.expects( :mock_caller ).returns( gem_stack )
|
94
|
+
Kernel.instance_eval { alias orig_caller caller }
|
95
|
+
Kernel.instance_eval { alias caller mock_caller }
|
96
|
+
|
97
|
+
RDoc.caller.must == real_stack
|
98
|
+
|
99
|
+
$0 = old_dollar_zero
|
100
|
+
Kernel.instance_eval { alias caller orig_caller }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|