puppet 2.7.6 → 2.7.8
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 +168 -0
- data/conf/auth.conf +5 -4
- data/conf/redhat/puppet.spec +16 -1
- data/conf/solaris/pkginfo +2 -2
- data/conf/suse/puppet.spec +9 -3
- data/ext/upload_facts.rb +120 -0
- data/install.rb +11 -16
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +0 -3
- data/lib/puppet/application/apply.rb +0 -3
- data/lib/puppet/application/queue.rb +21 -1
- data/lib/puppet/defaults.rb +6 -4
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/feature/base.rb +2 -1
- data/lib/puppet/file_bucket/dipper.rb +3 -2
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/file_serving/metadata.rb +5 -2
- data/lib/puppet/indirector/facts/inventory_service.rb +20 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
- data/lib/puppet/indirector/report/processor.rb +1 -1
- data/lib/puppet/network/handler/filebucket.rb +2 -0
- data/lib/puppet/network/handler/fileserver.rb +1 -1
- data/lib/puppet/network/handler/master.rb +1 -0
- data/lib/puppet/network/handler/report.rb +2 -0
- data/lib/puppet/network/handler/runner.rb +1 -0
- data/lib/puppet/network/handler/status.rb +2 -0
- data/lib/puppet/network/http/mongrel/rest.rb +8 -1
- data/lib/puppet/network/http_server.rb +3 -0
- data/lib/puppet/network/http_server/mongrel.rb +129 -0
- data/lib/puppet/network/rest_authconfig.rb +12 -4
- data/lib/puppet/parameter.rb +18 -0
- data/lib/puppet/parser/compiler.rb +1 -1
- data/lib/puppet/parser/grammar.ra +1 -1
- data/lib/puppet/parser/parser.rb +360 -350
- data/lib/puppet/property.rb +3 -3
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/exec/windows.rb +6 -7
- data/lib/puppet/provider/file/windows.rb +9 -2
- data/lib/puppet/provider/group/aix.rb +8 -8
- data/lib/puppet/provider/group/groupadd.rb +1 -3
- data/lib/puppet/provider/group/ldap.rb +8 -10
- data/lib/puppet/provider/group/windows_adsi.rb +8 -2
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/macports.rb +3 -3
- data/lib/puppet/provider/package/msi.rb +12 -5
- data/lib/puppet/provider/package/nim.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +3 -3
- data/lib/puppet/provider/package/ports.rb +1 -1
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +560 -0
- data/lib/puppet/provider/service/base.rb +2 -2
- data/lib/puppet/provider/service/bsd.rb +4 -3
- data/lib/puppet/provider/service/daemontools.rb +25 -25
- data/lib/puppet/provider/service/debian.rb +6 -4
- data/lib/puppet/provider/service/freebsd.rb +1 -1
- data/lib/puppet/provider/service/gentoo.rb +4 -3
- data/lib/puppet/provider/service/init.rb +3 -8
- data/lib/puppet/provider/service/launchd.rb +129 -96
- data/lib/puppet/provider/service/redhat.rb +2 -3
- data/lib/puppet/provider/service/runit.rb +20 -20
- data/lib/puppet/provider/service/smf.rb +8 -7
- data/lib/puppet/provider/service/src.rb +5 -6
- data/lib/puppet/provider/service/systemd.rb +1 -1
- data/lib/puppet/provider/service/upstart.rb +3 -5
- data/lib/puppet/provider/service/windows.rb +7 -7
- data/lib/puppet/provider/sshkey/parsed.rb +2 -3
- data/lib/puppet/provider/user/aix.rb +21 -21
- data/lib/puppet/provider/user/hpux.rb +3 -1
- data/lib/puppet/provider/user/ldap.rb +7 -7
- data/lib/puppet/provider/user/user_role_add.rb +10 -6
- data/lib/puppet/provider/user/useradd.rb +3 -1
- data/lib/puppet/provider/user/windows_adsi.rb +4 -3
- data/lib/puppet/rb_tree_map.rb +388 -0
- data/lib/puppet/reference/configuration.rb +7 -7
- data/lib/puppet/reference/indirection.rb +5 -6
- data/lib/puppet/reference/metaparameter.rb +3 -1
- data/lib/puppet/reference/network.rb +8 -8
- data/lib/puppet/reference/providers.rb +17 -21
- data/lib/puppet/reference/type.rb +12 -9
- data/lib/puppet/resource.rb +2 -5
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +70 -0
- data/lib/puppet/ssl/host.rb +6 -0
- data/lib/puppet/transaction.rb +158 -55
- data/lib/puppet/transaction/event_manager.rb +1 -1
- data/lib/puppet/type.rb +60 -30
- data/lib/puppet/type/augeas.rb +83 -49
- data/lib/puppet/type/computer.rb +1 -1
- data/lib/puppet/type/cron.rb +11 -11
- data/lib/puppet/type/exec.rb +28 -21
- data/lib/puppet/type/file.rb +17 -7
- data/lib/puppet/type/file/content.rb +2 -2
- data/lib/puppet/type/file/ensure.rb +15 -12
- data/lib/puppet/type/file/mode.rb +30 -5
- data/lib/puppet/type/file/source.rb +11 -10
- data/lib/puppet/type/file/target.rb +2 -2
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/group.rb +4 -5
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/interface.rb +13 -10
- data/lib/puppet/type/k5login.rb +6 -6
- data/lib/puppet/type/macauthorization.rb +37 -36
- data/lib/puppet/type/maillist.rb +2 -2
- data/lib/puppet/type/mcx.rb +6 -6
- data/lib/puppet/type/mount.rb +3 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +24 -23
- data/lib/puppet/type/router.rb +4 -1
- data/lib/puppet/type/schedule.rb +52 -44
- data/lib/puppet/type/scheduled_task.rb +222 -0
- data/lib/puppet/type/selmodule.rb +10 -6
- data/lib/puppet/type/service.rb +11 -11
- data/lib/puppet/type/ssh_authorized_key.rb +2 -5
- data/lib/puppet/type/sshkey.rb +1 -1
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/tidy.rb +10 -8
- data/lib/puppet/type/user.rb +61 -53
- data/lib/puppet/type/vlan.rb +4 -4
- data/lib/puppet/type/whit.rb +6 -2
- data/lib/puppet/type/yumrepo.rb +33 -31
- data/lib/puppet/type/zfs.rb +34 -32
- data/lib/puppet/type/zone.rb +21 -19
- data/lib/puppet/type/zpool.rb +3 -3
- data/lib/puppet/util.rb +24 -6
- data/lib/puppet/util/adsi.rb +12 -7
- data/lib/puppet/util/checksums.rb +1 -1
- data/lib/puppet/util/diff.rb +1 -1
- data/lib/puppet/util/nagios_maker.rb +2 -2
- data/lib/puppet/util/reference.rb +16 -17
- data/lib/puppet/util/settings/file_setting.rb +14 -2
- data/lib/puppet/util/windows/security.rb +96 -32
- data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
- data/spec/integration/indirector/direct_file_server_spec.rb +9 -15
- data/spec/integration/indirector/file_content/file_server_spec.rb +1 -1
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +4 -0
- data/spec/integration/provider/service/init_spec.rb +8 -2
- data/spec/integration/reference/providers_spec.rb +1 -1
- data/spec/integration/ssl/certificate_request_spec.rb +1 -2
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -2
- data/spec/integration/ssl/host_spec.rb +1 -2
- data/spec/integration/transaction_spec.rb +25 -17
- data/spec/integration/type/exec_spec.rb +77 -0
- data/spec/integration/type/file_spec.rb +322 -2
- data/spec/integration/util/windows/security_spec.rb +393 -230
- data/spec/integration/util_spec.rb +16 -0
- data/spec/lib/puppet_spec/files.rb +3 -7
- data/spec/unit/application/apply_spec.rb +0 -9
- data/spec/unit/application/inspect_spec.rb +1 -0
- data/spec/unit/configurer/downloader_spec.rb +3 -3
- data/spec/unit/face/certificate_spec.rb +6 -2
- data/spec/unit/file_bucket/dipper_spec.rb +67 -10
- data/spec/unit/file_bucket/file_spec.rb +22 -28
- data/spec/unit/file_serving/content_spec.rb +1 -1
- data/spec/unit/file_serving/metadata_spec.rb +30 -3
- data/spec/unit/indirector/facts/inventory_service_spec.rb +22 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +21 -24
- data/spec/unit/indirector/node/store_configs_spec.rb +1 -0
- data/spec/unit/indirector/resource/ral_spec.rb +1 -1
- data/spec/unit/indirector/resource_type/parser_spec.rb +2 -2
- data/spec/unit/indirector/rest_spec.rb +1 -1
- data/spec/unit/network/handler/ca_spec.rb +1 -1
- data/spec/unit/network/http/mongrel/rest_spec.rb +54 -25
- data/spec/unit/parameter_spec.rb +36 -0
- data/spec/unit/parser/parser_spec.rb +4 -0
- data/spec/unit/property_spec.rb +2 -2
- data/spec/unit/provider/exec/windows_spec.rb +2 -8
- data/spec/unit/provider/file/posix_spec.rb +6 -0
- data/spec/unit/provider/file/windows_spec.rb +18 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +22 -6
- data/spec/unit/provider/mount/parsed_spec.rb +1 -1
- data/spec/unit/provider/package/msi_spec.rb +2 -2
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1571 -0
- data/spec/unit/provider/service/launchd_spec.rb +143 -130
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +5 -0
- data/spec/unit/provider/user/user_role_add_spec.rb +39 -9
- data/spec/unit/provider/user/useradd_spec.rb +1 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +8 -1
- data/spec/unit/rb_tree_map_spec.rb +572 -0
- data/spec/unit/resource/catalog_spec.rb +1 -1
- data/spec/unit/simple_graph_spec.rb +9 -9
- data/spec/unit/ssl/host_spec.rb +60 -12
- data/spec/unit/transaction/report_spec.rb +3 -3
- data/spec/unit/transaction_spec.rb +394 -11
- data/spec/unit/type/exec_spec.rb +35 -15
- data/spec/unit/type/file/content_spec.rb +11 -10
- data/spec/unit/type/file/mode_spec.rb +73 -19
- data/spec/unit/type/file/source_spec.rb +1 -1
- data/spec/unit/type/file_spec.rb +15 -0
- data/spec/unit/type/group_spec.rb +1 -1
- data/spec/unit/type/mount_spec.rb +5 -5
- data/spec/unit/type/resources_spec.rb +3 -3
- data/spec/unit/type/scheduled_task_spec.rb +102 -0
- data/spec/unit/type/ssh_authorized_key_spec.rb +2 -3
- data/spec/unit/type/user_spec.rb +2 -1
- data/spec/unit/type_spec.rb +48 -4
- data/spec/unit/util/adsi_spec.rb +18 -7
- data/spec/unit/util/checksums_spec.rb +20 -2
- data/spec/unit/util/execution_stub_spec.rb +10 -5
- data/spec/unit/util/logging_spec.rb +6 -6
- data/spec/unit/util/rdoc/parser_spec.rb +1 -1
- data/spec/unit/util/reference_spec.rb +29 -0
- data/spec/unit/util/settings/file_setting_spec.rb +8 -2
- data/spec/unit/util_spec.rb +115 -0
- data/test/other/transactions.rb +5 -11
- data/test/ral/type/exec.rb +1 -1
- metadata +24 -11
@@ -47,9 +47,8 @@ describe ssh_authorized_key, :unless => Puppet.features.microsoft_windows? do
|
|
47
47
|
proc { @class.new(:name => "username@hostname", :ensure => :present, :user => "nobody") }.should_not raise_error
|
48
48
|
end
|
49
49
|
|
50
|
-
it "should
|
51
|
-
proc { @class.new(:name => "my test", :ensure => :present, :user => "nobody") }.
|
52
|
-
proc { @class.new(:name => "my\ttest", :ensure => :present, :user => "nobody") }.should raise_error(Puppet::Error,/Resourcename must not contain whitespace/)
|
50
|
+
it "should support whitespace" do
|
51
|
+
proc { @class.new(:name => "my test", :ensure => :present, :user => "nobody") }.should_not raise_error
|
53
52
|
end
|
54
53
|
|
55
54
|
end
|
data/spec/unit/type/user_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
user = Puppet::Type.type(:user)
|
5
5
|
|
6
|
-
describe user
|
6
|
+
describe user do
|
7
7
|
before do
|
8
8
|
ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin" unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin")
|
9
9
|
@provider = stub 'provider'
|
@@ -326,6 +326,7 @@ describe user, :fails_on_windows => true do
|
|
326
326
|
|
327
327
|
it "should autorequire roles" do
|
328
328
|
testuser = Puppet::Type.type(:user).new(:name => "testuser")
|
329
|
+
testuser.provider.stubs(:send).with(:roles).returns("")
|
329
330
|
testuser[:roles] = "testrole"
|
330
331
|
|
331
332
|
testrole = Puppet::Type.type(:user).new(:name => "testrole")
|
data/spec/unit/type_spec.rb
CHANGED
@@ -177,6 +177,15 @@ describe Puppet::Type, :fails_on_windows => true do
|
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
180
|
+
it "should have documentation for the 'provider' parameter if there are providers" do
|
181
|
+
@type.provide(:test_provider)
|
182
|
+
@type.paramdoc(:provider).should =~ /`provider_test_type`[\s\r]+resource/
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should not have documentation for the 'provider' parameter if there are no providers" do
|
186
|
+
expect { @type.paramdoc(:provider) }.to raise_error(NoMethodError)
|
187
|
+
end
|
188
|
+
|
180
189
|
it "should create a subclass of Puppet::Provider for the provider" do
|
181
190
|
provider = @type.provide(:test_provider)
|
182
191
|
|
@@ -544,9 +553,44 @@ describe Puppet::Type, :fails_on_windows => true do
|
|
544
553
|
it "should have a 'stage' metaparam" do
|
545
554
|
Puppet::Type.metaparamclass(:stage).should be_instance_of(Class)
|
546
555
|
end
|
556
|
+
|
557
|
+
describe "#suitable?" do
|
558
|
+
let(:type) { Puppet::Type.type(:file) }
|
559
|
+
let(:resource) { type.new :path => tmpfile('suitable') }
|
560
|
+
let(:provider) { resource.provider }
|
561
|
+
|
562
|
+
it "should be suitable if its type doesn't use providers" do
|
563
|
+
type.stubs(:paramclass).with(:provider).returns nil
|
564
|
+
|
565
|
+
resource.should be_suitable
|
566
|
+
end
|
567
|
+
|
568
|
+
it "should be suitable if it has a provider which is suitable" do
|
569
|
+
resource.should be_suitable
|
570
|
+
end
|
571
|
+
|
572
|
+
it "should not be suitable if it has a provider which is not suitable" do
|
573
|
+
provider.class.stubs(:suitable?).returns false
|
574
|
+
|
575
|
+
resource.should_not be_suitable
|
576
|
+
end
|
577
|
+
|
578
|
+
it "should be suitable if it does not have a provider and there is a default provider" do
|
579
|
+
resource.stubs(:provider).returns nil
|
580
|
+
|
581
|
+
resource.should be_suitable
|
582
|
+
end
|
583
|
+
|
584
|
+
it "should not be suitable if it doesn't have a provider and there is not default provider" do
|
585
|
+
resource.stubs(:provider).returns nil
|
586
|
+
type.stubs(:defaultprovider).returns nil
|
587
|
+
|
588
|
+
resource.should_not be_suitable
|
589
|
+
end
|
590
|
+
end
|
547
591
|
end
|
548
592
|
|
549
|
-
describe Puppet::Type::RelationshipMetaparam
|
593
|
+
describe Puppet::Type::RelationshipMetaparam do
|
550
594
|
include PuppetSpec::Files
|
551
595
|
|
552
596
|
it "should be a subclass of Puppet::Parameter" do
|
@@ -557,7 +601,7 @@ describe Puppet::Type::RelationshipMetaparam, :fails_on_windows => true do
|
|
557
601
|
Puppet::Type::RelationshipMetaparam.should respond_to(:subclasses)
|
558
602
|
end
|
559
603
|
|
560
|
-
describe "when munging relationships", :
|
604
|
+
describe "when munging relationships", :fails_on_windows => true do
|
561
605
|
before do
|
562
606
|
@path = make_absolute('/foo')
|
563
607
|
@resource = Puppet::Type.type(:mount).new :name => @path
|
@@ -593,7 +637,7 @@ describe Puppet::Type::RelationshipMetaparam, :fails_on_windows => true do
|
|
593
637
|
end
|
594
638
|
end
|
595
639
|
|
596
|
-
describe Puppet::Type.metaparamclass(:check)
|
640
|
+
describe Puppet::Type.metaparamclass(:check) do
|
597
641
|
include PuppetSpec::Files
|
598
642
|
|
599
643
|
it "should warn and create an instance of ':audit'" do
|
@@ -604,7 +648,7 @@ describe Puppet::Type.metaparamclass(:check), :fails_on_windows => true do
|
|
604
648
|
end
|
605
649
|
end
|
606
650
|
|
607
|
-
describe Puppet::Type.metaparamclass(:audit)
|
651
|
+
describe Puppet::Type.metaparamclass(:audit) do
|
608
652
|
include PuppetSpec::Files
|
609
653
|
|
610
654
|
before do
|
data/spec/unit/util/adsi_spec.rb
CHANGED
@@ -29,17 +29,26 @@ describe Puppet::Util::ADSI do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe ".sid_for_account" do
|
32
|
-
it "should return the
|
33
|
-
|
34
|
-
connection.expects(:execquery).returns(result)
|
32
|
+
it "should return nil if the account does not exist" do
|
33
|
+
connection.expects(:execquery).returns([])
|
35
34
|
|
36
|
-
Puppet::Util::ADSI.sid_for_account('
|
35
|
+
Puppet::Util::ADSI.sid_for_account('foobar').should be_nil
|
37
36
|
end
|
38
37
|
|
39
|
-
it "should return
|
40
|
-
|
38
|
+
it "should return a SID for a passed user or group name" do
|
39
|
+
Puppet::Util::ADSI.expects(:execquery).with(
|
40
|
+
"SELECT Sid from Win32_Account WHERE Name = 'testers' AND LocalAccount = true"
|
41
|
+
).returns([stub('acct_id', :Sid => 'S-1-5-32-547')])
|
41
42
|
|
42
|
-
Puppet::Util::ADSI.sid_for_account('
|
43
|
+
Puppet::Util::ADSI.sid_for_account('testers').should == 'S-1-5-32-547'
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return a SID for a passed fully-qualified user or group name" do
|
47
|
+
Puppet::Util::ADSI.expects(:execquery).with(
|
48
|
+
"SELECT Sid from Win32_Account WHERE Name = 'testers' AND Domain = 'MACHINE' AND LocalAccount = true"
|
49
|
+
).returns([stub('acct_id', :Sid => 'S-1-5-32-547')])
|
50
|
+
|
51
|
+
Puppet::Util::ADSI.sid_for_account('MACHINE\testers').should == 'S-1-5-32-547'
|
43
52
|
end
|
44
53
|
end
|
45
54
|
|
@@ -54,6 +63,7 @@ describe Puppet::Util::ADSI do
|
|
54
63
|
adsi_user = stub('adsi')
|
55
64
|
|
56
65
|
connection.expects(:Create).with('user', username).returns(adsi_user)
|
66
|
+
Puppet::Util::ADSI::Group.expects(:exists?).with(username).returns(false)
|
57
67
|
|
58
68
|
user = Puppet::Util::ADSI::User.create(username)
|
59
69
|
|
@@ -199,6 +209,7 @@ describe Puppet::Util::ADSI do
|
|
199
209
|
adsi_group = stub("adsi")
|
200
210
|
|
201
211
|
connection.expects(:Create).with('group', groupname).returns(adsi_group)
|
212
|
+
Puppet::Util::ADSI::User.expects(:exists?).with(groupname).returns(false)
|
202
213
|
|
203
214
|
group = Puppet::Util::ADSI::Group.create(groupname)
|
204
215
|
|
@@ -4,6 +4,8 @@ require 'spec_helper'
|
|
4
4
|
require 'puppet/util/checksums'
|
5
5
|
|
6
6
|
describe Puppet::Util::Checksums do
|
7
|
+
include PuppetSpec::Files
|
8
|
+
|
7
9
|
before do
|
8
10
|
@summer = Object.new
|
9
11
|
@summer.extend(Puppet::Util::Checksums)
|
@@ -76,7 +78,7 @@ describe Puppet::Util::Checksums do
|
|
76
78
|
#fh.expects(:read).with(512).returns("secondline")
|
77
79
|
#fh.expects(:read).with(512).returns(nil)
|
78
80
|
|
79
|
-
File.expects(:open).with(file, "
|
81
|
+
File.expects(:open).with(file, "rb").yields(fh)
|
80
82
|
|
81
83
|
digest.expects(:<<).with "firstline"
|
82
84
|
digest.expects(:<<).with "secondline"
|
@@ -94,6 +96,7 @@ describe Puppet::Util::Checksums do
|
|
94
96
|
sum.should == digest
|
95
97
|
end.should == :mydigest
|
96
98
|
end
|
99
|
+
|
97
100
|
end
|
98
101
|
end
|
99
102
|
|
@@ -114,7 +117,7 @@ describe Puppet::Util::Checksums do
|
|
114
117
|
fh = mock 'filehandle'
|
115
118
|
fh.expects(:read).with(512).returns('my content')
|
116
119
|
|
117
|
-
File.expects(:open).with(file, "
|
120
|
+
File.expects(:open).with(file, "rb").yields(fh)
|
118
121
|
|
119
122
|
digest.expects(:<<).with "my content"
|
120
123
|
digest.expects(:hexdigest).returns :mydigest
|
@@ -154,4 +157,19 @@ describe Puppet::Util::Checksums do
|
|
154
157
|
@summer.none_stream{ |checksum| checksum << "anything" ; expectation.do_something! }.should == ""
|
155
158
|
end
|
156
159
|
end
|
160
|
+
|
161
|
+
{:md5 => Digest::MD5, :sha1 => Digest::SHA1}.each do |sum, klass|
|
162
|
+
describe "when using #{sum}" do
|
163
|
+
let(:content) { "hello\r\nworld" }
|
164
|
+
let(:path) do
|
165
|
+
path = tmpfile("checksum_#{sum}")
|
166
|
+
File.open(path, 'wb') {|f| f.write(content)}
|
167
|
+
path
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should preserve nl/cr sequences" do
|
171
|
+
@summer.send(sum.to_s + "_file", path).should == klass.hexdigest(content)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
157
175
|
end
|
@@ -16,19 +16,24 @@ describe Puppet::Util::ExecutionStub do
|
|
16
16
|
Puppet::Util::ExecutionStub.current_value.should == nil
|
17
17
|
end
|
18
18
|
|
19
|
-
it "should restore normal execution after 'reset' is called"
|
20
|
-
|
19
|
+
it "should restore normal execution after 'reset' is called" do
|
20
|
+
# Note: "true" exists at different paths in different OSes
|
21
|
+
if Puppet.features.microsoft_windows?
|
22
|
+
true_command = [Puppet::Util.which('cmd.exe').tr('/', '\\'), '/c', 'exit 0']
|
23
|
+
else
|
24
|
+
true_command = [Puppet::Util.which('true')]
|
25
|
+
end
|
21
26
|
stub_call_count = 0
|
22
27
|
Puppet::Util::ExecutionStub.set do |command, options|
|
23
|
-
command.should ==
|
28
|
+
command.should == true_command
|
24
29
|
stub_call_count += 1
|
25
30
|
'stub called'
|
26
31
|
end
|
27
|
-
Puppet::Util.execute(
|
32
|
+
Puppet::Util.execute(true_command).should == 'stub called'
|
28
33
|
stub_call_count.should == 1
|
29
34
|
Puppet::Util::ExecutionStub.reset
|
30
35
|
Puppet::Util::ExecutionStub.current_value.should == nil
|
31
|
-
Puppet::Util.execute(
|
36
|
+
Puppet::Util.execute(true_command).should == ''
|
32
37
|
stub_call_count.should == 1
|
33
38
|
end
|
34
39
|
end
|
@@ -46,18 +46,18 @@ describe Puppet::Util::Logging do
|
|
46
46
|
@logger.notice "foo"
|
47
47
|
end
|
48
48
|
|
49
|
-
it "should use the path of any provided resource type"
|
50
|
-
resource = Puppet::Type.type(:
|
49
|
+
it "should use the path of any provided resource type" do
|
50
|
+
resource = Puppet::Type.type(:host).new :name => "foo"
|
51
51
|
|
52
|
-
resource.expects(:path).returns "/path/to/
|
52
|
+
resource.expects(:path).returns "/path/to/host".to_sym
|
53
53
|
|
54
|
-
Puppet::Util::Log.expects(:create).with { |args| args[:source] == "/path/to/
|
54
|
+
Puppet::Util::Log.expects(:create).with { |args| args[:source] == "/path/to/host" }
|
55
55
|
|
56
56
|
resource.notice "foo"
|
57
57
|
end
|
58
58
|
|
59
|
-
it "should use the path of any provided resource parameter"
|
60
|
-
resource = Puppet::Type.type(:
|
59
|
+
it "should use the path of any provided resource parameter" do
|
60
|
+
resource = Puppet::Type.type(:host).new :name => "foo"
|
61
61
|
|
62
62
|
param = resource.parameter(:name)
|
63
63
|
|
@@ -23,7 +23,7 @@ describe RDoc::Parser, :'fails_on_ruby_1.9.2' => true do
|
|
23
23
|
Puppet::Parser::Parser.stubs(:new).returns(parser)
|
24
24
|
parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new('')).at_least_once
|
25
25
|
parser.expects(:file=).with("module/manifests/init.pp")
|
26
|
-
parser.expects(:file=).with(
|
26
|
+
parser.expects(:file=).with(File.expand_path("/dev/null/manifests/site.pp"))
|
27
27
|
|
28
28
|
@parser.scan
|
29
29
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'puppet/util/reference'
|
4
|
+
|
5
|
+
describe Puppet::Util::Reference do
|
6
|
+
it "should create valid Markdown extension definition lists" do
|
7
|
+
my_fragment = nil
|
8
|
+
Puppet::Util::Reference.newreference :testreference, :doc => "A peer of the type and configuration references, but with no useful information" do
|
9
|
+
my_term = "A term"
|
10
|
+
my_definition = <<-EOT
|
11
|
+
The definition of this term.
|
12
|
+
We should be able to handle multi-line definitions.
|
13
|
+
|
14
|
+
We should be able to handle multi-paragraph definitions.
|
15
|
+
EOT
|
16
|
+
my_fragment = markdown_definitionlist(my_term, my_definition)
|
17
|
+
end
|
18
|
+
Puppet::Util::Reference.reference(:testreference).send(:to_markdown, true)
|
19
|
+
my_fragment.should == <<-EOT
|
20
|
+
A term
|
21
|
+
: The definition of this term.
|
22
|
+
We should be able to handle multi-line definitions.
|
23
|
+
|
24
|
+
We should be able to handle multi-paragraph definitions.
|
25
|
+
|
26
|
+
EOT
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -173,10 +173,16 @@ describe Puppet::Util::Settings::FileSetting do
|
|
173
173
|
@file.to_resource.title.should == path
|
174
174
|
end
|
175
175
|
|
176
|
-
it "should set the mode on the file if a mode is provided" do
|
176
|
+
it "should set the mode on the file if a mode is provided as an octal number" do
|
177
177
|
@file.mode = 0755
|
178
178
|
|
179
|
-
@file.to_resource[:mode].should ==
|
179
|
+
@file.to_resource[:mode].should == '755'
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should set the mode on the file if a mode is provided as a string" do
|
183
|
+
@file.mode = '0755'
|
184
|
+
|
185
|
+
@file.to_resource[:mode].should == '755'
|
180
186
|
end
|
181
187
|
|
182
188
|
it "should not set the mode on a the file if manage_internal_file_permissions is disabled" do
|
data/spec/unit/util_spec.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Puppet::Util do
|
6
|
+
include PuppetSpec::Files
|
7
|
+
|
6
8
|
def process_status(exitstatus)
|
7
9
|
return exitstatus if Puppet.features.microsoft_windows?
|
8
10
|
|
@@ -445,4 +447,117 @@ describe Puppet::Util do
|
|
445
447
|
end
|
446
448
|
end
|
447
449
|
end
|
450
|
+
|
451
|
+
describe "#which" do
|
452
|
+
let(:base) { File.expand_path('/bin') }
|
453
|
+
let(:path) { File.join(base, 'foo') }
|
454
|
+
|
455
|
+
before :each do
|
456
|
+
FileTest.stubs(:file?).returns false
|
457
|
+
FileTest.stubs(:file?).with(path).returns true
|
458
|
+
|
459
|
+
FileTest.stubs(:executable?).returns false
|
460
|
+
FileTest.stubs(:executable?).with(path).returns true
|
461
|
+
end
|
462
|
+
|
463
|
+
it "should accept absolute paths" do
|
464
|
+
Puppet::Util.which(path).should == path
|
465
|
+
end
|
466
|
+
|
467
|
+
it "should return nil if no executable found" do
|
468
|
+
Puppet::Util.which('doesnotexist').should be_nil
|
469
|
+
end
|
470
|
+
|
471
|
+
it "should reject directories" do
|
472
|
+
Puppet::Util.which(base).should be_nil
|
473
|
+
end
|
474
|
+
|
475
|
+
describe "on POSIX systems" do
|
476
|
+
before :each do
|
477
|
+
Puppet.features.stubs(:posix?).returns true
|
478
|
+
Puppet.features.stubs(:microsoft_windows?).returns false
|
479
|
+
end
|
480
|
+
|
481
|
+
it "should walk the search PATH returning the first executable" do
|
482
|
+
ENV.stubs(:[]).with('PATH').returns(File.expand_path('/bin'))
|
483
|
+
|
484
|
+
Puppet::Util.which('foo').should == path
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
describe "on Windows systems" do
|
489
|
+
let(:path) { File.expand_path(File.join(base, 'foo.CMD')) }
|
490
|
+
|
491
|
+
before :each do
|
492
|
+
Puppet.features.stubs(:posix?).returns false
|
493
|
+
Puppet.features.stubs(:microsoft_windows?).returns true
|
494
|
+
end
|
495
|
+
|
496
|
+
describe "when a file extension is specified" do
|
497
|
+
it "should walk each directory in PATH ignoring PATHEXT" do
|
498
|
+
ENV.stubs(:[]).with('PATH').returns(%w[/bar /bin].map{|dir| File.expand_path(dir)}.join(File::PATH_SEPARATOR))
|
499
|
+
|
500
|
+
FileTest.expects(:file?).with(File.join(File.expand_path('/bar'), 'foo.CMD')).returns false
|
501
|
+
|
502
|
+
ENV.expects(:[]).with('PATHEXT').never
|
503
|
+
Puppet::Util.which('foo.CMD').should == path
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
describe "when a file extension is not specified" do
|
508
|
+
it "should walk each extension in PATHEXT until an executable is found" do
|
509
|
+
bar = File.expand_path('/bar')
|
510
|
+
ENV.stubs(:[]).with('PATH').returns("#{bar}#{File::PATH_SEPARATOR}#{base}")
|
511
|
+
ENV.stubs(:[]).with('PATHEXT').returns(".EXE#{File::PATH_SEPARATOR}.CMD")
|
512
|
+
|
513
|
+
exts = sequence('extensions')
|
514
|
+
FileTest.expects(:file?).in_sequence(exts).with(File.join(bar, 'foo.EXE')).returns false
|
515
|
+
FileTest.expects(:file?).in_sequence(exts).with(File.join(bar, 'foo.CMD')).returns false
|
516
|
+
FileTest.expects(:file?).in_sequence(exts).with(File.join(base, 'foo.EXE')).returns false
|
517
|
+
FileTest.expects(:file?).in_sequence(exts).with(path).returns true
|
518
|
+
|
519
|
+
Puppet::Util.which('foo').should == path
|
520
|
+
end
|
521
|
+
|
522
|
+
it "should walk the default extension path if the environment variable is not defined" do
|
523
|
+
ENV.stubs(:[]).with('PATH').returns(base)
|
524
|
+
ENV.stubs(:[]).with('PATHEXT').returns(nil)
|
525
|
+
|
526
|
+
exts = sequence('extensions')
|
527
|
+
%w[.COM .EXE .BAT].each do |ext|
|
528
|
+
FileTest.expects(:file?).in_sequence(exts).with(File.join(base, "foo#{ext}")).returns false
|
529
|
+
end
|
530
|
+
FileTest.expects(:file?).in_sequence(exts).with(path).returns true
|
531
|
+
|
532
|
+
Puppet::Util.which('foo').should == path
|
533
|
+
end
|
534
|
+
|
535
|
+
it "should fall back if no extension matches" do
|
536
|
+
ENV.stubs(:[]).with('PATH').returns(base)
|
537
|
+
ENV.stubs(:[]).with('PATHEXT').returns(".EXE")
|
538
|
+
|
539
|
+
FileTest.stubs(:file?).with(File.join(base, 'foo.EXE')).returns false
|
540
|
+
FileTest.stubs(:file?).with(File.join(base, 'foo')).returns true
|
541
|
+
FileTest.stubs(:executable?).with(File.join(base, 'foo')).returns true
|
542
|
+
|
543
|
+
Puppet::Util.which('foo').should == File.join(base, 'foo')
|
544
|
+
end
|
545
|
+
end
|
546
|
+
end
|
547
|
+
end
|
548
|
+
|
549
|
+
describe "#binread" do
|
550
|
+
let(:contents) { "foo\r\nbar" }
|
551
|
+
|
552
|
+
it "should preserve line endings" do
|
553
|
+
path = tmpfile('util_binread')
|
554
|
+
File.open(path, 'wb') { |f| f.print contents }
|
555
|
+
|
556
|
+
Puppet::Util.binread(path).should == contents
|
557
|
+
end
|
558
|
+
|
559
|
+
it "should raise an error if the file doesn't exist" do
|
560
|
+
expect { Puppet::Util.binread('/path/does/not/exist') }.to raise_error(Errno::ENOENT)
|
561
|
+
end
|
562
|
+
end
|
448
563
|
end
|