puppet 2.6.7 → 2.6.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 +49 -0
- data/install.rb +6 -2
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application.rb +16 -8
- data/lib/puppet/application/agent.rb +2 -0
- data/lib/puppet/application/apply.rb +3 -0
- data/lib/puppet/application/master.rb +1 -1
- data/lib/puppet/configurer.rb +10 -1
- data/lib/puppet/defaults.rb +9 -0
- data/lib/puppet/file_serving/fileset.rb +1 -0
- data/lib/puppet/indirector/exec.rb +1 -2
- data/lib/puppet/indirector/report/yaml.rb +11 -0
- data/lib/puppet/node/environment.rb +1 -1
- data/lib/puppet/parameter.rb +2 -0
- data/lib/puppet/parameter/path.rb +42 -0
- data/lib/puppet/parser/compiler.rb +1 -1
- data/lib/puppet/parser/lexer.rb +3 -2
- data/lib/puppet/parser/parser_support.rb +0 -1
- data/lib/puppet/provider/exec/posix.rb +112 -0
- data/lib/puppet/provider/exec/shell.rb +17 -0
- data/lib/puppet/provider/group/groupadd.rb +3 -0
- data/lib/puppet/provider/nameservice/#directoryservice.rb# +519 -0
- data/lib/puppet/provider/package/gem.rb +2 -2
- data/lib/puppet/provider/package/macports.rb +106 -0
- data/lib/puppet/provider/service/debian.rb +6 -2
- data/lib/puppet/rails/inventory_node.rb +5 -0
- data/lib/puppet/reference/#providers.rb# +123 -0
- data/lib/puppet/resource/type_collection.rb +6 -1
- data/lib/puppet/simple_graph.rb +1 -1
- data/lib/puppet/transaction.rb +1 -1
- data/lib/puppet/transaction/report.rb +28 -10
- data/lib/puppet/type/cron.rb +3 -1
- data/lib/puppet/type/exec.rb +30 -167
- data/lib/puppet/type/file.rb +12 -1
- data/lib/puppet/type/file/source.rb +1 -0
- data/lib/puppet/type/group.rb +11 -1
- data/lib/puppet/type/service.rb +19 -11
- data/lib/puppet/util/command_line.rb +15 -12
- data/lib/puppet/util/command_line/puppetrun +0 -1
- data/lib/puppet/util/loadedfile.rb +1 -5
- data/lib/puppet/util/metric.rb +3 -5
- data/lib/puppet/util/plugins.rb +82 -0
- data/spec/integration/configurer_spec.rb +38 -5
- data/spec/integration/transaction_spec.rb +43 -42
- data/spec/lib/puppet_spec/verbose.rb +9 -0
- data/spec/shared_behaviours/path_parameters.rb +185 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/unit/application/agent_spec.rb +7 -0
- data/spec/unit/application/apply_spec.rb +6 -0
- data/spec/unit/application/master_spec.rb +2 -2
- data/spec/unit/configurer_spec.rb +48 -0
- data/spec/unit/file_serving/fileset_spec.rb +8 -0
- data/spec/unit/indirector/certificate_status/#file_spec.rb# +188 -0
- data/spec/unit/indirector/exec_spec.rb +2 -3
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +5 -1
- data/spec/unit/indirector/report/yaml_spec.rb +38 -0
- data/spec/unit/node/environment_spec.rb +15 -14
- data/spec/unit/parameter/path_spec.rb +24 -0
- data/spec/unit/parser/compiler_spec.rb +1 -2
- data/spec/unit/parser/lexer_spec.rb +12 -0
- data/spec/unit/provider/exec/posix_spec.rb +120 -0
- data/spec/unit/provider/exec/shell_spec.rb +50 -0
- data/spec/unit/provider/group/groupadd_spec.rb +11 -1
- data/spec/unit/provider/package/gem_spec.rb +11 -1
- data/spec/unit/provider/package/macports_spec.rb +122 -0
- data/spec/unit/provider/service/debian_spec.rb +14 -2
- data/spec/unit/resource/#type_collection_spec.rb# +463 -0
- data/spec/unit/resource/type_collection_spec.rb +21 -17
- data/spec/unit/transaction/report_spec.rb +13 -2
- data/spec/unit/type/cron_spec.rb +466 -18
- data/spec/unit/type/exec_spec.rb +633 -106
- data/spec/unit/type/file/source_spec.rb +1 -0
- data/spec/unit/type/group_spec.rb +8 -1
- data/spec/unit/type_spec.rb +1 -1
- data/spec/unit/util/loadedfile_spec.rb +7 -0
- data/spec/unit/util/rdoc/parser_spec.rb +2 -1
- data/tasks/rake/git_workflow.rake +3 -1
- data/test/ral/type/exec.rb +87 -176
- metadata +21 -5
- data/lib/puppet/provider/package/darwinport.rb +0 -86
@@ -6,6 +6,7 @@ require 'puppet/resource/type_collection'
|
|
6
6
|
require 'puppet/resource/type'
|
7
7
|
|
8
8
|
describe Puppet::Resource::TypeCollection do
|
9
|
+
include PuppetSpec::Files
|
9
10
|
before do
|
10
11
|
@instance = Puppet::Resource::Type.new(:hostclass, "foo")
|
11
12
|
@code = Puppet::Resource::TypeCollection.new("env")
|
@@ -276,7 +277,7 @@ describe Puppet::Resource::TypeCollection do
|
|
276
277
|
end
|
277
278
|
|
278
279
|
end
|
279
|
-
|
280
|
+
|
280
281
|
it "should not look in the local scope for classes when the name is qualified" do
|
281
282
|
@loader = Puppet::Resource::TypeCollection.new("env")
|
282
283
|
@loader.add Puppet::Resource::Type.new(:hostclass, "foo::bar")
|
@@ -386,16 +387,11 @@ describe Puppet::Resource::TypeCollection do
|
|
386
387
|
|
387
388
|
describe "when performing initial import" do
|
388
389
|
before do
|
389
|
-
@parser =
|
390
|
+
@parser = Puppet::Parser::Parser.new("test")
|
390
391
|
Puppet::Parser::Parser.stubs(:new).returns @parser
|
391
392
|
@code = Puppet::Resource::TypeCollection.new("env")
|
392
393
|
end
|
393
394
|
|
394
|
-
it "should create a new parser instance" do
|
395
|
-
Puppet::Parser::Parser.expects(:new).returns @parser
|
396
|
-
@code.perform_initial_import
|
397
|
-
end
|
398
|
-
|
399
395
|
it "should set the parser's string to the 'code' setting and parse if code is available" do
|
400
396
|
Puppet.settings[:code] = "my code"
|
401
397
|
@parser.expects(:string=).with "my code"
|
@@ -404,28 +400,36 @@ describe Puppet::Resource::TypeCollection do
|
|
404
400
|
end
|
405
401
|
|
406
402
|
it "should set the parser's file to the 'manifest' setting and parse if no code is available and the manifest is available" do
|
407
|
-
|
408
|
-
File.
|
409
|
-
Puppet.settings[:manifest] =
|
410
|
-
@parser.expects(:file=).with
|
403
|
+
filename = tmpfile('myfile')
|
404
|
+
File.open(filename, 'w'){|f| }
|
405
|
+
Puppet.settings[:manifest] = filename
|
406
|
+
@parser.expects(:file=).with filename
|
411
407
|
@parser.expects(:parse)
|
412
408
|
@code.perform_initial_import
|
413
409
|
end
|
414
410
|
|
415
|
-
it "should
|
416
|
-
|
417
|
-
|
418
|
-
Puppet.settings[:manifest] =
|
419
|
-
@parser.expects(:file=).
|
420
|
-
@parser.expects(:parse).
|
411
|
+
it "should pass the manifest file to the parser even if it does not exist on disk" do
|
412
|
+
filename = tmpfile('myfile')
|
413
|
+
Puppet.settings[:code] = ""
|
414
|
+
Puppet.settings[:manifest] = filename
|
415
|
+
@parser.expects(:file=).with(filename).once
|
416
|
+
@parser.expects(:parse).once
|
421
417
|
@code.perform_initial_import
|
422
418
|
end
|
423
419
|
|
424
420
|
it "should fail helpfully if there is an error importing" do
|
425
421
|
File.stubs(:exist?).returns true
|
426
422
|
@parser.expects(:parse).raises ArgumentError
|
423
|
+
@parser.stubs(:file=)
|
427
424
|
lambda { @code.perform_initial_import }.should raise_error(Puppet::Error)
|
428
425
|
end
|
426
|
+
|
427
|
+
it "should mark the type collection as needing a reparse when there is an error parsing" do
|
428
|
+
@parser.expects(:parse).raises Puppet::ParseError.new("Syntax error at ...")
|
429
|
+
|
430
|
+
lambda { @code.perform_initial_import }.should raise_error(Puppet::Error, /Syntax error at .../)
|
431
|
+
@code.require_reparse?.should be_true
|
432
|
+
end
|
429
433
|
end
|
430
434
|
|
431
435
|
describe "when determining the configuration version" do
|
@@ -273,8 +273,19 @@ describe Puppet::Transaction::Report do
|
|
273
273
|
@report.finalize_report
|
274
274
|
end
|
275
275
|
|
276
|
-
%w{
|
277
|
-
it "should include
|
276
|
+
%w{changes time resources events}.each do |main|
|
277
|
+
it "should include the key #{main} in the raw summary hash" do
|
278
|
+
@report.raw_summary.should be_key main
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should include the last run time in the raw summary hash" do
|
283
|
+
Time.stubs(:now).returns(Time.utc(2010,11,10,12,0,24))
|
284
|
+
@report.raw_summary["time"]["last_run"].should == 1289390424
|
285
|
+
end
|
286
|
+
|
287
|
+
%w{Changes Total Resources Time Events}.each do |main|
|
288
|
+
it "should include information on #{main} in the textual summary" do
|
278
289
|
@report.summary.should be_include(main)
|
279
290
|
end
|
280
291
|
end
|
data/spec/unit/type/cron_spec.rb
CHANGED
@@ -4,30 +4,478 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f
|
|
4
4
|
|
5
5
|
describe Puppet::Type.type(:cron) do
|
6
6
|
before do
|
7
|
-
@
|
8
|
-
|
7
|
+
@class = Puppet::Type.type(:cron)
|
8
|
+
|
9
|
+
# Init a fake provider
|
10
|
+
@provider_class = stub 'provider_class', :ancestors => [], :name => 'fake', :suitable? => true, :supports_parameter? => true
|
11
|
+
@class.stubs(:defaultprovider).returns @provider_class
|
12
|
+
@class.stubs(:provider).returns @provider_class
|
13
|
+
|
14
|
+
@provider = stub 'provider', :class => @provider_class, :clean => nil
|
15
|
+
@provider.stubs(:is_a?).returns false
|
16
|
+
@provider_class.stubs(:new).returns @provider
|
9
17
|
|
10
|
-
|
11
|
-
lambda do
|
12
|
-
@cron[:environment] = 'PATH=/bin:/usr/bin:/usr/sbin'
|
13
|
-
end.should_not raise_error
|
18
|
+
@cron = @class.new( :name => "foo" )
|
14
19
|
end
|
15
20
|
|
16
|
-
it "should
|
17
|
-
|
18
|
-
@cron[:environment] = "INVALID"
|
19
|
-
end.should raise_error(Puppet::Error)
|
21
|
+
it "should have :name be its namevar" do
|
22
|
+
@class.key_attributes.should == [:name]
|
20
23
|
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
describe "when validating attributes" do
|
26
|
+
|
27
|
+
[:name, :provider].each do |param|
|
28
|
+
it "should have a #{param} parameter" do
|
29
|
+
@class.attrtype(param).should == :param
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
[:command, :special, :minute, :hour, :weekday, :month, :monthday, :environment, :user, :target].each do |property|
|
34
|
+
it "should have a #{property} property" do
|
35
|
+
@class.attrtype(property).should == :property
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
[:command, :minute, :hour, :weekday, :month, :monthday].each do |cronparam|
|
40
|
+
it "should have #{cronparam} of type CronParam" do
|
41
|
+
@class.attrclass(cronparam).ancestors.should include CronParam
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
26
45
|
end
|
27
46
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
47
|
+
|
48
|
+
describe "when validating attribute" do
|
49
|
+
|
50
|
+
describe "ensure" do
|
51
|
+
it "should support present as a value for ensure" do
|
52
|
+
proc { @class.new(:name => 'foo', :ensure => :present) }.should_not raise_error
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should support absent as a value for ensure" do
|
56
|
+
proc { @class.new(:name => 'foo', :ensure => :present) }.should_not raise_error
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "minute" do
|
61
|
+
|
62
|
+
it "should support absent" do
|
63
|
+
proc { @class.new(:name => 'foo', :minute => 'absent') }.should_not raise_error
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should support *" do
|
67
|
+
proc { @class.new(:name => 'foo', :minute => '*') }.should_not raise_error
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should translate absent to :absent" do
|
71
|
+
@class.new(:name => 'foo', :minute => 'absent')[:minute].should == :absent
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should translate * to :absent" do
|
75
|
+
@class.new(:name => 'foo', :minute => '*')[:minute].should == :absent
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should support valid single values" do
|
79
|
+
proc { @class.new(:name => 'foo', :minute => '0') }.should_not raise_error
|
80
|
+
proc { @class.new(:name => 'foo', :minute => '1') }.should_not raise_error
|
81
|
+
proc { @class.new(:name => 'foo', :minute => '59') }.should_not raise_error
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should not support non numeric characters" do
|
85
|
+
proc { @class.new(:name => 'foo', :minute => 'z59') }.should raise_error(Puppet::Error)
|
86
|
+
proc { @class.new(:name => 'foo', :minute => '5z9') }.should raise_error(Puppet::Error)
|
87
|
+
proc { @class.new(:name => 'foo', :minute => '59z') }.should raise_error(Puppet::Error)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should not support single values out of range" do
|
91
|
+
|
92
|
+
proc { @class.new(:name => 'foo', :minute => '-1') }.should raise_error(Puppet::Error)
|
93
|
+
proc { @class.new(:name => 'foo', :minute => '60') }.should raise_error(Puppet::Error)
|
94
|
+
proc { @class.new(:name => 'foo', :minute => '61') }.should raise_error(Puppet::Error)
|
95
|
+
proc { @class.new(:name => 'foo', :minute => '120') }.should raise_error(Puppet::Error)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should support valid multiple values" do
|
99
|
+
proc { @class.new(:name => 'foo', :minute => ['0','1','59'] ) }.should_not raise_error
|
100
|
+
proc { @class.new(:name => 'foo', :minute => ['40','30','20'] ) }.should_not raise_error
|
101
|
+
proc { @class.new(:name => 'foo', :minute => ['10','30','20'] ) }.should_not raise_error
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should not support multiple values if at least one is invalid" do
|
105
|
+
# one invalid
|
106
|
+
proc { @class.new(:name => 'foo', :minute => ['0','1','60'] ) }.should raise_error(Puppet::Error)
|
107
|
+
proc { @class.new(:name => 'foo', :minute => ['0','120','59'] ) }.should raise_error(Puppet::Error)
|
108
|
+
proc { @class.new(:name => 'foo', :minute => ['-1','1','59'] ) }.should raise_error(Puppet::Error)
|
109
|
+
# two invalid
|
110
|
+
proc { @class.new(:name => 'foo', :minute => ['0','61','62'] ) }.should raise_error(Puppet::Error)
|
111
|
+
# all invalid
|
112
|
+
proc { @class.new(:name => 'foo', :minute => ['-1','61','62'] ) }.should raise_error(Puppet::Error)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should support valid step syntax" do
|
116
|
+
proc { @class.new(:name => 'foo', :minute => '*/2' ) }.should_not raise_error
|
117
|
+
proc { @class.new(:name => 'foo', :minute => '10-16/2' ) }.should_not raise_error
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should not support invalid steps" do
|
121
|
+
proc { @class.new(:name => 'foo', :minute => '*/A' ) }.should raise_error(Puppet::Error)
|
122
|
+
proc { @class.new(:name => 'foo', :minute => '*/2A' ) }.should raise_error(Puppet::Error)
|
123
|
+
# As it turns out cron does not complaining about steps that exceed the valid range
|
124
|
+
# proc { @class.new(:name => 'foo', :minute => '*/120' ) }.should raise_error(Puppet::Error)
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "hour" do
|
130
|
+
|
131
|
+
it "should support absent" do
|
132
|
+
proc { @class.new(:name => 'foo', :hour => 'absent') }.should_not raise_error
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should support *" do
|
136
|
+
proc { @class.new(:name => 'foo', :hour => '*') }.should_not raise_error
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should translate absent to :absent" do
|
140
|
+
@class.new(:name => 'foo', :hour => 'absent')[:hour].should == :absent
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should translate * to :absent" do
|
144
|
+
@class.new(:name => 'foo', :hour => '*')[:hour].should == :absent
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should support valid single values" do
|
148
|
+
proc { @class.new(:name => 'foo', :hour => '0') }.should_not raise_error
|
149
|
+
proc { @class.new(:name => 'foo', :hour => '11') }.should_not raise_error
|
150
|
+
proc { @class.new(:name => 'foo', :hour => '12') }.should_not raise_error
|
151
|
+
proc { @class.new(:name => 'foo', :hour => '13') }.should_not raise_error
|
152
|
+
proc { @class.new(:name => 'foo', :hour => '23') }.should_not raise_error
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should not support non numeric characters" do
|
156
|
+
proc { @class.new(:name => 'foo', :hour => 'z15') }.should raise_error(Puppet::Error)
|
157
|
+
proc { @class.new(:name => 'foo', :hour => '1z5') }.should raise_error(Puppet::Error)
|
158
|
+
proc { @class.new(:name => 'foo', :hour => '15z') }.should raise_error(Puppet::Error)
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should not support single values out of range" do
|
162
|
+
proc { @class.new(:name => 'foo', :hour => '-1') }.should raise_error(Puppet::Error)
|
163
|
+
proc { @class.new(:name => 'foo', :hour => '24') }.should raise_error(Puppet::Error)
|
164
|
+
proc { @class.new(:name => 'foo', :hour => '120') }.should raise_error(Puppet::Error)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should support valid multiple values" do
|
168
|
+
proc { @class.new(:name => 'foo', :hour => ['0','1','23'] ) }.should_not raise_error
|
169
|
+
proc { @class.new(:name => 'foo', :hour => ['5','16','14'] ) }.should_not raise_error
|
170
|
+
proc { @class.new(:name => 'foo', :hour => ['16','13','9'] ) }.should_not raise_error
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should not support multiple values if at least one is invalid" do
|
174
|
+
# one invalid
|
175
|
+
proc { @class.new(:name => 'foo', :hour => ['0','1','24'] ) }.should raise_error(Puppet::Error)
|
176
|
+
proc { @class.new(:name => 'foo', :hour => ['0','-1','5'] ) }.should raise_error(Puppet::Error)
|
177
|
+
proc { @class.new(:name => 'foo', :hour => ['-1','1','23'] ) }.should raise_error(Puppet::Error)
|
178
|
+
# two invalid
|
179
|
+
proc { @class.new(:name => 'foo', :hour => ['0','25','26'] ) }.should raise_error(Puppet::Error)
|
180
|
+
# all invalid
|
181
|
+
proc { @class.new(:name => 'foo', :hour => ['-1','24','120'] ) }.should raise_error(Puppet::Error)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should support valid step syntax" do
|
185
|
+
proc { @class.new(:name => 'foo', :hour => '*/2' ) }.should_not raise_error
|
186
|
+
proc { @class.new(:name => 'foo', :hour => '10-18/4' ) }.should_not raise_error
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should not support invalid steps" do
|
190
|
+
proc { @class.new(:name => 'foo', :hour => '*/A' ) }.should raise_error(Puppet::Error)
|
191
|
+
proc { @class.new(:name => 'foo', :hour => '*/2A' ) }.should raise_error(Puppet::Error)
|
192
|
+
# As it turns out cron does not complaining about steps that exceed the valid range
|
193
|
+
# proc { @class.new(:name => 'foo', :hour => '*/26' ) }.should raise_error(Puppet::Error)
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
describe "weekday" do
|
199
|
+
|
200
|
+
it "should support absent" do
|
201
|
+
proc { @class.new(:name => 'foo', :weekday => 'absent') }.should_not raise_error
|
202
|
+
end
|
203
|
+
|
204
|
+
it "should support *" do
|
205
|
+
proc { @class.new(:name => 'foo', :weekday => '*') }.should_not raise_error
|
206
|
+
end
|
207
|
+
|
208
|
+
it "should translate absent to :absent" do
|
209
|
+
@class.new(:name => 'foo', :weekday => 'absent')[:weekday].should == :absent
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should translate * to :absent" do
|
213
|
+
@class.new(:name => 'foo', :weekday => '*')[:weekday].should == :absent
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should support valid numeric weekdays" do
|
217
|
+
proc { @class.new(:name => 'foo', :weekday => '0') }.should_not raise_error
|
218
|
+
proc { @class.new(:name => 'foo', :weekday => '1') }.should_not raise_error
|
219
|
+
proc { @class.new(:name => 'foo', :weekday => '6') }.should_not raise_error
|
220
|
+
# According to http://www.manpagez.com/man/5/crontab 7 is also valid (Sunday)
|
221
|
+
proc { @class.new(:name => 'foo', :weekday => '7') }.should_not raise_error
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should support valid weekdays as words (3 character version)" do
|
225
|
+
proc { @class.new(:name => 'foo', :weekday => 'Monday') }.should_not raise_error
|
226
|
+
proc { @class.new(:name => 'foo', :weekday => 'Tuesday') }.should_not raise_error
|
227
|
+
proc { @class.new(:name => 'foo', :weekday => 'Wednesday') }.should_not raise_error
|
228
|
+
proc { @class.new(:name => 'foo', :weekday => 'Thursday') }.should_not raise_error
|
229
|
+
proc { @class.new(:name => 'foo', :weekday => 'Friday') }.should_not raise_error
|
230
|
+
proc { @class.new(:name => 'foo', :weekday => 'Saturday') }.should_not raise_error
|
231
|
+
proc { @class.new(:name => 'foo', :weekday => 'Sunday') }.should_not raise_error
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should support valid weekdays as words (3 character version)" do
|
235
|
+
proc { @class.new(:name => 'foo', :weekday => 'Mon') }.should_not raise_error
|
236
|
+
proc { @class.new(:name => 'foo', :weekday => 'Tue') }.should_not raise_error
|
237
|
+
proc { @class.new(:name => 'foo', :weekday => 'Wed') }.should_not raise_error
|
238
|
+
proc { @class.new(:name => 'foo', :weekday => 'Thu') }.should_not raise_error
|
239
|
+
proc { @class.new(:name => 'foo', :weekday => 'Fri') }.should_not raise_error
|
240
|
+
proc { @class.new(:name => 'foo', :weekday => 'Sat') }.should_not raise_error
|
241
|
+
proc { @class.new(:name => 'foo', :weekday => 'Sun') }.should_not raise_error
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should not support numeric values out of range" do
|
245
|
+
proc { @class.new(:name => 'foo', :weekday => '-1') }.should raise_error(Puppet::Error)
|
246
|
+
proc { @class.new(:name => 'foo', :weekday => '8') }.should raise_error(Puppet::Error)
|
247
|
+
end
|
248
|
+
|
249
|
+
it "should not support invalid weekday names" do
|
250
|
+
proc { @class.new(:name => 'foo', :weekday => 'Sar') }.should raise_error(Puppet::Error)
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should support valid multiple values" do
|
254
|
+
proc { @class.new(:name => 'foo', :weekday => ['0','1','6'] ) }.should_not raise_error
|
255
|
+
proc { @class.new(:name => 'foo', :weekday => ['Mon','Wed','Friday'] ) }.should_not raise_error
|
256
|
+
end
|
257
|
+
|
258
|
+
it "should not support multiple values if at least one is invalid" do
|
259
|
+
# one invalid
|
260
|
+
proc { @class.new(:name => 'foo', :weekday => ['0','1','8'] ) }.should raise_error(Puppet::Error)
|
261
|
+
proc { @class.new(:name => 'foo', :weekday => ['Mon','Fii','Sat'] ) }.should raise_error(Puppet::Error)
|
262
|
+
# two invalid
|
263
|
+
proc { @class.new(:name => 'foo', :weekday => ['Mos','Fii','Sat'] ) }.should raise_error(Puppet::Error)
|
264
|
+
# all invalid
|
265
|
+
proc { @class.new(:name => 'foo', :weekday => ['Mos','Fii','Saa'] ) }.should raise_error(Puppet::Error)
|
266
|
+
proc { @class.new(:name => 'foo', :weekday => ['-1','8','11'] ) }.should raise_error(Puppet::Error)
|
267
|
+
end
|
268
|
+
|
269
|
+
it "should support valid step syntax" do
|
270
|
+
proc { @class.new(:name => 'foo', :weekday => '*/2' ) }.should_not raise_error
|
271
|
+
proc { @class.new(:name => 'foo', :weekday => '0-4/2' ) }.should_not raise_error
|
272
|
+
end
|
273
|
+
|
274
|
+
it "should not support invalid steps" do
|
275
|
+
proc { @class.new(:name => 'foo', :weekday => '*/A' ) }.should raise_error(Puppet::Error)
|
276
|
+
proc { @class.new(:name => 'foo', :weekday => '*/2A' ) }.should raise_error(Puppet::Error)
|
277
|
+
# As it turns out cron does not complaining about steps that exceed the valid range
|
278
|
+
# proc { @class.new(:name => 'foo', :weekday => '*/9' ) }.should raise_error(Puppet::Error)
|
279
|
+
end
|
280
|
+
|
281
|
+
end
|
282
|
+
|
283
|
+
describe "month" do
|
284
|
+
|
285
|
+
it "should support absent" do
|
286
|
+
proc { @class.new(:name => 'foo', :month => 'absent') }.should_not raise_error
|
287
|
+
end
|
288
|
+
|
289
|
+
it "should support *" do
|
290
|
+
proc { @class.new(:name => 'foo', :month => '*') }.should_not raise_error
|
291
|
+
end
|
292
|
+
|
293
|
+
it "should translate absent to :absent" do
|
294
|
+
@class.new(:name => 'foo', :month => 'absent')[:month].should == :absent
|
295
|
+
end
|
296
|
+
|
297
|
+
it "should translate * to :absent" do
|
298
|
+
@class.new(:name => 'foo', :month => '*')[:month].should == :absent
|
299
|
+
end
|
300
|
+
|
301
|
+
it "should support valid numeric values" do
|
302
|
+
proc { @class.new(:name => 'foo', :month => '1') }.should_not raise_error
|
303
|
+
proc { @class.new(:name => 'foo', :month => '12') }.should_not raise_error
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should support valid months as words" do
|
307
|
+
proc { @class.new(:name => 'foo', :month => 'January') }.should_not raise_error
|
308
|
+
proc { @class.new(:name => 'foo', :month => 'February') }.should_not raise_error
|
309
|
+
proc { @class.new(:name => 'foo', :month => 'March') }.should_not raise_error
|
310
|
+
proc { @class.new(:name => 'foo', :month => 'April') }.should_not raise_error
|
311
|
+
proc { @class.new(:name => 'foo', :month => 'May') }.should_not raise_error
|
312
|
+
proc { @class.new(:name => 'foo', :month => 'June') }.should_not raise_error
|
313
|
+
proc { @class.new(:name => 'foo', :month => 'July') }.should_not raise_error
|
314
|
+
proc { @class.new(:name => 'foo', :month => 'August') }.should_not raise_error
|
315
|
+
proc { @class.new(:name => 'foo', :month => 'September') }.should_not raise_error
|
316
|
+
proc { @class.new(:name => 'foo', :month => 'October') }.should_not raise_error
|
317
|
+
proc { @class.new(:name => 'foo', :month => 'November') }.should_not raise_error
|
318
|
+
proc { @class.new(:name => 'foo', :month => 'December') }.should_not raise_error
|
319
|
+
end
|
320
|
+
|
321
|
+
it "should support valid months as words (3 character short version)" do
|
322
|
+
proc { @class.new(:name => 'foo', :month => 'Jan') }.should_not raise_error
|
323
|
+
proc { @class.new(:name => 'foo', :month => 'Feb') }.should_not raise_error
|
324
|
+
proc { @class.new(:name => 'foo', :month => 'Mar') }.should_not raise_error
|
325
|
+
proc { @class.new(:name => 'foo', :month => 'Apr') }.should_not raise_error
|
326
|
+
proc { @class.new(:name => 'foo', :month => 'May') }.should_not raise_error
|
327
|
+
proc { @class.new(:name => 'foo', :month => 'Jun') }.should_not raise_error
|
328
|
+
proc { @class.new(:name => 'foo', :month => 'Jul') }.should_not raise_error
|
329
|
+
proc { @class.new(:name => 'foo', :month => 'Aug') }.should_not raise_error
|
330
|
+
proc { @class.new(:name => 'foo', :month => 'Sep') }.should_not raise_error
|
331
|
+
proc { @class.new(:name => 'foo', :month => 'Oct') }.should_not raise_error
|
332
|
+
proc { @class.new(:name => 'foo', :month => 'Nov') }.should_not raise_error
|
333
|
+
proc { @class.new(:name => 'foo', :month => 'Dec') }.should_not raise_error
|
334
|
+
end
|
335
|
+
|
336
|
+
it "should not support numeric values out of range" do
|
337
|
+
proc { @class.new(:name => 'foo', :month => '-1') }.should raise_error(Puppet::Error)
|
338
|
+
proc { @class.new(:name => 'foo', :month => '0') }.should raise_error(Puppet::Error)
|
339
|
+
proc { @class.new(:name => 'foo', :month => '13') }.should raise_error(Puppet::Error)
|
340
|
+
end
|
341
|
+
|
342
|
+
it "should not support words that are not valid months" do
|
343
|
+
proc { @class.new(:name => 'foo', :month => 'Jal') }.should raise_error(Puppet::Error)
|
344
|
+
end
|
345
|
+
|
346
|
+
it "should not support single values out of range" do
|
347
|
+
|
348
|
+
proc { @class.new(:name => 'foo', :month => '-1') }.should raise_error(Puppet::Error)
|
349
|
+
proc { @class.new(:name => 'foo', :month => '60') }.should raise_error(Puppet::Error)
|
350
|
+
proc { @class.new(:name => 'foo', :month => '61') }.should raise_error(Puppet::Error)
|
351
|
+
proc { @class.new(:name => 'foo', :month => '120') }.should raise_error(Puppet::Error)
|
352
|
+
end
|
353
|
+
|
354
|
+
it "should support valid multiple values" do
|
355
|
+
proc { @class.new(:name => 'foo', :month => ['1','9','12'] ) }.should_not raise_error
|
356
|
+
proc { @class.new(:name => 'foo', :month => ['Jan','March','Jul'] ) }.should_not raise_error
|
357
|
+
end
|
358
|
+
|
359
|
+
it "should not support multiple values if at least one is invalid" do
|
360
|
+
# one invalid
|
361
|
+
proc { @class.new(:name => 'foo', :month => ['0','1','12'] ) }.should raise_error(Puppet::Error)
|
362
|
+
proc { @class.new(:name => 'foo', :month => ['1','13','10'] ) }.should raise_error(Puppet::Error)
|
363
|
+
proc { @class.new(:name => 'foo', :month => ['Jan','Feb','Jxx'] ) }.should raise_error(Puppet::Error)
|
364
|
+
# two invalid
|
365
|
+
proc { @class.new(:name => 'foo', :month => ['Jan','Fex','Jux'] ) }.should raise_error(Puppet::Error)
|
366
|
+
# all invalid
|
367
|
+
proc { @class.new(:name => 'foo', :month => ['-1','0','13'] ) }.should raise_error(Puppet::Error)
|
368
|
+
proc { @class.new(:name => 'foo', :month => ['Jax','Fex','Aux'] ) }.should raise_error(Puppet::Error)
|
369
|
+
end
|
370
|
+
|
371
|
+
it "should support valid step syntax" do
|
372
|
+
proc { @class.new(:name => 'foo', :month => '*/2' ) }.should_not raise_error
|
373
|
+
proc { @class.new(:name => 'foo', :month => '1-12/3' ) }.should_not raise_error
|
374
|
+
end
|
375
|
+
|
376
|
+
it "should not support invalid steps" do
|
377
|
+
proc { @class.new(:name => 'foo', :month => '*/A' ) }.should raise_error(Puppet::Error)
|
378
|
+
proc { @class.new(:name => 'foo', :month => '*/2A' ) }.should raise_error(Puppet::Error)
|
379
|
+
# As it turns out cron does not complaining about steps that exceed the valid range
|
380
|
+
# proc { @class.new(:name => 'foo', :month => '*/13' ) }.should raise_error(Puppet::Error)
|
381
|
+
end
|
382
|
+
|
383
|
+
end
|
384
|
+
|
385
|
+
describe "monthday" do
|
386
|
+
|
387
|
+
it "should support absent" do
|
388
|
+
proc { @class.new(:name => 'foo', :monthday => 'absent') }.should_not raise_error
|
389
|
+
end
|
390
|
+
|
391
|
+
it "should support *" do
|
392
|
+
proc { @class.new(:name => 'foo', :monthday => '*') }.should_not raise_error
|
393
|
+
end
|
394
|
+
|
395
|
+
it "should translate absent to :absent" do
|
396
|
+
@class.new(:name => 'foo', :monthday => 'absent')[:monthday].should == :absent
|
397
|
+
end
|
398
|
+
|
399
|
+
it "should translate * to :absent" do
|
400
|
+
@class.new(:name => 'foo', :monthday => '*')[:monthday].should == :absent
|
401
|
+
end
|
402
|
+
|
403
|
+
it "should support valid single values" do
|
404
|
+
proc { @class.new(:name => 'foo', :monthday => '1') }.should_not raise_error
|
405
|
+
proc { @class.new(:name => 'foo', :monthday => '30') }.should_not raise_error
|
406
|
+
proc { @class.new(:name => 'foo', :monthday => '31') }.should_not raise_error
|
407
|
+
end
|
408
|
+
|
409
|
+
it "should not support non numeric characters" do
|
410
|
+
proc { @class.new(:name => 'foo', :monthday => 'z23') }.should raise_error(Puppet::Error)
|
411
|
+
proc { @class.new(:name => 'foo', :monthday => '2z3') }.should raise_error(Puppet::Error)
|
412
|
+
proc { @class.new(:name => 'foo', :monthday => '23z') }.should raise_error(Puppet::Error)
|
413
|
+
end
|
414
|
+
|
415
|
+
it "should not support single values out of range" do
|
416
|
+
proc { @class.new(:name => 'foo', :monthday => '-1') }.should raise_error(Puppet::Error)
|
417
|
+
proc { @class.new(:name => 'foo', :monthday => '0') }.should raise_error(Puppet::Error)
|
418
|
+
proc { @class.new(:name => 'foo', :monthday => '32') }.should raise_error(Puppet::Error)
|
419
|
+
end
|
420
|
+
|
421
|
+
it "should support valid multiple values" do
|
422
|
+
proc { @class.new(:name => 'foo', :monthday => ['1','23','31'] ) }.should_not raise_error
|
423
|
+
proc { @class.new(:name => 'foo', :monthday => ['31','23','1'] ) }.should_not raise_error
|
424
|
+
proc { @class.new(:name => 'foo', :monthday => ['1','31','23'] ) }.should_not raise_error
|
425
|
+
end
|
426
|
+
|
427
|
+
it "should not support multiple values if at least one is invalid" do
|
428
|
+
# one invalid
|
429
|
+
proc { @class.new(:name => 'foo', :monthday => ['1','23','32'] ) }.should raise_error(Puppet::Error)
|
430
|
+
proc { @class.new(:name => 'foo', :monthday => ['-1','12','23'] ) }.should raise_error(Puppet::Error)
|
431
|
+
proc { @class.new(:name => 'foo', :monthday => ['13','32','30'] ) }.should raise_error(Puppet::Error)
|
432
|
+
# two invalid
|
433
|
+
proc { @class.new(:name => 'foo', :monthday => ['-1','0','23'] ) }.should raise_error(Puppet::Error)
|
434
|
+
# all invalid
|
435
|
+
proc { @class.new(:name => 'foo', :monthday => ['-1','0','32'] ) }.should raise_error(Puppet::Error)
|
436
|
+
end
|
437
|
+
|
438
|
+
it "should support valid step syntax" do
|
439
|
+
proc { @class.new(:name => 'foo', :monthday => '*/2' ) }.should_not raise_error
|
440
|
+
proc { @class.new(:name => 'foo', :monthday => '10-16/2' ) }.should_not raise_error
|
441
|
+
end
|
442
|
+
|
443
|
+
it "should not support invalid steps" do
|
444
|
+
proc { @class.new(:name => 'foo', :monthday => '*/A' ) }.should raise_error(Puppet::Error)
|
445
|
+
proc { @class.new(:name => 'foo', :monthday => '*/2A' ) }.should raise_error(Puppet::Error)
|
446
|
+
# As it turns out cron does not complaining about steps that exceed the valid range
|
447
|
+
# proc { @class.new(:name => 'foo', :monthday => '*/32' ) }.should raise_error(Puppet::Error)
|
448
|
+
end
|
449
|
+
|
450
|
+
end
|
451
|
+
|
452
|
+
describe "environment" do
|
453
|
+
|
454
|
+
it "it should accept an :environment that looks like a path" do
|
455
|
+
lambda do
|
456
|
+
@cron[:environment] = 'PATH=/bin:/usr/bin:/usr/sbin'
|
457
|
+
end.should_not raise_error
|
458
|
+
end
|
459
|
+
|
460
|
+
it "should not accept environment variables that do not contain '='" do
|
461
|
+
lambda do
|
462
|
+
@cron[:environment] = "INVALID"
|
463
|
+
end.should raise_error(Puppet::Error)
|
464
|
+
end
|
465
|
+
|
466
|
+
it "should accept empty environment variables that do not contain '='" do
|
467
|
+
lambda do
|
468
|
+
@cron[:environment] = "MAILTO="
|
469
|
+
end.should_not raise_error(Puppet::Error)
|
470
|
+
end
|
471
|
+
|
472
|
+
it "should accept 'absent'" do
|
473
|
+
lambda do
|
474
|
+
@cron[:environment] = 'absent'
|
475
|
+
end.should_not raise_error(Puppet::Error)
|
476
|
+
end
|
477
|
+
|
478
|
+
end
|
479
|
+
|
32
480
|
end
|
33
481
|
end
|