puppet 2.7.18 → 2.7.19
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 +82 -0
- data/CONTRIBUTING.md +114 -171
- data/README.md +8 -0
- data/README_DEVELOPER.md +38 -3
- data/Rakefile +19 -3
- data/conf/osx/createpackage.sh +3 -1
- data/conf/redhat/logrotate +1 -1
- data/conf/redhat/puppet.spec +35 -8
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +2 -0
- data/lib/puppet/application/master.rb +2 -0
- data/lib/puppet/configurer.rb +2 -3
- data/lib/puppet/defaults.rb +6 -5
- data/lib/puppet/face/module/install.rb +2 -1
- data/lib/puppet/file_bucket/dipper.rb +1 -1
- data/lib/puppet/indirector/file_content.rb +2 -2
- data/lib/puppet/indirector/file_metadata.rb +2 -2
- data/lib/puppet/indirector/indirection.rb +3 -4
- data/lib/puppet/indirector/rest.rb +12 -6
- data/lib/puppet/interface/action_manager.rb +1 -2
- data/lib/puppet/module_tool/applications/unpacker.rb +22 -3
- data/lib/puppet/network/handler/fileserver.rb +2 -2
- data/lib/puppet/parser/ast/resource.rb +9 -2
- data/lib/puppet/parser/functions/fqdn_rand.rb +2 -1
- data/lib/puppet/parser/functions/md5.rb +2 -2
- data/lib/puppet/parser/functions/sha1.rb +2 -2
- data/lib/puppet/parser/functions/template.rb +0 -2
- data/lib/puppet/parser/type_loader.rb +1 -2
- data/lib/puppet/provider/augeas/augeas.rb +19 -1
- data/lib/puppet/provider/confine.rb +1 -1
- data/lib/puppet/provider/package/msi.rb +97 -51
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +1 -0
- data/lib/puppet/provider/service/gentoo.rb +0 -2
- data/lib/puppet/provider/service/openrc.rb +69 -0
- data/lib/puppet/provider/service/windows.rb +6 -4
- data/lib/puppet/provider/user/aix.rb +8 -4
- data/lib/puppet/provider/user/useradd.rb +6 -0
- data/lib/puppet/rails/benchmark.rb +2 -2
- data/lib/puppet/reports/store.rb +9 -9
- data/lib/puppet/resource/catalog.rb +2 -1
- data/lib/puppet/resource/type_collection.rb +2 -1
- data/lib/puppet/ssl/base.rb +1 -2
- data/lib/puppet/ssl/certificate_authority/interface.rb +1 -0
- data/lib/puppet/test/test_helper.rb +2 -1
- data/lib/puppet/type.rb +1 -1
- data/lib/puppet/type/augeas.rb +1 -1
- data/lib/puppet/type/file.rb +4 -2
- data/lib/puppet/type/scheduled_task.rb +8 -10
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/util.rb +63 -25
- data/lib/puppet/util/autoload.rb +6 -4
- data/lib/puppet/util/checksums.rb +3 -8
- data/lib/puppet/util/diff.rb +2 -1
- data/lib/puppet/util/filetype.rb +1 -3
- data/lib/puppet/util/run_mode.rb +2 -1
- data/lib/puppet/util/suidmanager.rb +1 -1
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/file.rb +27 -0
- data/lib/puppet/util/windows/user.rb +1 -2
- data/man/man8/puppet-agent.8 +4 -0
- data/man/man8/puppet-master.8 +4 -0
- data/man/man8/puppetmasterd.8 +4 -0
- data/spec/fixtures/unit/provider/augeas/augeas/augeas/lenses/test.aug +13 -0
- data/spec/fixtures/unit/provider/augeas/augeas/etc/fstab +10 -0
- data/spec/fixtures/unit/provider/augeas/augeas/etc/hosts +6 -0
- data/spec/fixtures/unit/provider/augeas/augeas/etc/test +3 -0
- data/spec/fixtures/unit/provider/augeas/augeas/test.aug +13 -0
- data/spec/fixtures/unit/provider/service/openrc/rcservice_list +8 -0
- data/spec/fixtures/unit/provider/service/openrc/rcstatus +43 -0
- data/spec/integration/defaults_spec.rb +3 -3
- data/spec/integration/network/server/mongrel_spec.rb +8 -6
- data/spec/integration/parser/parser_spec.rb +1 -1
- data/spec/integration/type/file_spec.rb +49 -12
- data/spec/lib/puppet_spec/database.rb +5 -3
- data/spec/lib/puppet_spec/files.rb +2 -1
- data/spec/monkey_patches/alias_should_to_must.rb +15 -2
- data/spec/shared_behaviours/file_serving_model.rb +9 -6
- data/spec/shared_behaviours/path_parameters.rb +5 -5
- data/spec/shared_behaviours/things_that_declare_options.rb +5 -5
- data/spec/unit/application/facts_spec.rb +1 -1
- data/spec/unit/application_spec.rb +10 -8
- data/spec/unit/configurer_spec.rb +11 -2
- data/spec/unit/face/ca_spec.rb +15 -15
- data/spec/unit/face/help_spec.rb +5 -5
- data/spec/unit/face/module/install_spec.rb +13 -2
- data/spec/unit/face/node_spec.rb +7 -6
- data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -1
- data/spec/unit/indirector/envelope_spec.rb +0 -13
- data/spec/unit/indirector/facts/inventory_service_spec.rb +1 -1
- data/spec/unit/indirector/queue_spec.rb +3 -3
- data/spec/unit/indirector/rest_spec.rb +31 -20
- data/spec/unit/indirector_spec.rb +5 -5
- data/spec/unit/interface/action_builder_spec.rb +3 -2
- data/spec/unit/interface/action_manager_spec.rb +1 -1
- data/spec/unit/interface/action_spec.rb +4 -3
- data/spec/unit/interface/face_collection_spec.rb +1 -1
- data/spec/unit/interface/option_spec.rb +13 -9
- data/spec/unit/interface_spec.rb +5 -5
- data/spec/unit/module_tool/applications/unpacker_spec.rb +61 -0
- data/spec/unit/network/handler/fileserver_spec.rb +3 -3
- data/spec/unit/other/transbucket_spec.rb +6 -9
- data/spec/unit/parser/ast/resource_spec.rb +27 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +12 -12
- data/spec/unit/parser/lexer_spec.rb +5 -5
- data/spec/unit/provider/augeas/augeas_spec.rb +78 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +6 -6
- data/spec/unit/provider/package/freebsd_spec.rb +2 -2
- data/spec/unit/provider/package/msi_spec.rb +181 -114
- data/spec/unit/provider/package/openbsd_spec.rb +1 -0
- data/spec/unit/provider/package/pkgdmg_spec.rb +3 -3
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1 -1
- data/spec/unit/provider/service/openrc_spec.rb +209 -0
- data/spec/unit/provider/service/windows_spec.rb +57 -59
- data/spec/unit/provider/user/useradd_spec.rb +7 -0
- data/spec/unit/reports/store_spec.rb +13 -13
- data/spec/unit/resource/catalog_spec.rb +29 -24
- data/spec/unit/resource_spec.rb +13 -13
- data/spec/unit/simple_graph_spec.rb +12 -12
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +3 -3
- data/spec/unit/ssl/certificate_authority_spec.rb +11 -10
- data/spec/unit/transaction_spec.rb +3 -3
- data/spec/unit/type/cron_spec.rb +171 -171
- data/spec/unit/type/exec_spec.rb +29 -27
- data/spec/unit/type/file_spec.rb +22 -13
- data/spec/unit/type/interface_spec.rb +1 -1
- data/spec/unit/type/scheduled_task_spec.rb +15 -14
- data/spec/unit/type/tidy_spec.rb +2 -2
- data/spec/unit/type/user_spec.rb +15 -15
- data/spec/unit/type/vlan_spec.rb +1 -1
- data/spec/unit/type_spec.rb +22 -25
- data/spec/unit/util/autoload_spec.rb +13 -7
- data/spec/unit/util/backups_spec.rb +36 -67
- data/spec/unit/util/storage_spec.rb +2 -9
- data/spec/unit/util/suidmanager_spec.rb +1 -1
- data/spec/unit/util_spec.rb +20 -28
- data/test/ral/manager/attributes.rb +1 -1
- metadata +1553 -1542
data/spec/unit/type/exec_spec.rb
CHANGED
@@ -59,17 +59,17 @@ describe Puppet::Type.type(:exec) do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should report a failure" do
|
62
|
-
|
63
|
-
|
62
|
+
expect { exec_tester('false', 1).refresh }.
|
63
|
+
to raise_error(Puppet::Error, /^false returned 1 instead of/)
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should not report a failure if the exit status is specified in a returns array" do
|
67
|
-
|
67
|
+
expect { exec_tester("false", 1, :returns => [0, 1]).refresh }.to_not raise_error
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should report a failure if the exit status is not specified in a returns array" do
|
71
|
-
|
72
|
-
|
71
|
+
expect { exec_tester('false', 1, :returns => [0, 100]).refresh }.
|
72
|
+
to raise_error(Puppet::Error, /^false returned 1 instead of/)
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should log the output on success" do
|
@@ -84,8 +84,8 @@ describe Puppet::Type.type(:exec) do
|
|
84
84
|
|
85
85
|
it "should log the output on failure" do
|
86
86
|
output = "output1\noutput2\n"
|
87
|
-
|
88
|
-
|
87
|
+
expect { exec_tester('false', 1, :output => output, :logoutput => true).refresh }.
|
88
|
+
to raise_error(Puppet::Error)
|
89
89
|
|
90
90
|
output.split("\n").each do |line|
|
91
91
|
log = @logs.shift
|
@@ -98,8 +98,8 @@ describe Puppet::Type.type(:exec) do
|
|
98
98
|
describe "when logoutput=>on_failure is set" do
|
99
99
|
it "should log the output on failure" do
|
100
100
|
output = "output1\noutput2\n"
|
101
|
-
|
102
|
-
|
101
|
+
expect { exec_tester('false', 1, :output => output, :logoutput => :on_failure).refresh }.
|
102
|
+
to raise_error(Puppet::Error, /^false returned 1 instead of/)
|
103
103
|
|
104
104
|
output.split("\n").each do |line|
|
105
105
|
log = @logs.shift
|
@@ -111,10 +111,10 @@ describe Puppet::Type.type(:exec) do
|
|
111
111
|
it "should log the output on failure when returns is specified as an array" do
|
112
112
|
output = "output1\noutput2\n"
|
113
113
|
|
114
|
-
|
114
|
+
expect {
|
115
115
|
exec_tester('false', 1, :output => output, :returns => [0, 100],
|
116
116
|
:logoutput => :on_failure).refresh
|
117
|
-
}.
|
117
|
+
}.to raise_error(Puppet::Error, /^false returned 1 instead of/)
|
118
118
|
|
119
119
|
output.split("\n").each do |line|
|
120
120
|
log = @logs.shift
|
@@ -138,7 +138,7 @@ describe Puppet::Type.type(:exec) do
|
|
138
138
|
it "should repeat the command attempt 'tries' times on failure and produce an error" do
|
139
139
|
tries = 5
|
140
140
|
resource = exec_tester("false", 1, :tries => tries, :try_sleep => 0)
|
141
|
-
|
141
|
+
expect { resource.refresh }.to raise_error(Puppet::Error)
|
142
142
|
end
|
143
143
|
end
|
144
144
|
end
|
@@ -190,8 +190,9 @@ describe Puppet::Type.type(:exec) do
|
|
190
190
|
describe "on POSIX systems", :as_platform => :posix do
|
191
191
|
it "should fail if we are not root" do
|
192
192
|
Puppet.features.stubs(:root?).returns(false)
|
193
|
-
expect {
|
194
|
-
|
193
|
+
expect {
|
194
|
+
Puppet::Type.type(:exec).new(:name => '/bin/true whatever', :user => 'input')
|
195
|
+
}.to raise_error Puppet::Error, /Parameter user failed/
|
195
196
|
end
|
196
197
|
|
197
198
|
['one', 2, 'root', 4294967295, 4294967296].each do |value|
|
@@ -209,8 +210,9 @@ describe Puppet::Type.type(:exec) do
|
|
209
210
|
end
|
210
211
|
|
211
212
|
it "should reject user parameter" do
|
212
|
-
expect {
|
213
|
-
|
213
|
+
expect {
|
214
|
+
Puppet::Type.type(:exec).new(:name => 'c:\windows\notepad.exe', :user => 'input')
|
215
|
+
}.to raise_error Puppet::Error, /Unable to execute commands as other users on Windows/
|
214
216
|
end
|
215
217
|
end
|
216
218
|
end
|
@@ -267,12 +269,12 @@ describe Puppet::Type.type(:exec) do
|
|
267
269
|
end
|
268
270
|
|
269
271
|
it "should work if the provider calls the command valid" do
|
270
|
-
expect { test(command, true) }.
|
272
|
+
expect { test(command, true) }.to_not raise_error
|
271
273
|
end
|
272
274
|
|
273
275
|
it "should fail if the provider calls the command invalid" do
|
274
276
|
expect { test(command, false) }.
|
275
|
-
|
277
|
+
to raise_error Puppet::Error, /Parameter #{@param} failed: from a stub/
|
276
278
|
end
|
277
279
|
end
|
278
280
|
end
|
@@ -335,7 +337,7 @@ describe Puppet::Type.type(:exec) do
|
|
335
337
|
}.each do |name, data|
|
336
338
|
it "should reject #{name} without assignment" do
|
337
339
|
expect { @exec[:environment] = data }.
|
338
|
-
|
340
|
+
to raise_error Puppet::Error, /Invalid environment setting/
|
339
341
|
end
|
340
342
|
end
|
341
343
|
end
|
@@ -356,12 +358,12 @@ describe Puppet::Type.type(:exec) do
|
|
356
358
|
['1/2', '', 'foo', '5foo'].each do |invalid|
|
357
359
|
it "should reject '#{invalid}' as invalid" do
|
358
360
|
expect { @exec[:timeout] = invalid }.
|
359
|
-
|
361
|
+
to raise_error Puppet::Error, /The timeout must be a number/
|
360
362
|
end
|
361
363
|
|
362
364
|
it "should reject '#{invalid}' in an array as invalid" do
|
363
365
|
expect { @exec[:timeout] = [invalid] }.
|
364
|
-
|
366
|
+
to raise_error Puppet::Error, /The timeout must be a number/
|
365
367
|
end
|
366
368
|
end
|
367
369
|
|
@@ -376,7 +378,7 @@ describe Puppet::Type.type(:exec) do
|
|
376
378
|
FileTest.stubs(:executable?).with(File.expand_path('/bin/sleep')).returns(true)
|
377
379
|
sleep_exec = Puppet::Type.type(:exec).new(:name => 'sleep 1', :path => [File.expand_path('/bin')], :timeout => '0.2')
|
378
380
|
|
379
|
-
|
381
|
+
expect { sleep_exec.refresh }.to raise_error Puppet::Error, "Command exceeded timeout"
|
380
382
|
end
|
381
383
|
|
382
384
|
it "should convert timeout to a float" do
|
@@ -413,14 +415,14 @@ describe Puppet::Type.type(:exec) do
|
|
413
415
|
[-3.5, -1, 0, 0.2, '1/2', '1_000_000', '+12', '', 'foo'].each do |invalid|
|
414
416
|
it "should reject '#{invalid}' as invalid" do
|
415
417
|
expect { @exec[:tries] = invalid }.
|
416
|
-
|
418
|
+
to raise_error Puppet::Error, /Tries must be an integer/
|
417
419
|
end
|
418
420
|
|
419
421
|
if "REVISIT: too much test log spam" == "a good thing" then
|
420
422
|
it "should reject '#{invalid}' in an array as invalid" do
|
421
423
|
pending "inconsistent, but this is not supporting arrays, unlike timeout"
|
422
424
|
expect { @exec[:tries] = [invalid] }.
|
423
|
-
|
425
|
+
to raise_error Puppet::Error, /Tries must be an integer/
|
424
426
|
end
|
425
427
|
end
|
426
428
|
end
|
@@ -452,14 +454,14 @@ describe Puppet::Type.type(:exec) do
|
|
452
454
|
}.each do |invalid, error|
|
453
455
|
it "should reject '#{invalid}' as invalid" do
|
454
456
|
expect { @exec[:try_sleep] = invalid }.
|
455
|
-
|
457
|
+
to raise_error Puppet::Error, /try_sleep #{error}/
|
456
458
|
end
|
457
459
|
|
458
460
|
if "REVISIT: too much test log spam" == "a good thing" then
|
459
461
|
it "should reject '#{invalid}' in an array as invalid" do
|
460
462
|
pending "inconsistent, but this is not supporting arrays, unlike timeout"
|
461
463
|
expect { @exec[:try_sleep] = [invalid] }.
|
462
|
-
|
464
|
+
to raise_error Puppet::Error, /try_sleep #{error}/
|
463
465
|
end
|
464
466
|
end
|
465
467
|
end
|
@@ -476,7 +478,7 @@ describe Puppet::Type.type(:exec) do
|
|
476
478
|
[1, 0, "1", "0", "yes", "y", "no", "n"].each do |value|
|
477
479
|
it "should reject '#{value}'" do
|
478
480
|
expect { @exec[:refreshonly] = value }.
|
479
|
-
|
481
|
+
to raise_error(Puppet::Error,
|
480
482
|
/Invalid value #{value.inspect}\. Valid values are true, false/
|
481
483
|
)
|
482
484
|
end
|
data/spec/unit/type/file_spec.rb
CHANGED
@@ -42,7 +42,7 @@ describe Puppet::Type.type(:file) do
|
|
42
42
|
# REVISIT: This should be wrong, later. See the next test.
|
43
43
|
# --daniel 2011-01-31
|
44
44
|
file[:path].should == '/tmp/xxx'
|
45
|
-
}.
|
45
|
+
}.to_not raise_error
|
46
46
|
end
|
47
47
|
|
48
48
|
# REVISIT: This is pending, because I don't want to try and audit the
|
@@ -76,7 +76,7 @@ describe Puppet::Type.type(:file) do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should not accept a drive letter without a slash", :'fails_on_ruby_1.9.2' => true do
|
79
|
-
|
79
|
+
expect { file[:path] = "X:" }.to raise_error(/File paths must be fully qualified/)
|
80
80
|
end
|
81
81
|
|
82
82
|
describe "when using UNC filenames", :if => Puppet.features.microsoft_windows?, :'fails_on_ruby_1.9.2' => true do
|
@@ -433,7 +433,7 @@ describe Puppet::Type.type(:file) do
|
|
433
433
|
|
434
434
|
it "should set a desired 'ensure' value if none is set and 'target' is set" do
|
435
435
|
file = described_class.new(:path => path, :target => File.expand_path(__FILE__))
|
436
|
-
file[:ensure].should == :
|
436
|
+
file[:ensure].should == :link
|
437
437
|
end
|
438
438
|
end
|
439
439
|
|
@@ -465,7 +465,7 @@ describe Puppet::Type.type(:file) do
|
|
465
465
|
it "should create a new resource relative to the parent" do
|
466
466
|
child = file.newchild('bar')
|
467
467
|
|
468
|
-
child.
|
468
|
+
child.must be_a(described_class)
|
469
469
|
child[:path].should == File.join(file[:path], 'bar')
|
470
470
|
end
|
471
471
|
|
@@ -1112,6 +1112,15 @@ describe Puppet::Type.type(:file) do
|
|
1112
1112
|
File.chmod(0777, dir)
|
1113
1113
|
end
|
1114
1114
|
|
1115
|
+
it "should return nil if parts of path are no directories" do
|
1116
|
+
regular_file = tmpfile('ENOTDIR_test')
|
1117
|
+
FileUtils.touch(regular_file)
|
1118
|
+
impossible_child = File.join(regular_file, 'some_file')
|
1119
|
+
|
1120
|
+
file[:path] = impossible_child
|
1121
|
+
file.stat.should be_nil
|
1122
|
+
end
|
1123
|
+
|
1115
1124
|
it "should return the stat instance" do
|
1116
1125
|
file.stat.should be_a(File::Stat)
|
1117
1126
|
end
|
@@ -1133,7 +1142,7 @@ describe Puppet::Type.type(:file) do
|
|
1133
1142
|
property = stub('content_property', :actual_content => "something", :length => "something".length)
|
1134
1143
|
file.stubs(:property).with(:content).returns(property)
|
1135
1144
|
|
1136
|
-
|
1145
|
+
expect { file.write(:content) }.to raise_error(Puppet::Error)
|
1137
1146
|
end
|
1138
1147
|
|
1139
1148
|
it "should delegate writing to the content property" do
|
@@ -1161,7 +1170,7 @@ describe Puppet::Type.type(:file) do
|
|
1161
1170
|
property = stub('content_property', :actual_content => "something", :length => "something".length, :write => 'checksum_a')
|
1162
1171
|
file.stubs(:property).with(:content).returns(property)
|
1163
1172
|
|
1164
|
-
|
1173
|
+
expect { file.write :NOTUSED }.to raise_error(Puppet::Error)
|
1165
1174
|
end
|
1166
1175
|
end
|
1167
1176
|
|
@@ -1175,7 +1184,7 @@ describe Puppet::Type.type(:file) do
|
|
1175
1184
|
property = stub('content_property', :actual_content => "something", :length => "something".length, :write => 'checksum_a')
|
1176
1185
|
file.stubs(:property).with(:content).returns(property)
|
1177
1186
|
|
1178
|
-
|
1187
|
+
expect { file.write :NOTUSED }.to_not raise_error(Puppet::Error)
|
1179
1188
|
end
|
1180
1189
|
end
|
1181
1190
|
end
|
@@ -1260,7 +1269,7 @@ describe Puppet::Type.type(:file) do
|
|
1260
1269
|
describe "target" do
|
1261
1270
|
it "should require file resource when specified with the target property" do
|
1262
1271
|
file = described_class.new(:path => File.expand_path("/foo"), :ensure => :directory)
|
1263
|
-
link = described_class.new(:path => File.expand_path("/bar"), :ensure => :
|
1272
|
+
link = described_class.new(:path => File.expand_path("/bar"), :ensure => :link, :target => File.expand_path("/foo"))
|
1264
1273
|
catalog.add_resource file
|
1265
1274
|
catalog.add_resource link
|
1266
1275
|
reqs = link.autorequire
|
@@ -1281,7 +1290,7 @@ describe Puppet::Type.type(:file) do
|
|
1281
1290
|
end
|
1282
1291
|
|
1283
1292
|
it "should not require target if target is not managed" do
|
1284
|
-
link = described_class.new(:path => File.expand_path('/foo'), :ensure => :
|
1293
|
+
link = described_class.new(:path => File.expand_path('/foo'), :ensure => :link, :target => '/bar')
|
1285
1294
|
catalog.add_resource link
|
1286
1295
|
link.autorequire.size.should == 0
|
1287
1296
|
end
|
@@ -1420,7 +1429,7 @@ describe Puppet::Type.type(:file) do
|
|
1420
1429
|
|
1421
1430
|
it 'should validate' do
|
1422
1431
|
|
1423
|
-
|
1432
|
+
expect { file.validate }.to_not raise_error
|
1424
1433
|
end
|
1425
1434
|
end
|
1426
1435
|
end
|
@@ -1431,7 +1440,7 @@ describe Puppet::Type.type(:file) do
|
|
1431
1440
|
end
|
1432
1441
|
|
1433
1442
|
it 'should raise an exception when validating' do
|
1434
|
-
|
1443
|
+
expect { file.validate }.to raise_error(/You cannot specify source when using checksum 'none'/)
|
1435
1444
|
end
|
1436
1445
|
end
|
1437
1446
|
end
|
@@ -1448,7 +1457,7 @@ describe Puppet::Type.type(:file) do
|
|
1448
1457
|
end
|
1449
1458
|
|
1450
1459
|
it 'should validate' do
|
1451
|
-
|
1460
|
+
expect { file.validate }.to_not raise_error
|
1452
1461
|
end
|
1453
1462
|
end
|
1454
1463
|
end
|
@@ -1458,7 +1467,7 @@ describe Puppet::Type.type(:file) do
|
|
1458
1467
|
it 'should raise an exception when validating' do
|
1459
1468
|
file[:checksum] = checksum_type
|
1460
1469
|
|
1461
|
-
|
1470
|
+
expect { file.validate }.to raise_error(/You cannot specify content when using checksum '#{checksum_type}'/)
|
1462
1471
|
end
|
1463
1472
|
end
|
1464
1473
|
end
|
@@ -16,7 +16,7 @@ describe Puppet::Type.type(:interface) do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should be applied on device" do
|
19
|
-
Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1").
|
19
|
+
Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1").must be_appliable_to_device
|
20
20
|
end
|
21
21
|
|
22
22
|
[:description, :speed, :duplex, :native_vlan, :encapsulation, :mode, :allowed_trunk_vlans, :etherchannel, :ipaddress].each do |p|
|
@@ -15,6 +15,20 @@ describe Puppet::Type.type(:scheduled_task), :if => Puppet.features.microsoft_wi
|
|
15
15
|
described_class.new(:name => 'Test Task', :command => 'C:\Windows\System32\notepad.exe')[:command].should == 'C:\Windows\System32\notepad.exe'
|
16
16
|
end
|
17
17
|
|
18
|
+
it 'should convert forward slashes to backslashes' do
|
19
|
+
described_class.new(
|
20
|
+
:name => 'Test Task',
|
21
|
+
:command => 'C:/Windows/System32/notepad.exe'
|
22
|
+
)[:command].should == 'C:\Windows\System32\notepad.exe'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should normalize backslashes' do
|
26
|
+
described_class.new(
|
27
|
+
:name => 'Test Task',
|
28
|
+
:command => 'C:\Windows\\System32\\\\notepad.exe'
|
29
|
+
)[:command].should == 'C:\Windows\System32\notepad.exe'
|
30
|
+
end
|
31
|
+
|
18
32
|
it 'should fail if the path to the command is not absolute' do
|
19
33
|
expect {
|
20
34
|
described_class.new(:name => 'Test Task', :command => 'notepad.exe')
|
@@ -26,25 +40,12 @@ describe Puppet::Type.type(:scheduled_task), :if => Puppet.features.microsoft_wi
|
|
26
40
|
end
|
27
41
|
|
28
42
|
describe 'when setting the command arguments' do
|
29
|
-
it 'should fail if provided an array' do
|
30
|
-
expect {
|
31
|
-
described_class.new(
|
32
|
-
:name => 'Test Task',
|
33
|
-
:command => 'C:\Windows\System32\notepad.exe',
|
34
|
-
:arguments => ['/a', '/b', '/c']
|
35
|
-
)
|
36
|
-
}.to raise_error(
|
37
|
-
Puppet::Error,
|
38
|
-
/Parameter arguments failed: Must be specified as a single string/
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
43
|
it 'should accept a string' do
|
43
44
|
described_class.new(
|
44
45
|
:name => 'Test Task',
|
45
46
|
:command => 'C:\Windows\System32\notepad.exe',
|
46
47
|
:arguments => '/a /b /c'
|
47
|
-
)[:arguments].should ==
|
48
|
+
)[:arguments].should == '/a /b /c'
|
48
49
|
end
|
49
50
|
|
50
51
|
it 'should allow not specifying any command arguments' do
|
data/spec/unit/type/tidy_spec.rb
CHANGED
@@ -372,7 +372,7 @@ describe tidy do
|
|
372
372
|
|
373
373
|
@tidy.parameter(:size).stubs(:tidy?).returns true
|
374
374
|
@tidy.parameter(:age).stubs(:tidy?).returns false
|
375
|
-
@tidy.
|
375
|
+
@tidy.must be_tidy(@basepath)
|
376
376
|
end
|
377
377
|
|
378
378
|
it "should tidy a file if age and size are set but only age matches" do
|
@@ -381,7 +381,7 @@ describe tidy do
|
|
381
381
|
|
382
382
|
@tidy.parameter(:size).stubs(:tidy?).returns false
|
383
383
|
@tidy.parameter(:age).stubs(:tidy?).returns true
|
384
|
-
@tidy.
|
384
|
+
@tidy.must be_tidy(@basepath)
|
385
385
|
end
|
386
386
|
|
387
387
|
it "should tidy all files if neither age nor size is set" do
|
data/spec/unit/type/user_spec.rb
CHANGED
@@ -111,11 +111,11 @@ describe Puppet::Type.type(:user) do
|
|
111
111
|
|
112
112
|
describe "when managing the ensure property" do
|
113
113
|
it "should support a :present value" do
|
114
|
-
|
114
|
+
expect { described_class.new(:name => 'foo', :ensure => :present) }.to_not raise_error
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should support an :absent value" do
|
118
|
-
|
118
|
+
expect { described_class.new(:name => 'foo', :ensure => :absent) }.to_not raise_error
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should call :create on the provider when asked to sync to the :present state" do
|
@@ -212,20 +212,20 @@ describe Puppet::Type.type(:user) do
|
|
212
212
|
|
213
213
|
describe "when managing groups" do
|
214
214
|
it "should support a singe group" do
|
215
|
-
|
215
|
+
expect { described_class.new(:name => 'foo', :groups => 'bar') }.to_not raise_error
|
216
216
|
end
|
217
217
|
|
218
218
|
it "should support multiple groups as an array" do
|
219
|
-
|
220
|
-
|
219
|
+
expect { described_class.new(:name => 'foo', :groups => [ 'bar' ]) }.to_not raise_error
|
220
|
+
expect { described_class.new(:name => 'foo', :groups => [ 'bar', 'baz' ]) }.to_not raise_error
|
221
221
|
end
|
222
222
|
|
223
223
|
it "should not support a comma separated list" do
|
224
|
-
|
224
|
+
expect { described_class.new(:name => 'foo', :groups => 'bar,baz') }.to raise_error(Puppet::Error, /Group names must be provided as an array/)
|
225
225
|
end
|
226
226
|
|
227
227
|
it "should not support an empty string" do
|
228
|
-
|
228
|
+
expect { described_class.new(:name => 'foo', :groups => '') }.to raise_error(Puppet::Error, /Group names must not be empty/)
|
229
229
|
end
|
230
230
|
|
231
231
|
describe "when testing is in sync" do
|
@@ -262,27 +262,27 @@ describe Puppet::Type.type(:user) do
|
|
262
262
|
|
263
263
|
describe "when managing expiry" do
|
264
264
|
it "should fail if given an invalid date" do
|
265
|
-
|
265
|
+
expect { described_class.new(:name => 'foo', :expiry => "200-20-20") }.to raise_error(Puppet::Error, /Expiry dates must be YYYY-MM-DD/)
|
266
266
|
end
|
267
267
|
end
|
268
268
|
|
269
269
|
describe "when managing minimum password age" do
|
270
270
|
it "should accept a negative minimum age" do
|
271
|
-
expect { described_class.new(:name => 'foo', :password_min_age => '-1') }.
|
271
|
+
expect { described_class.new(:name => 'foo', :password_min_age => '-1') }.to_not raise_error
|
272
272
|
end
|
273
273
|
|
274
274
|
it "should fail with an empty minimum age" do
|
275
|
-
expect { described_class.new(:name => 'foo', :password_min_age => '') }.
|
275
|
+
expect { described_class.new(:name => 'foo', :password_min_age => '') }.to raise_error(Puppet::Error, /minimum age must be provided as a number/)
|
276
276
|
end
|
277
277
|
end
|
278
278
|
|
279
279
|
describe "when managing maximum password age" do
|
280
280
|
it "should accept a negative maximum age" do
|
281
|
-
expect { described_class.new(:name => 'foo', :password_max_age => '-1') }.
|
281
|
+
expect { described_class.new(:name => 'foo', :password_max_age => '-1') }.to_not raise_error
|
282
282
|
end
|
283
283
|
|
284
284
|
it "should fail with an empty maximum age" do
|
285
|
-
expect { described_class.new(:name => 'foo', :password_max_age => '') }.
|
285
|
+
expect { described_class.new(:name => 'foo', :password_max_age => '') }.to raise_error(Puppet::Error, /maximum age must be provided as a number/)
|
286
286
|
end
|
287
287
|
end
|
288
288
|
|
@@ -308,17 +308,17 @@ describe Puppet::Type.type(:user) do
|
|
308
308
|
end
|
309
309
|
|
310
310
|
it "should fail if a ':' is included in the password" do
|
311
|
-
|
311
|
+
expect { described_class.new(:name => 'foo', :password => "some:thing") }.to raise_error(Puppet::Error, /Passwords cannot include ':'/)
|
312
312
|
end
|
313
313
|
|
314
314
|
it "should allow the value to be set to :absent" do
|
315
|
-
|
315
|
+
expect { described_class.new(:name => 'foo', :password => :absent) }.to_not raise_error
|
316
316
|
end
|
317
317
|
end
|
318
318
|
|
319
319
|
describe "when manages_solaris_rbac is enabled" do
|
320
320
|
it "should support a :role value for ensure" do
|
321
|
-
|
321
|
+
expect { described_class.new(:name => 'foo', :ensure => :role) }.to_not raise_error
|
322
322
|
end
|
323
323
|
end
|
324
324
|
|