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
@@ -578,7 +578,6 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
578
578
|
@transaction = mock 'transaction'
|
579
579
|
Puppet::Transaction.stubs(:new).returns(@transaction)
|
580
580
|
@transaction.stubs(:evaluate)
|
581
|
-
@transaction.stubs(:cleanup)
|
582
581
|
@transaction.stubs(:addtimes)
|
583
582
|
end
|
584
583
|
|
@@ -595,11 +594,6 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
595
594
|
@catalog.apply
|
596
595
|
end
|
597
596
|
|
598
|
-
it "should clean up the transaction" do
|
599
|
-
@transaction.expects :cleanup
|
600
|
-
@catalog.apply
|
601
|
-
end
|
602
|
-
|
603
597
|
it "should return the transaction" do
|
604
598
|
@catalog.apply.should equal(@transaction)
|
605
599
|
end
|
@@ -624,37 +618,6 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
624
618
|
@catalog.apply(:ignoreschedules => true)
|
625
619
|
end
|
626
620
|
|
627
|
-
it "should remove resources created mid-transaction" do
|
628
|
-
args = {:name => "/yay", :ensure => :file}
|
629
|
-
resource = stub 'file', :ref => "File[/yay]", :catalog= => @catalog, :title => "/yay", :[] => "/yay"
|
630
|
-
@transaction = mock 'transaction'
|
631
|
-
Puppet::Transaction.stubs(:new).returns(@transaction)
|
632
|
-
@transaction.stubs(:evaluate)
|
633
|
-
@transaction.stubs(:cleanup)
|
634
|
-
@transaction.stubs(:addtimes)
|
635
|
-
Puppet::Type.type(:file).expects(:new).with(args).returns(resource)
|
636
|
-
resource.expects :remove
|
637
|
-
@catalog.apply do |trans|
|
638
|
-
@catalog.create_resource :file, args
|
639
|
-
@catalog.resource("File[/yay]").should equal(resource)
|
640
|
-
end
|
641
|
-
@catalog.resource("File[/yay]").should be_nil
|
642
|
-
end
|
643
|
-
|
644
|
-
it "should remove resources added mid-transaction" do
|
645
|
-
@transaction = mock 'transaction'
|
646
|
-
Puppet::Transaction.stubs(:new).returns(@transaction)
|
647
|
-
@transaction.stubs(:evaluate)
|
648
|
-
@transaction.stubs(:cleanup)
|
649
|
-
@transaction.stubs(:addtimes)
|
650
|
-
file = Puppet::Type.type(:file).new(:name => "/yay", :ensure => :file)
|
651
|
-
@catalog.apply do |trans|
|
652
|
-
@catalog.add_resource file
|
653
|
-
@catalog.resource("File[/yay]").should_not be_nil
|
654
|
-
end
|
655
|
-
@catalog.resource("File[/yay]").should be_nil
|
656
|
-
end
|
657
|
-
|
658
621
|
it "should expire cached data in the resources both before and after the transaction" do
|
659
622
|
@catalog.expects(:expire).times(2)
|
660
623
|
@catalog.apply
|
@@ -832,6 +795,8 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
832
795
|
|
833
796
|
describe "when indirecting" do
|
834
797
|
before do
|
798
|
+
@real_indirection = Puppet::Resource::Catalog.indirection
|
799
|
+
|
835
800
|
@indirection = stub 'indirection', :name => :catalog
|
836
801
|
|
837
802
|
Puppet::Util::Cacher.expire
|
@@ -843,12 +808,24 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
843
808
|
Puppet::Resource::Catalog.find(:myconfig)
|
844
809
|
end
|
845
810
|
|
846
|
-
it "should
|
847
|
-
Puppet
|
811
|
+
it "should use the value of the 'catalog_terminus' setting to determine its terminus class" do
|
812
|
+
# Puppet only checks the terminus setting the first time you ask
|
813
|
+
# so this returns the object to the clean state
|
814
|
+
# at the expense of making this test less pure
|
815
|
+
Puppet::Resource::Catalog.indirection.reset_terminus_class
|
816
|
+
|
817
|
+
Puppet.settings[:catalog_terminus] = "rest"
|
818
|
+
Puppet::Resource::Catalog.indirection.terminus_class.should == :rest
|
819
|
+
end
|
820
|
+
|
821
|
+
it "should allow the terminus class to be set manually" do
|
822
|
+
Puppet::Resource::Catalog.indirection.terminus_class = :rest
|
823
|
+
Puppet::Resource::Catalog.indirection.terminus_class.should == :rest
|
848
824
|
end
|
849
825
|
|
850
826
|
after do
|
851
827
|
Puppet::Util::Cacher.expire
|
828
|
+
@real_indirection.reset_terminus_class
|
852
829
|
end
|
853
830
|
end
|
854
831
|
|
data/spec/unit/simple_graph.rb
CHANGED
@@ -372,6 +372,20 @@ describe Puppet::SimpleGraph do
|
|
372
372
|
edges.should be_include(@edges["a/b"])
|
373
373
|
edges.should be_include(@edges["a/c"])
|
374
374
|
end
|
375
|
+
|
376
|
+
describe "from generated resources" do
|
377
|
+
before :each do
|
378
|
+
@topsource = stub 'source'
|
379
|
+
@edges["a/topsource"] = Puppet::Relationship.new(@topsource, "a", {:event => :yay, :callback => :refresh})
|
380
|
+
@graph.add_edge(@edges["a/topsource"])
|
381
|
+
end
|
382
|
+
|
383
|
+
it "should not match with edges pointing back to events sources" do
|
384
|
+
@edges["a/b"].expects(:match?).never
|
385
|
+
@edges["a/topsource"].expects(:match?)
|
386
|
+
@graph.matching_edges([@event], @topsource)
|
387
|
+
end
|
388
|
+
end
|
375
389
|
end
|
376
390
|
|
377
391
|
describe "when determining dependencies" do
|
data/spec/unit/ssl/host.rb
CHANGED
@@ -90,6 +90,55 @@ 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
|
+
|
93
142
|
describe "when specifying the CA location" do
|
94
143
|
before do
|
95
144
|
[Puppet::SSL::Key, Puppet::SSL::Certificate, Puppet::SSL::CertificateRequest, Puppet::SSL::CertificateRevocationList].each do |klass|
|
@@ -359,11 +408,10 @@ describe Puppet::SSL::Host do
|
|
359
408
|
describe "when managing its certificate" do
|
360
409
|
before do
|
361
410
|
@realcert = mock 'certificate'
|
362
|
-
@
|
363
|
-
|
364
|
-
@cert = stub 'cert', :content => @realcert, :expired? => false
|
411
|
+
@cert = stub 'cert', :content => @realcert
|
365
412
|
|
366
|
-
@host.stubs(:key).returns
|
413
|
+
@host.stubs(:key).returns mock("key")
|
414
|
+
@host.stubs(:certificate_matches_key?).returns true
|
367
415
|
end
|
368
416
|
|
369
417
|
it "should find the CA certificate if it does not have a certificate" do
|
@@ -411,22 +459,12 @@ describe Puppet::SSL::Host do
|
|
411
459
|
@host.certificate.should equal(@cert)
|
412
460
|
end
|
413
461
|
|
414
|
-
it "should
|
415
|
-
@
|
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
|
462
|
+
it "should fail if the found certificate does not match the private key" do
|
463
|
+
@host.expects(:certificate_matches_key?).returns false
|
425
464
|
|
426
465
|
Puppet::SSL::Certificate.stubs(:find).returns @cert
|
427
|
-
Puppet::SSL::Certificate.stubs(:expire).with("myname")
|
428
466
|
|
429
|
-
@host.certificate.should
|
467
|
+
lambda { @host.certificate }.should raise_error(Puppet::Error)
|
430
468
|
end
|
431
469
|
|
432
470
|
it "should return any previously found certificate" do
|
data/spec/unit/type/file.rb
CHANGED
@@ -16,6 +16,42 @@ describe Puppet::Type.type(:file) do
|
|
16
16
|
@file.catalog = @catalog
|
17
17
|
end
|
18
18
|
|
19
|
+
describe "#write" do
|
20
|
+
|
21
|
+
it "should propagate failures encountered when renaming the temporary file" do
|
22
|
+
File.stubs(:open)
|
23
|
+
|
24
|
+
File.expects(:rename).raises ArgumentError
|
25
|
+
file = Puppet::Type::File.new(:name => "/my/file", :backup => "puppet")
|
26
|
+
|
27
|
+
lambda { file.write("something", :content) }.should raise_error(Puppet::Error)
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "when validating the checksum" do
|
31
|
+
before { @file.stubs(:validate_checksum?).returns(true) }
|
32
|
+
|
33
|
+
it "should fail if the checksum property and content checksums do not match" do
|
34
|
+
property = stub('checksum_property', :checktype => :md5, :md5 => 'checksum_a', :getsum => 'checksum_b')
|
35
|
+
@file.stubs(:property).with(:checksum).returns(property)
|
36
|
+
|
37
|
+
@file.stubs(:validate_checksum?).returns(true)
|
38
|
+
lambda { @file.write "something", :NOTUSED }.should raise_error(Puppet::Error)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "when not validating the checksum" do
|
43
|
+
before { @file.stubs(:validate_checksum?).returns(false) }
|
44
|
+
|
45
|
+
it "should not fail if the checksum property and content checksums do not match" do
|
46
|
+
property = stub('checksum_property', :checktype => :md5, :md5 => 'checksum_a', :getsum => 'checksum_b')
|
47
|
+
@file.stubs(:property).with(:checksum).returns(property)
|
48
|
+
|
49
|
+
lambda { @file.write "something", :NOTUSED }.should_not raise_error(Puppet::Error)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
19
55
|
it "should have a method for determining if the file is present" do
|
20
56
|
@file.must respond_to(:exist?)
|
21
57
|
end
|
@@ -320,6 +356,13 @@ describe Puppet::Type.type(:file) do
|
|
320
356
|
@file.expects(:newchild).with("my/file").returns "fiebar"
|
321
357
|
@file.recurse_local.should == {"my/file" => "fiebar"}
|
322
358
|
end
|
359
|
+
|
360
|
+
it "should set checksum_type to none if this file checksum is none" do
|
361
|
+
@file[:checksum] = :none
|
362
|
+
Puppet::FileServing::Metadata.expects(:search).with { |path,params| params[:checksum_type] == :none }.returns [@metadata]
|
363
|
+
@file.expects(:newchild).with("my/file").returns "fiebar"
|
364
|
+
@file.recurse_local
|
365
|
+
end
|
323
366
|
end
|
324
367
|
|
325
368
|
it "should have a method for performing link recursion" do
|
@@ -764,15 +807,4 @@ describe Puppet::Type.type(:file) do
|
|
764
807
|
file.finish
|
765
808
|
end
|
766
809
|
end
|
767
|
-
|
768
|
-
describe "when writing the file" do
|
769
|
-
it "should propagate failures encountered when renaming the temporary file" do
|
770
|
-
File.stubs(:open)
|
771
|
-
|
772
|
-
File.expects(:rename).raises ArgumentError
|
773
|
-
file = Puppet::Type::File.new(:name => "/my/file", :backup => "puppet")
|
774
|
-
|
775
|
-
lambda { file.write("something", :content) }.should raise_error(Puppet::Error)
|
776
|
-
end
|
777
|
-
end
|
778
810
|
end
|
@@ -0,0 +1,28 @@
|
|
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
|
+
checksum = Puppet::Type.type(:file).attrclass(:checksum)
|
6
|
+
describe checksum do
|
7
|
+
before do
|
8
|
+
# Wow that's a messy interface to the resource.
|
9
|
+
@resource = stub 'resource', :[] => nil, :[]= => nil, :property => nil, :newattr => nil, :parameter => nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be a subclass of Property" do
|
13
|
+
checksum.superclass.must == Puppet::Property
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have default checksum of :md5" do
|
17
|
+
@checksum = checksum.new(:resource => @resource)
|
18
|
+
@checksum.checktype.should == :md5
|
19
|
+
end
|
20
|
+
|
21
|
+
[:none, nil, ""].each do |ck|
|
22
|
+
it "should use a none checksum for #{ck.inspect}" do
|
23
|
+
@checksum = checksum.new(:resource => @resource)
|
24
|
+
@checksum.should = "none"
|
25
|
+
@checksum.checktype.should == :none
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/unit/type/tidy.rb
CHANGED
@@ -60,6 +60,28 @@ describe tidy do
|
|
60
60
|
lambda { @tidy[:recurse] = "whatever" }.should raise_error
|
61
61
|
end
|
62
62
|
end
|
63
|
+
|
64
|
+
describe "for 'matches'" do
|
65
|
+
before do
|
66
|
+
@tidy = Puppet::Type.type(:tidy).new :path => "/tmp", :age => "100d"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should object if matches is given with recurse is not specified" do
|
70
|
+
lambda { @tidy[:matches] = '*.doh' }.should raise_error
|
71
|
+
end
|
72
|
+
it "should object if matches is given and recurse is 0" do
|
73
|
+
lambda { @tidy[:recurse] = 0; @tidy[:matches] = '*.doh' }.should raise_error
|
74
|
+
end
|
75
|
+
it "should object if matches is given and recurse is false" do
|
76
|
+
lambda { @tidy[:recurse] = false; @tidy[:matches] = '*.doh' }.should raise_error
|
77
|
+
end
|
78
|
+
it "should not object if matches is given and recurse is > 0" do
|
79
|
+
lambda { @tidy[:recurse] = 1; @tidy[:matches] = '*.doh' }.should_not raise_error
|
80
|
+
end
|
81
|
+
it "should not object if matches is given and recurse is true" do
|
82
|
+
lambda { @tidy[:recurse] = true; @tidy[:matches] = '*.doh' }.should_not raise_error
|
83
|
+
end
|
84
|
+
end
|
63
85
|
end
|
64
86
|
|
65
87
|
describe "when matching files by age" do
|
@@ -199,7 +221,7 @@ describe tidy do
|
|
199
221
|
|
200
222
|
describe "and determining whether a file matches provided glob patterns" do
|
201
223
|
before do
|
202
|
-
@tidy = Puppet::Type.type(:tidy).new :path => "/what/ever"
|
224
|
+
@tidy = Puppet::Type.type(:tidy).new :path => "/what/ever", :recurse => 1
|
203
225
|
@tidy[:matches] = %w{*foo* *bar*}
|
204
226
|
|
205
227
|
@stat = mock 'stat'
|
@@ -273,6 +295,12 @@ describe tidy do
|
|
273
295
|
|
274
296
|
@sizer.must be_tidy("/what/ever", @stat)
|
275
297
|
end
|
298
|
+
|
299
|
+
it "should return true if the file is equal to the specified size" do
|
300
|
+
@stat.expects(:size).returns(1024)
|
301
|
+
|
302
|
+
@sizer.must be_tidy("/what/ever", @stat)
|
303
|
+
end
|
276
304
|
end
|
277
305
|
|
278
306
|
describe "and determining whether a file should be tidied" do
|
@@ -310,6 +338,7 @@ describe tidy do
|
|
310
338
|
end
|
311
339
|
|
312
340
|
it "should return false if it does not match any provided globs" do
|
341
|
+
@tidy[:recurse] = 1
|
313
342
|
@tidy[:matches] = "globs"
|
314
343
|
|
315
344
|
matches = @tidy.parameter(:matches)
|
data/spec/unit/util/autoload.rb
CHANGED
@@ -51,8 +51,9 @@ describe Puppet::Util::Autoload do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should include the module directories, the Puppet libdir, and all of the Ruby load directories" do
|
54
|
+
Puppet.stubs(:[]).with(:libdir).returns(%w{/libdir1 /lib/dir/two /third/lib/dir}.join(File::PATH_SEPARATOR))
|
54
55
|
@autoload.expects(:module_directories).returns %w{/one /two}
|
55
|
-
@autoload.search_directories.should ==
|
56
|
+
@autoload.search_directories.should == %w{/one /two /libdir1 /lib/dir/two /third/lib/dir} + $:
|
56
57
|
end
|
57
58
|
|
58
59
|
it "should include in its search path all of the search directories that have a subdirectory matching the autoload path" do
|
data/spec/unit/util/checksums.rb
CHANGED
@@ -14,7 +14,7 @@ describe Puppet::Util::Checksums do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
content_sums = [:md5, :md5lite, :sha1, :sha1lite]
|
17
|
-
file_only = [:ctime, :mtime]
|
17
|
+
file_only = [:ctime, :mtime, :none]
|
18
18
|
|
19
19
|
content_sums.each do |sumtype|
|
20
20
|
it "should be able to calculate %s sums from strings" % sumtype do
|
@@ -104,4 +104,10 @@ describe Puppet::Util::Checksums do
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
|
+
|
108
|
+
describe "when using the none checksum" do
|
109
|
+
it "should return an empty string" do
|
110
|
+
@summer.none_file("/my/file").should == ""
|
111
|
+
end
|
112
|
+
end
|
107
113
|
end
|
data/spec/unit/util/settings.rb
CHANGED
@@ -79,6 +79,7 @@ describe Puppet::Util::Settings do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should support a getopt-specific mechanism for turning booleans off" do
|
82
|
+
@settings[:bool] = true
|
82
83
|
@settings.handlearg("--no-bool", "")
|
83
84
|
@settings[:bool].should == false
|
84
85
|
end
|
@@ -97,20 +98,33 @@ describe Puppet::Util::Settings do
|
|
97
98
|
@settings[:bool].should == true
|
98
99
|
end
|
99
100
|
|
100
|
-
it "should consider a cli setting with an empty string as an argument to be a boolean" do
|
101
|
+
it "should consider a cli setting with an empty string as an argument to be a boolean, if the setting itself is a boolean" do
|
101
102
|
# Turn it off first
|
102
103
|
@settings[:bool] = false
|
103
104
|
@settings.handlearg("--bool", "")
|
104
105
|
@settings[:bool].should == true
|
105
106
|
end
|
106
107
|
|
108
|
+
it "should consider a cli setting with an empty string as an argument to be an empty argument, if the setting itself is not a boolean" do
|
109
|
+
@settings[:myval] = "bob"
|
110
|
+
@settings.handlearg("--myval", "")
|
111
|
+
@settings[:myval].should == ""
|
112
|
+
end
|
113
|
+
|
107
114
|
it "should consider a cli setting with a boolean as an argument to be a boolean" do
|
108
115
|
# Turn it off first
|
109
116
|
@settings[:bool] = false
|
110
|
-
@settings.handlearg("--bool", true)
|
117
|
+
@settings.handlearg("--bool", "true")
|
111
118
|
@settings[:bool].should == true
|
112
119
|
end
|
113
120
|
|
121
|
+
it "should not consider a cli setting of a non boolean with a boolean as an argument to be a boolean" do
|
122
|
+
# Turn it off first
|
123
|
+
@settings[:myval] = "bob"
|
124
|
+
@settings.handlearg("--no-myval", "")
|
125
|
+
@settings[:myval].should == ""
|
126
|
+
end
|
127
|
+
|
114
128
|
it "should clear the cache when setting getopt-specific values" do
|
115
129
|
@settings.setdefaults :mysection, :one => ["whah", "yay"], :two => ["$one yay", "bah"]
|
116
130
|
@settings[:two].should == "whah yay"
|
@@ -1018,4 +1032,27 @@ describe Puppet::Util::Settings do
|
|
1018
1032
|
|
1019
1033
|
it "should cache the result"
|
1020
1034
|
end
|
1035
|
+
|
1036
|
+
describe "#without_noop" do
|
1037
|
+
before do
|
1038
|
+
@settings = Puppet::Util::Settings.new
|
1039
|
+
@settings.setdefaults :main, :noop => [true, ""]
|
1040
|
+
end
|
1041
|
+
|
1042
|
+
it "should set noop to false for the duration of the block" do
|
1043
|
+
@settings.without_noop { @settings.value(:noop, :cli).should be_false }
|
1044
|
+
end
|
1045
|
+
|
1046
|
+
it "should ensure that noop is returned to its previous value" do
|
1047
|
+
@settings.without_noop { raise } rescue nil
|
1048
|
+
@settings.value(:noop, :cli).should be_true
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
it "should work even if no 'noop' setting is available" do
|
1052
|
+
settings = Puppet::Util::Settings.new
|
1053
|
+
stuff = nil
|
1054
|
+
settings.without_noop { stuff = "yay" }
|
1055
|
+
stuff.should == "yay"
|
1056
|
+
end
|
1057
|
+
end
|
1021
1058
|
end
|