puppet 2.7.11 → 2.7.12
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 +188 -0
- data/conf/osx/createpackage.sh +1 -0
- data/conf/redhat/puppet.spec +12 -9
- data/conf/suse/puppet.spec +4 -1
- data/install.rb +9 -22
- data/lib/puppet.rb +1 -31
- data/lib/puppet/agent.rb +3 -5
- data/lib/puppet/agent/locker.rb +15 -1
- data/lib/puppet/application.rb +7 -4
- data/lib/puppet/application/agent.rb +4 -25
- data/lib/puppet/application/apply.rb +3 -3
- data/lib/puppet/application/device.rb +2 -16
- data/lib/puppet/application/doc.rb +2 -2
- data/lib/puppet/application/face_base.rb +22 -5
- data/lib/puppet/application/filebucket.rb +2 -0
- data/lib/puppet/application/inspect.rb +2 -1
- data/lib/puppet/application/kick.rb +25 -9
- data/lib/puppet/application/queue.rb +0 -23
- data/lib/puppet/configurer.rb +1 -0
- data/lib/puppet/configurer/downloader.rb +7 -3
- data/lib/puppet/defaults.rb +34 -29
- data/lib/puppet/face/ca.rb +1 -1
- data/lib/puppet/face/catalog.rb +1 -0
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/face/module/list.rb +23 -3
- data/lib/puppet/face/module/search.rb +21 -32
- data/lib/puppet/face/module/uninstall.rb +56 -15
- data/lib/puppet/file_bucket/dipper.rb +2 -2
- data/lib/puppet/file_serving/base.rb +6 -5
- data/lib/puppet/file_serving/configuration/parser.rb +1 -1
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/forge.rb +153 -0
- data/lib/puppet/{module_tool → forge}/cache.rb +1 -2
- data/lib/puppet/{module_tool → forge}/repository.rb +46 -4
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -3
- data/lib/puppet/interface/action.rb +6 -2
- data/lib/puppet/module.rb +70 -10
- data/lib/puppet/module_tool.rb +2 -38
- data/lib/puppet/module_tool/applications.rb +15 -11
- data/lib/puppet/module_tool/applications/application.rb +2 -5
- data/lib/puppet/module_tool/applications/cleaner.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +10 -45
- data/lib/puppet/module_tool/applications/searcher.rb +2 -26
- data/lib/puppet/module_tool/applications/uninstaller.rb +39 -13
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +1 -1
- data/lib/puppet/network/authconfig.rb +1 -1
- data/lib/puppet/network/handler/fileserver.rb +1 -1
- data/lib/puppet/network/http/handler.rb +4 -1
- data/lib/puppet/network/http/webrick.rb +4 -2
- data/lib/puppet/node/environment.rb +32 -6
- data/lib/puppet/parameter/path.rb +0 -4
- data/lib/puppet/parser/ast/relationship.rb +3 -16
- data/lib/puppet/parser/collector.rb +5 -3
- data/lib/puppet/parser/compiler.rb +2 -1
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +8 -2
- data/lib/puppet/parser/grammar.ra +16 -15
- data/lib/puppet/parser/parser.rb +959 -881
- data/lib/puppet/parser/relationship.rb +32 -15
- data/lib/puppet/parser/resource.rb +0 -1
- data/lib/puppet/parser/type_loader.rb +1 -2
- data/lib/puppet/provider/augeas/augeas.rb +17 -29
- data/lib/puppet/provider/exec/windows.rb +25 -3
- data/lib/puppet/provider/file/posix.rb +1 -1
- data/lib/puppet/provider/file/windows.rb +1 -1
- data/lib/puppet/provider/group/windows_adsi.rb +1 -1
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +21 -23
- data/lib/puppet/provider/package/macports.rb +1 -1
- data/lib/puppet/provider/package/msi.rb +7 -1
- data/lib/puppet/provider/package/openbsd.rb +13 -16
- data/lib/puppet/provider/package/pacman.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +3 -0
- data/lib/puppet/provider/package/pkg.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +35 -3
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +6 -2
- data/lib/puppet/provider/selmodule/semodule.rb +2 -2
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +4 -0
- data/lib/puppet/provider/service/src.rb +2 -2
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/service/windows.rb +5 -4
- data/lib/puppet/provider/user/aix.rb +3 -3
- data/lib/puppet/provider/user/pw.rb +6 -0
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/resource/catalog.rb +6 -6
- data/lib/puppet/resource/type.rb +2 -0
- data/lib/puppet/ssl/certificate_request.rb +0 -70
- data/lib/puppet/transaction.rb +1 -1
- data/lib/puppet/transaction/report.rb +3 -2
- data/lib/puppet/type.rb +1 -1
- data/lib/puppet/type/cron.rb +5 -2
- data/lib/puppet/type/exec.rb +8 -0
- data/lib/puppet/type/file.rb +27 -18
- data/lib/puppet/type/file/checksum.rb +2 -2
- data/lib/puppet/type/file/content.rb +14 -9
- data/lib/puppet/type/file/ensure.rb +5 -4
- data/lib/puppet/type/file/group.rb +10 -2
- data/lib/puppet/type/file/mode.rb +46 -18
- data/lib/puppet/type/file/owner.rb +10 -2
- data/lib/puppet/type/file/source.rb +27 -40
- data/lib/puppet/type/file/target.rb +6 -6
- data/lib/puppet/type/group.rb +13 -9
- data/lib/puppet/type/k5login.rb +1 -1
- data/lib/puppet/type/package.rb +24 -8
- data/lib/puppet/type/scheduled_task.rb +77 -131
- data/lib/puppet/type/service.rb +22 -8
- data/lib/puppet/type/user.rb +29 -9
- data/lib/puppet/util.rb +24 -33
- data/lib/puppet/util/colors.rb +98 -0
- data/lib/puppet/util/diff.rb +3 -1
- data/lib/puppet/util/log.rb +5 -1
- data/lib/puppet/util/log/destinations.rb +37 -44
- data/lib/puppet/util/monkey_patches.rb +32 -0
- data/lib/puppet/util/pidlock.rb +70 -21
- data/lib/puppet/util/rdoc/parser.rb +4 -2
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +2 -12
- data/lib/puppet/util/windows.rb +2 -0
- data/lib/puppet/util/windows/process.rb +33 -0
- data/lib/puppet/util/windows/security.rb +6 -4
- data/lib/puppet/util/windows/user.rb +44 -0
- data/lib/semver.rb +55 -4
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.detail +19 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.list +10 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.query +1 -0
- data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-SLES11sp1.out +369 -0
- data/spec/integration/defaults_spec.rb +10 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +1 -1
- data/spec/integration/module_tool_spec.rb +10 -12
- data/spec/integration/parser/compiler_spec.rb +147 -0
- data/spec/integration/type/file_spec.rb +1 -1
- data/spec/integration/util/windows/user_spec.rb +59 -0
- data/spec/lib/puppet/face/basetest.rb +5 -0
- data/spec/lib/puppet_spec/modules.rb +26 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/unit/agent/locker_spec.rb +12 -0
- data/spec/unit/agent_backward_compatibility_spec.rb +152 -0
- data/spec/unit/agent_spec.rb +28 -8
- data/spec/unit/application/agent_spec.rb +4 -36
- data/spec/unit/application/device_spec.rb +55 -10
- data/spec/unit/application/face_base_spec.rb +32 -10
- data/spec/unit/application/filebucket_spec.rb +5 -0
- data/spec/unit/application/kick_spec.rb +6 -0
- data/spec/unit/application_spec.rb +8 -1
- data/spec/unit/configurer/downloader_spec.rb +4 -5
- data/spec/unit/face/ca_spec.rb +15 -4
- data/spec/unit/file_bucket/dipper_spec.rb +1 -1
- data/spec/unit/file_serving/base_spec.rb +60 -42
- data/spec/unit/file_serving/configuration/parser_spec.rb +5 -3
- data/spec/unit/file_serving/content_spec.rb +26 -27
- data/spec/unit/file_serving/metadata_spec.rb +22 -21
- data/spec/unit/forge/repository_spec.rb +86 -0
- data/spec/unit/forge_spec.rb +114 -0
- data/spec/unit/indirector/exec_spec.rb +8 -6
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +0 -1
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +1 -1
- data/spec/unit/indirector/node/exec_spec.rb +1 -1
- data/spec/unit/indirector/resource/active_record_spec.rb +0 -4
- data/spec/unit/interface/action_builder_spec.rb +7 -5
- data/spec/unit/module_spec.rb +228 -9
- data/spec/unit/module_tool/application_spec.rb +3 -3
- data/spec/unit/module_tool/uninstaller_spec.rb +107 -27
- data/spec/unit/module_tool_spec.rb +0 -33
- data/spec/unit/network/authconfig_spec.rb +22 -21
- data/spec/unit/network/http/webrick_spec.rb +13 -9
- data/spec/unit/node/environment_spec.rb +159 -66
- data/spec/unit/parser/collector_spec.rb +16 -8
- data/spec/unit/parser/functions/generate_spec.rb +60 -18
- data/spec/unit/parser/resource_spec.rb +44 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +160 -179
- data/spec/unit/provider/confine/feature_spec.rb +3 -5
- data/spec/unit/provider/package/dpkg_spec.rb +4 -2
- data/spec/unit/provider/package/gem_spec.rb +59 -43
- data/spec/unit/provider/package/openbsd_spec.rb +114 -0
- data/spec/unit/provider/package/pacman_spec.rb +1 -1
- data/spec/unit/provider/package/pip_spec.rb +10 -4
- data/spec/unit/provider/package/zypper_spec.rb +56 -14
- data/spec/unit/provider/selmodule_spec.rb +3 -3
- data/spec/unit/provider/service/launchd_spec.rb +22 -21
- data/spec/unit/provider/service/{upstart.rb → upstart_spec.rb} +7 -3
- data/spec/unit/provider/user/pw_spec.rb +19 -0
- data/spec/unit/resource/catalog_spec.rb +3 -3
- data/spec/unit/semver_spec.rb +117 -24
- data/spec/unit/transaction/report_spec.rb +11 -1
- data/spec/unit/type/cron_spec.rb +200 -213
- data/spec/unit/type/exec_spec.rb +7 -0
- data/spec/unit/type/file/content_spec.rb +2 -2
- data/spec/unit/type/file_spec.rb +12 -9
- data/spec/unit/type/package_spec.rb +25 -0
- data/spec/unit/type/schedule_spec.rb +31 -31
- data/spec/unit/util/diff_spec.rb +30 -0
- data/spec/unit/util/execution_stub_spec.rb +1 -2
- data/spec/unit/util/log/destinations_spec.rb +51 -0
- data/spec/unit/util/log_spec.rb +17 -1
- data/spec/unit/util/monkey_patches_spec.rb +119 -0
- data/spec/unit/util/rdoc/parser_spec.rb +25 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/util/suidmanager_spec.rb +6 -51
- data/spec/unit/util_spec.rb +82 -24
- data/test/lib/puppettest/certificates.rb +16 -0
- data/test/lib/puppettest/servertest.rb +4 -0
- data/test/util/pidlock.rb +125 -0
- metadata +23 -14
- data/ext/puppetstoredconfigclean.rb +0 -103
- data/lib/puppet/agent/disabler.rb +0 -27
- data/lib/puppet/util/anonymous_filelock.rb +0 -36
- data/spec/unit/agent/disabler_spec.rb +0 -60
- data/spec/unit/module_tool/repository_spec.rb +0 -52
- data/spec/unit/util/anonymous_filelock_spec.rb +0 -78
- data/spec/unit/util/pidlock_spec.rb +0 -208
@@ -29,7 +29,7 @@ describe Puppet::Transaction::Report do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should take a 'configuration_version' as an argument" do
|
32
|
-
Puppet::Transaction::Report.new("inspect", "some configuration version").configuration_version.should == "some configuration version"
|
32
|
+
Puppet::Transaction::Report.new("inspect", "some configuration version", "some environment").configuration_version.should == "some configuration version"
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should be able to set configuration_version" do
|
@@ -38,6 +38,16 @@ describe Puppet::Transaction::Report do
|
|
38
38
|
report.configuration_version.should == "some version"
|
39
39
|
end
|
40
40
|
|
41
|
+
it "should take 'environment' as an argument" do
|
42
|
+
Puppet::Transaction::Report.new("inspect", "some configuration version", "some environment").environment.should == "some environment"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should be able to set environment" do
|
46
|
+
report = Puppet::Transaction::Report.new("inspect")
|
47
|
+
report.environment = "some environment"
|
48
|
+
report.environment.should == "some environment"
|
49
|
+
end
|
50
|
+
|
41
51
|
it "should not include whits" do
|
42
52
|
Puppet::FileBucket::File.indirection.stubs(:save)
|
43
53
|
|
data/spec/unit/type/cron_spec.rb
CHANGED
@@ -1,490 +1,477 @@
|
|
1
1
|
#!/usr/bin/env rspec
|
2
|
+
|
2
3
|
require 'spec_helper'
|
3
4
|
|
4
5
|
describe Puppet::Type.type(:cron), :unless => Puppet.features.microsoft_windows? do
|
5
6
|
before do
|
6
|
-
@
|
7
|
-
|
8
|
-
|
9
|
-
@provider_class = stub 'provider_class', :ancestors => [], :name => 'fake', :suitable? => true, :supports_parameter? => true
|
10
|
-
@class.stubs(:defaultprovider).returns @provider_class
|
11
|
-
@class.stubs(:provider).returns @provider_class
|
12
|
-
|
13
|
-
@provider = stub 'provider', :class => @provider_class, :clean => nil
|
14
|
-
@provider.stubs(:is_a?).returns false
|
15
|
-
@provider_class.stubs(:new).returns @provider
|
16
|
-
|
17
|
-
@cron = @class.new( :name => "foo" )
|
7
|
+
@provider_class = described_class.provide(:simple) { mk_resource_methods }
|
8
|
+
@provider_class.stubs(:suitable?).returns true
|
9
|
+
described_class.stubs(:defaultprovider).returns @provider_class
|
18
10
|
end
|
19
11
|
|
20
12
|
it "should have :name be its namevar" do
|
21
|
-
|
13
|
+
described_class.key_attributes.should == [:name]
|
22
14
|
end
|
23
15
|
|
24
16
|
describe "when validating attributes" do
|
25
|
-
|
26
17
|
[:name, :provider].each do |param|
|
27
18
|
it "should have a #{param} parameter" do
|
28
|
-
|
19
|
+
described_class.attrtype(param).should == :param
|
29
20
|
end
|
30
21
|
end
|
31
22
|
|
32
23
|
[:command, :special, :minute, :hour, :weekday, :month, :monthday, :environment, :user, :target].each do |property|
|
33
24
|
it "should have a #{property} property" do
|
34
|
-
|
25
|
+
described_class.attrtype(property).should == :property
|
35
26
|
end
|
36
27
|
end
|
37
28
|
|
38
29
|
[:command, :minute, :hour, :weekday, :month, :monthday].each do |cronparam|
|
39
30
|
it "should have #{cronparam} of type CronParam" do
|
40
|
-
|
31
|
+
described_class.attrclass(cronparam).ancestors.should include CronParam
|
41
32
|
end
|
42
33
|
end
|
43
|
-
|
44
34
|
end
|
45
35
|
|
46
36
|
|
47
37
|
describe "when validating attribute" do
|
48
|
-
|
49
38
|
describe "ensure" do
|
50
39
|
it "should support present as a value for ensure" do
|
51
|
-
proc {
|
40
|
+
proc { described_class.new(:name => 'foo', :ensure => :present) }.should_not raise_error
|
52
41
|
end
|
53
42
|
|
54
43
|
it "should support absent as a value for ensure" do
|
55
|
-
proc {
|
44
|
+
proc { described_class.new(:name => 'foo', :ensure => :present) }.should_not raise_error
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not support other values" do
|
48
|
+
proc { described_class.new(:name => 'foo', :ensure => :foo) }.should raise_error(Puppet::Error, /Invalid value/)
|
56
49
|
end
|
57
50
|
end
|
58
51
|
|
59
52
|
describe "minute" do
|
60
|
-
|
61
53
|
it "should support absent" do
|
62
|
-
proc {
|
54
|
+
proc { described_class.new(:name => 'foo', :minute => 'absent') }.should_not raise_error
|
63
55
|
end
|
64
56
|
|
65
57
|
it "should support *" do
|
66
|
-
proc {
|
58
|
+
proc { described_class.new(:name => 'foo', :minute => '*') }.should_not raise_error
|
67
59
|
end
|
68
60
|
|
69
61
|
it "should translate absent to :absent" do
|
70
|
-
|
62
|
+
described_class.new(:name => 'foo', :minute => 'absent')[:minute].should == :absent
|
71
63
|
end
|
72
64
|
|
73
65
|
it "should translate * to :absent" do
|
74
|
-
|
66
|
+
described_class.new(:name => 'foo', :minute => '*')[:minute].should == :absent
|
75
67
|
end
|
76
68
|
|
77
69
|
it "should support valid single values" do
|
78
|
-
proc {
|
79
|
-
proc {
|
80
|
-
proc {
|
70
|
+
proc { described_class.new(:name => 'foo', :minute => '0') }.should_not raise_error
|
71
|
+
proc { described_class.new(:name => 'foo', :minute => '1') }.should_not raise_error
|
72
|
+
proc { described_class.new(:name => 'foo', :minute => '59') }.should_not raise_error
|
81
73
|
end
|
82
74
|
|
83
75
|
it "should not support non numeric characters" do
|
84
|
-
proc {
|
85
|
-
proc {
|
86
|
-
proc {
|
76
|
+
proc { described_class.new(:name => 'foo', :minute => 'z59') }.should raise_error(Puppet::Error, /z59 is not a valid minute/)
|
77
|
+
proc { described_class.new(:name => 'foo', :minute => '5z9') }.should raise_error(Puppet::Error, /5z9 is not a valid minute/)
|
78
|
+
proc { described_class.new(:name => 'foo', :minute => '59z') }.should raise_error(Puppet::Error, /59z is not a valid minute/)
|
87
79
|
end
|
88
80
|
|
89
81
|
it "should not support single values out of range" do
|
90
82
|
|
91
|
-
proc {
|
92
|
-
proc {
|
93
|
-
proc {
|
94
|
-
proc {
|
83
|
+
proc { described_class.new(:name => 'foo', :minute => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid minute/)
|
84
|
+
proc { described_class.new(:name => 'foo', :minute => '60') }.should raise_error(Puppet::Error, /60 is not a valid minute/)
|
85
|
+
proc { described_class.new(:name => 'foo', :minute => '61') }.should raise_error(Puppet::Error, /61 is not a valid minute/)
|
86
|
+
proc { described_class.new(:name => 'foo', :minute => '120') }.should raise_error(Puppet::Error, /120 is not a valid minute/)
|
95
87
|
end
|
96
88
|
|
97
89
|
it "should support valid multiple values" do
|
98
|
-
proc {
|
99
|
-
proc {
|
100
|
-
proc {
|
90
|
+
proc { described_class.new(:name => 'foo', :minute => ['0','1','59'] ) }.should_not raise_error
|
91
|
+
proc { described_class.new(:name => 'foo', :minute => ['40','30','20'] ) }.should_not raise_error
|
92
|
+
proc { described_class.new(:name => 'foo', :minute => ['10','30','20'] ) }.should_not raise_error
|
101
93
|
end
|
102
94
|
|
103
95
|
it "should not support multiple values if at least one is invalid" do
|
104
96
|
# one invalid
|
105
|
-
proc {
|
106
|
-
proc {
|
107
|
-
proc {
|
97
|
+
proc { described_class.new(:name => 'foo', :minute => ['0','1','60'] ) }.should raise_error(Puppet::Error, /60 is not a valid minute/)
|
98
|
+
proc { described_class.new(:name => 'foo', :minute => ['0','120','59'] ) }.should raise_error(Puppet::Error, /120 is not a valid minute/)
|
99
|
+
proc { described_class.new(:name => 'foo', :minute => ['-1','1','59'] ) }.should raise_error(Puppet::Error, /-1 is not a valid minute/)
|
108
100
|
# two invalid
|
109
|
-
proc {
|
101
|
+
proc { described_class.new(:name => 'foo', :minute => ['0','61','62'] ) }.should raise_error(Puppet::Error, /(61|62) is not a valid minute/)
|
110
102
|
# all invalid
|
111
|
-
proc {
|
103
|
+
proc { described_class.new(:name => 'foo', :minute => ['-1','61','62'] ) }.should raise_error(Puppet::Error, /(-1|61|62) is not a valid minute/)
|
112
104
|
end
|
113
105
|
|
114
106
|
it "should support valid step syntax" do
|
115
|
-
proc {
|
116
|
-
proc {
|
107
|
+
proc { described_class.new(:name => 'foo', :minute => '*/2' ) }.should_not raise_error
|
108
|
+
proc { described_class.new(:name => 'foo', :minute => '10-16/2' ) }.should_not raise_error
|
117
109
|
end
|
118
110
|
|
119
111
|
it "should not support invalid steps" do
|
120
|
-
proc {
|
121
|
-
proc {
|
112
|
+
proc { described_class.new(:name => 'foo', :minute => '*/A' ) }.should raise_error(Puppet::Error, /\*\/A is not a valid minute/)
|
113
|
+
proc { described_class.new(:name => 'foo', :minute => '*/2A' ) }.should raise_error(Puppet::Error, /\*\/2A is not a valid minute/)
|
122
114
|
# As it turns out cron does not complaining about steps that exceed the valid range
|
123
|
-
# proc {
|
115
|
+
# proc { described_class.new(:name => 'foo', :minute => '*/120' ) }.should raise_error(Puppet::Error, /is not a valid minute/)
|
124
116
|
end
|
125
|
-
|
126
117
|
end
|
127
118
|
|
128
119
|
describe "hour" do
|
129
|
-
|
130
|
-
|
131
|
-
proc { @class.new(:name => 'foo', :hour => 'absent') }.should_not raise_error
|
120
|
+
it "should support absent" do
|
121
|
+
proc { described_class.new(:name => 'foo', :hour => 'absent') }.should_not raise_error
|
132
122
|
end
|
133
123
|
|
134
124
|
it "should support *" do
|
135
|
-
proc {
|
125
|
+
proc { described_class.new(:name => 'foo', :hour => '*') }.should_not raise_error
|
136
126
|
end
|
137
127
|
|
138
128
|
it "should translate absent to :absent" do
|
139
|
-
|
129
|
+
described_class.new(:name => 'foo', :hour => 'absent')[:hour].should == :absent
|
140
130
|
end
|
141
131
|
|
142
132
|
it "should translate * to :absent" do
|
143
|
-
|
133
|
+
described_class.new(:name => 'foo', :hour => '*')[:hour].should == :absent
|
144
134
|
end
|
145
135
|
|
146
136
|
it "should support valid single values" do
|
147
|
-
proc {
|
148
|
-
proc {
|
149
|
-
proc {
|
150
|
-
proc {
|
151
|
-
proc {
|
137
|
+
proc { described_class.new(:name => 'foo', :hour => '0') }.should_not raise_error
|
138
|
+
proc { described_class.new(:name => 'foo', :hour => '11') }.should_not raise_error
|
139
|
+
proc { described_class.new(:name => 'foo', :hour => '12') }.should_not raise_error
|
140
|
+
proc { described_class.new(:name => 'foo', :hour => '13') }.should_not raise_error
|
141
|
+
proc { described_class.new(:name => 'foo', :hour => '23') }.should_not raise_error
|
152
142
|
end
|
153
143
|
|
154
144
|
it "should not support non numeric characters" do
|
155
|
-
proc {
|
156
|
-
proc {
|
157
|
-
proc {
|
145
|
+
proc { described_class.new(:name => 'foo', :hour => 'z15') }.should raise_error(Puppet::Error, /z15 is not a valid hour/)
|
146
|
+
proc { described_class.new(:name => 'foo', :hour => '1z5') }.should raise_error(Puppet::Error, /1z5 is not a valid hour/)
|
147
|
+
proc { described_class.new(:name => 'foo', :hour => '15z') }.should raise_error(Puppet::Error, /15z is not a valid hour/)
|
158
148
|
end
|
159
149
|
|
160
150
|
it "should not support single values out of range" do
|
161
|
-
proc {
|
162
|
-
proc {
|
163
|
-
proc {
|
151
|
+
proc { described_class.new(:name => 'foo', :hour => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid hour/)
|
152
|
+
proc { described_class.new(:name => 'foo', :hour => '24') }.should raise_error(Puppet::Error, /24 is not a valid hour/)
|
153
|
+
proc { described_class.new(:name => 'foo', :hour => '120') }.should raise_error(Puppet::Error, /120 is not a valid hour/)
|
164
154
|
end
|
165
155
|
|
166
156
|
it "should support valid multiple values" do
|
167
|
-
proc {
|
168
|
-
proc {
|
169
|
-
proc {
|
157
|
+
proc { described_class.new(:name => 'foo', :hour => ['0','1','23'] ) }.should_not raise_error
|
158
|
+
proc { described_class.new(:name => 'foo', :hour => ['5','16','14'] ) }.should_not raise_error
|
159
|
+
proc { described_class.new(:name => 'foo', :hour => ['16','13','9'] ) }.should_not raise_error
|
170
160
|
end
|
171
161
|
|
172
162
|
it "should not support multiple values if at least one is invalid" do
|
173
163
|
# one invalid
|
174
|
-
proc {
|
175
|
-
proc {
|
176
|
-
proc {
|
164
|
+
proc { described_class.new(:name => 'foo', :hour => ['0','1','24'] ) }.should raise_error(Puppet::Error, /24 is not a valid hour/)
|
165
|
+
proc { described_class.new(:name => 'foo', :hour => ['0','-1','5'] ) }.should raise_error(Puppet::Error, /-1 is not a valid hour/)
|
166
|
+
proc { described_class.new(:name => 'foo', :hour => ['-1','1','23'] ) }.should raise_error(Puppet::Error, /-1 is not a valid hour/)
|
177
167
|
# two invalid
|
178
|
-
proc {
|
168
|
+
proc { described_class.new(:name => 'foo', :hour => ['0','25','26'] ) }.should raise_error(Puppet::Error, /(25|26) is not a valid hour/)
|
179
169
|
# all invalid
|
180
|
-
proc {
|
170
|
+
proc { described_class.new(:name => 'foo', :hour => ['-1','24','120'] ) }.should raise_error(Puppet::Error, /(-1|24|120) is not a valid hour/)
|
181
171
|
end
|
182
172
|
|
183
173
|
it "should support valid step syntax" do
|
184
|
-
proc {
|
185
|
-
proc {
|
174
|
+
proc { described_class.new(:name => 'foo', :hour => '*/2' ) }.should_not raise_error
|
175
|
+
proc { described_class.new(:name => 'foo', :hour => '10-18/4' ) }.should_not raise_error
|
186
176
|
end
|
187
177
|
|
188
178
|
it "should not support invalid steps" do
|
189
|
-
proc {
|
190
|
-
proc {
|
179
|
+
proc { described_class.new(:name => 'foo', :hour => '*/A' ) }.should raise_error(Puppet::Error, /\*\/A is not a valid hour/)
|
180
|
+
proc { described_class.new(:name => 'foo', :hour => '*/2A' ) }.should raise_error(Puppet::Error, /\*\/2A is not a valid hour/)
|
191
181
|
# As it turns out cron does not complaining about steps that exceed the valid range
|
192
|
-
# proc {
|
182
|
+
# proc { described_class.new(:name => 'foo', :hour => '*/26' ) }.should raise_error(Puppet::Error, /is not a valid hour/)
|
193
183
|
end
|
194
|
-
|
195
184
|
end
|
196
185
|
|
197
|
-
|
198
|
-
|
186
|
+
describe "weekday" do
|
199
187
|
it "should support absent" do
|
200
|
-
proc {
|
188
|
+
proc { described_class.new(:name => 'foo', :weekday => 'absent') }.should_not raise_error
|
201
189
|
end
|
202
190
|
|
203
191
|
it "should support *" do
|
204
|
-
proc {
|
192
|
+
proc { described_class.new(:name => 'foo', :weekday => '*') }.should_not raise_error
|
205
193
|
end
|
206
194
|
|
207
195
|
it "should translate absent to :absent" do
|
208
|
-
|
196
|
+
described_class.new(:name => 'foo', :weekday => 'absent')[:weekday].should == :absent
|
209
197
|
end
|
210
198
|
|
211
199
|
it "should translate * to :absent" do
|
212
|
-
|
200
|
+
described_class.new(:name => 'foo', :weekday => '*')[:weekday].should == :absent
|
213
201
|
end
|
214
202
|
|
215
203
|
it "should support valid numeric weekdays" do
|
216
|
-
proc {
|
217
|
-
proc {
|
218
|
-
proc {
|
204
|
+
proc { described_class.new(:name => 'foo', :weekday => '0') }.should_not raise_error
|
205
|
+
proc { described_class.new(:name => 'foo', :weekday => '1') }.should_not raise_error
|
206
|
+
proc { described_class.new(:name => 'foo', :weekday => '6') }.should_not raise_error
|
219
207
|
# According to http://www.manpagez.com/man/5/crontab 7 is also valid (Sunday)
|
220
|
-
proc {
|
208
|
+
proc { described_class.new(:name => 'foo', :weekday => '7') }.should_not raise_error
|
221
209
|
end
|
222
210
|
|
223
|
-
it "should support valid weekdays as words (
|
224
|
-
proc {
|
225
|
-
proc {
|
226
|
-
proc {
|
227
|
-
proc {
|
228
|
-
proc {
|
229
|
-
proc {
|
230
|
-
proc {
|
211
|
+
it "should support valid weekdays as words (long version)" do
|
212
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Monday') }.should_not raise_error
|
213
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Tuesday') }.should_not raise_error
|
214
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Wednesday') }.should_not raise_error
|
215
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Thursday') }.should_not raise_error
|
216
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Friday') }.should_not raise_error
|
217
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Saturday') }.should_not raise_error
|
218
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Sunday') }.should_not raise_error
|
231
219
|
end
|
232
220
|
|
233
221
|
it "should support valid weekdays as words (3 character version)" do
|
234
|
-
proc {
|
235
|
-
proc {
|
236
|
-
proc {
|
237
|
-
proc {
|
238
|
-
proc {
|
239
|
-
proc {
|
240
|
-
proc {
|
222
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Mon') }.should_not raise_error
|
223
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Tue') }.should_not raise_error
|
224
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Wed') }.should_not raise_error
|
225
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Thu') }.should_not raise_error
|
226
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Fri') }.should_not raise_error
|
227
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Sat') }.should_not raise_error
|
228
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Sun') }.should_not raise_error
|
241
229
|
end
|
242
230
|
|
243
231
|
it "should not support numeric values out of range" do
|
244
|
-
proc {
|
245
|
-
proc {
|
232
|
+
proc { described_class.new(:name => 'foo', :weekday => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid weekday/)
|
233
|
+
proc { described_class.new(:name => 'foo', :weekday => '8') }.should raise_error(Puppet::Error, /8 is not a valid weekday/)
|
246
234
|
end
|
247
235
|
|
248
236
|
it "should not support invalid weekday names" do
|
249
|
-
proc {
|
237
|
+
proc { described_class.new(:name => 'foo', :weekday => 'Sar') }.should raise_error(Puppet::Error, /Sar is not a valid weekday/)
|
250
238
|
end
|
251
239
|
|
252
240
|
it "should support valid multiple values" do
|
253
|
-
proc {
|
254
|
-
proc {
|
241
|
+
proc { described_class.new(:name => 'foo', :weekday => ['0','1','6'] ) }.should_not raise_error
|
242
|
+
proc { described_class.new(:name => 'foo', :weekday => ['Mon','Wed','Friday'] ) }.should_not raise_error
|
255
243
|
end
|
256
244
|
|
257
245
|
it "should not support multiple values if at least one is invalid" do
|
258
246
|
# one invalid
|
259
|
-
proc {
|
260
|
-
proc {
|
247
|
+
proc { described_class.new(:name => 'foo', :weekday => ['0','1','8'] ) }.should raise_error(Puppet::Error, /8 is not a valid weekday/)
|
248
|
+
proc { described_class.new(:name => 'foo', :weekday => ['Mon','Fii','Sat'] ) }.should raise_error(Puppet::Error, /Fii is not a valid weekday/)
|
261
249
|
# two invalid
|
262
|
-
proc {
|
250
|
+
proc { described_class.new(:name => 'foo', :weekday => ['Mos','Fii','Sat'] ) }.should raise_error(Puppet::Error, /(Mos|Fii) is not a valid weekday/)
|
263
251
|
# all invalid
|
264
|
-
proc {
|
265
|
-
proc {
|
252
|
+
proc { described_class.new(:name => 'foo', :weekday => ['Mos','Fii','Saa'] ) }.should raise_error(Puppet::Error, /(Mos|Fii|Saa) is not a valid weekday/)
|
253
|
+
proc { described_class.new(:name => 'foo', :weekday => ['-1','8','11'] ) }.should raise_error(Puppet::Error, /(-1|8|11) is not a valid weekday/)
|
266
254
|
end
|
267
255
|
|
268
256
|
it "should support valid step syntax" do
|
269
|
-
proc {
|
270
|
-
proc {
|
257
|
+
proc { described_class.new(:name => 'foo', :weekday => '*/2' ) }.should_not raise_error
|
258
|
+
proc { described_class.new(:name => 'foo', :weekday => '0-4/2' ) }.should_not raise_error
|
271
259
|
end
|
272
260
|
|
273
261
|
it "should not support invalid steps" do
|
274
|
-
proc {
|
275
|
-
proc {
|
262
|
+
proc { described_class.new(:name => 'foo', :weekday => '*/A' ) }.should raise_error(Puppet::Error, /\*\/A is not a valid weekday/)
|
263
|
+
proc { described_class.new(:name => 'foo', :weekday => '*/2A' ) }.should raise_error(Puppet::Error, /\*\/2A is not a valid weekday/)
|
276
264
|
# As it turns out cron does not complaining about steps that exceed the valid range
|
277
|
-
# proc {
|
265
|
+
# proc { described_class.new(:name => 'foo', :weekday => '*/9' ) }.should raise_error(Puppet::Error, /is not a valid weekday/)
|
278
266
|
end
|
279
|
-
|
280
267
|
end
|
281
268
|
|
282
269
|
describe "month" do
|
283
|
-
|
284
270
|
it "should support absent" do
|
285
|
-
proc {
|
271
|
+
proc { described_class.new(:name => 'foo', :month => 'absent') }.should_not raise_error
|
286
272
|
end
|
287
273
|
|
288
274
|
it "should support *" do
|
289
|
-
proc {
|
275
|
+
proc { described_class.new(:name => 'foo', :month => '*') }.should_not raise_error
|
290
276
|
end
|
291
277
|
|
292
278
|
it "should translate absent to :absent" do
|
293
|
-
|
279
|
+
described_class.new(:name => 'foo', :month => 'absent')[:month].should == :absent
|
294
280
|
end
|
295
281
|
|
296
282
|
it "should translate * to :absent" do
|
297
|
-
|
283
|
+
described_class.new(:name => 'foo', :month => '*')[:month].should == :absent
|
298
284
|
end
|
299
285
|
|
300
286
|
it "should support valid numeric values" do
|
301
|
-
proc {
|
302
|
-
proc {
|
287
|
+
proc { described_class.new(:name => 'foo', :month => '1') }.should_not raise_error
|
288
|
+
proc { described_class.new(:name => 'foo', :month => '12') }.should_not raise_error
|
303
289
|
end
|
304
290
|
|
305
291
|
it "should support valid months as words" do
|
306
|
-
proc {
|
307
|
-
proc {
|
308
|
-
proc {
|
309
|
-
proc {
|
310
|
-
proc {
|
311
|
-
proc {
|
312
|
-
proc {
|
313
|
-
proc {
|
314
|
-
proc {
|
315
|
-
proc {
|
316
|
-
proc {
|
317
|
-
proc {
|
292
|
+
proc { described_class.new(:name => 'foo', :month => 'January') }.should_not raise_error
|
293
|
+
proc { described_class.new(:name => 'foo', :month => 'February') }.should_not raise_error
|
294
|
+
proc { described_class.new(:name => 'foo', :month => 'March') }.should_not raise_error
|
295
|
+
proc { described_class.new(:name => 'foo', :month => 'April') }.should_not raise_error
|
296
|
+
proc { described_class.new(:name => 'foo', :month => 'May') }.should_not raise_error
|
297
|
+
proc { described_class.new(:name => 'foo', :month => 'June') }.should_not raise_error
|
298
|
+
proc { described_class.new(:name => 'foo', :month => 'July') }.should_not raise_error
|
299
|
+
proc { described_class.new(:name => 'foo', :month => 'August') }.should_not raise_error
|
300
|
+
proc { described_class.new(:name => 'foo', :month => 'September') }.should_not raise_error
|
301
|
+
proc { described_class.new(:name => 'foo', :month => 'October') }.should_not raise_error
|
302
|
+
proc { described_class.new(:name => 'foo', :month => 'November') }.should_not raise_error
|
303
|
+
proc { described_class.new(:name => 'foo', :month => 'December') }.should_not raise_error
|
318
304
|
end
|
319
305
|
|
320
306
|
it "should support valid months as words (3 character short version)" do
|
321
|
-
proc {
|
322
|
-
proc {
|
323
|
-
proc {
|
324
|
-
proc {
|
325
|
-
proc {
|
326
|
-
proc {
|
327
|
-
proc {
|
328
|
-
proc {
|
329
|
-
proc {
|
330
|
-
proc {
|
331
|
-
proc {
|
332
|
-
proc {
|
307
|
+
proc { described_class.new(:name => 'foo', :month => 'Jan') }.should_not raise_error
|
308
|
+
proc { described_class.new(:name => 'foo', :month => 'Feb') }.should_not raise_error
|
309
|
+
proc { described_class.new(:name => 'foo', :month => 'Mar') }.should_not raise_error
|
310
|
+
proc { described_class.new(:name => 'foo', :month => 'Apr') }.should_not raise_error
|
311
|
+
proc { described_class.new(:name => 'foo', :month => 'May') }.should_not raise_error
|
312
|
+
proc { described_class.new(:name => 'foo', :month => 'Jun') }.should_not raise_error
|
313
|
+
proc { described_class.new(:name => 'foo', :month => 'Jul') }.should_not raise_error
|
314
|
+
proc { described_class.new(:name => 'foo', :month => 'Aug') }.should_not raise_error
|
315
|
+
proc { described_class.new(:name => 'foo', :month => 'Sep') }.should_not raise_error
|
316
|
+
proc { described_class.new(:name => 'foo', :month => 'Oct') }.should_not raise_error
|
317
|
+
proc { described_class.new(:name => 'foo', :month => 'Nov') }.should_not raise_error
|
318
|
+
proc { described_class.new(:name => 'foo', :month => 'Dec') }.should_not raise_error
|
333
319
|
end
|
334
320
|
|
335
321
|
it "should not support numeric values out of range" do
|
336
|
-
proc {
|
337
|
-
proc {
|
338
|
-
proc {
|
322
|
+
proc { described_class.new(:name => 'foo', :month => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid month/)
|
323
|
+
proc { described_class.new(:name => 'foo', :month => '0') }.should raise_error(Puppet::Error, /0 is not a valid month/)
|
324
|
+
proc { described_class.new(:name => 'foo', :month => '13') }.should raise_error(Puppet::Error, /13 is not a valid month/)
|
339
325
|
end
|
340
326
|
|
341
327
|
it "should not support words that are not valid months" do
|
342
|
-
proc {
|
328
|
+
proc { described_class.new(:name => 'foo', :month => 'Jal') }.should raise_error(Puppet::Error, /Jal is not a valid month/)
|
343
329
|
end
|
344
330
|
|
345
331
|
it "should not support single values out of range" do
|
346
332
|
|
347
|
-
proc {
|
348
|
-
proc {
|
349
|
-
proc {
|
350
|
-
proc {
|
333
|
+
proc { described_class.new(:name => 'foo', :month => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid month/)
|
334
|
+
proc { described_class.new(:name => 'foo', :month => '60') }.should raise_error(Puppet::Error, /60 is not a valid month/)
|
335
|
+
proc { described_class.new(:name => 'foo', :month => '61') }.should raise_error(Puppet::Error, /61 is not a valid month/)
|
336
|
+
proc { described_class.new(:name => 'foo', :month => '120') }.should raise_error(Puppet::Error, /120 is not a valid month/)
|
351
337
|
end
|
352
338
|
|
353
339
|
it "should support valid multiple values" do
|
354
|
-
proc {
|
355
|
-
proc {
|
340
|
+
proc { described_class.new(:name => 'foo', :month => ['1','9','12'] ) }.should_not raise_error
|
341
|
+
proc { described_class.new(:name => 'foo', :month => ['Jan','March','Jul'] ) }.should_not raise_error
|
356
342
|
end
|
357
343
|
|
358
344
|
it "should not support multiple values if at least one is invalid" do
|
359
345
|
# one invalid
|
360
|
-
proc {
|
361
|
-
proc {
|
362
|
-
proc {
|
346
|
+
proc { described_class.new(:name => 'foo', :month => ['0','1','12'] ) }.should raise_error(Puppet::Error, /0 is not a valid month/)
|
347
|
+
proc { described_class.new(:name => 'foo', :month => ['1','13','10'] ) }.should raise_error(Puppet::Error, /13 is not a valid month/)
|
348
|
+
proc { described_class.new(:name => 'foo', :month => ['Jan','Feb','Jxx'] ) }.should raise_error(Puppet::Error, /Jxx is not a valid month/)
|
363
349
|
# two invalid
|
364
|
-
proc {
|
350
|
+
proc { described_class.new(:name => 'foo', :month => ['Jan','Fex','Jux'] ) }.should raise_error(Puppet::Error, /(Fex|Jux) is not a valid month/)
|
365
351
|
# all invalid
|
366
|
-
proc {
|
367
|
-
proc {
|
352
|
+
proc { described_class.new(:name => 'foo', :month => ['-1','0','13'] ) }.should raise_error(Puppet::Error, /(-1|0|13) is not a valid month/)
|
353
|
+
proc { described_class.new(:name => 'foo', :month => ['Jax','Fex','Aux'] ) }.should raise_error(Puppet::Error, /(Jax|Fex|Aux) is not a valid month/)
|
368
354
|
end
|
369
355
|
|
370
356
|
it "should support valid step syntax" do
|
371
|
-
proc {
|
372
|
-
proc {
|
357
|
+
proc { described_class.new(:name => 'foo', :month => '*/2' ) }.should_not raise_error
|
358
|
+
proc { described_class.new(:name => 'foo', :month => '1-12/3' ) }.should_not raise_error
|
373
359
|
end
|
374
360
|
|
375
361
|
it "should not support invalid steps" do
|
376
|
-
proc {
|
377
|
-
proc {
|
362
|
+
proc { described_class.new(:name => 'foo', :month => '*/A' ) }.should raise_error(Puppet::Error, /\*\/A is not a valid month/)
|
363
|
+
proc { described_class.new(:name => 'foo', :month => '*/2A' ) }.should raise_error(Puppet::Error, /\*\/2A is not a valid month/)
|
378
364
|
# As it turns out cron does not complaining about steps that exceed the valid range
|
379
|
-
# proc {
|
365
|
+
# proc { described_class.new(:name => 'foo', :month => '*/13' ) }.should raise_error(Puppet::Error, /is not a valid month/)
|
380
366
|
end
|
381
|
-
|
382
367
|
end
|
383
368
|
|
384
369
|
describe "monthday" do
|
385
|
-
|
386
370
|
it "should support absent" do
|
387
|
-
proc {
|
371
|
+
proc { described_class.new(:name => 'foo', :monthday => 'absent') }.should_not raise_error
|
388
372
|
end
|
389
373
|
|
390
374
|
it "should support *" do
|
391
|
-
proc {
|
375
|
+
proc { described_class.new(:name => 'foo', :monthday => '*') }.should_not raise_error
|
392
376
|
end
|
393
377
|
|
394
378
|
it "should translate absent to :absent" do
|
395
|
-
|
379
|
+
described_class.new(:name => 'foo', :monthday => 'absent')[:monthday].should == :absent
|
396
380
|
end
|
397
381
|
|
398
382
|
it "should translate * to :absent" do
|
399
|
-
|
383
|
+
described_class.new(:name => 'foo', :monthday => '*')[:monthday].should == :absent
|
400
384
|
end
|
401
385
|
|
402
386
|
it "should support valid single values" do
|
403
|
-
proc {
|
404
|
-
proc {
|
405
|
-
proc {
|
387
|
+
proc { described_class.new(:name => 'foo', :monthday => '1') }.should_not raise_error
|
388
|
+
proc { described_class.new(:name => 'foo', :monthday => '30') }.should_not raise_error
|
389
|
+
proc { described_class.new(:name => 'foo', :monthday => '31') }.should_not raise_error
|
406
390
|
end
|
407
391
|
|
408
392
|
it "should not support non numeric characters" do
|
409
|
-
proc {
|
410
|
-
proc {
|
411
|
-
proc {
|
393
|
+
proc { described_class.new(:name => 'foo', :monthday => 'z23') }.should raise_error(Puppet::Error, /z23 is not a valid monthday/)
|
394
|
+
proc { described_class.new(:name => 'foo', :monthday => '2z3') }.should raise_error(Puppet::Error, /2z3 is not a valid monthday/)
|
395
|
+
proc { described_class.new(:name => 'foo', :monthday => '23z') }.should raise_error(Puppet::Error, /23z is not a valid monthday/)
|
412
396
|
end
|
413
397
|
|
414
398
|
it "should not support single values out of range" do
|
415
|
-
proc {
|
416
|
-
proc {
|
417
|
-
proc {
|
399
|
+
proc { described_class.new(:name => 'foo', :monthday => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid monthday/)
|
400
|
+
proc { described_class.new(:name => 'foo', :monthday => '0') }.should raise_error(Puppet::Error, /0 is not a valid monthday/)
|
401
|
+
proc { described_class.new(:name => 'foo', :monthday => '32') }.should raise_error(Puppet::Error, /32 is not a valid monthday/)
|
418
402
|
end
|
419
403
|
|
420
404
|
it "should support valid multiple values" do
|
421
|
-
proc {
|
422
|
-
proc {
|
423
|
-
proc {
|
405
|
+
proc { described_class.new(:name => 'foo', :monthday => ['1','23','31'] ) }.should_not raise_error
|
406
|
+
proc { described_class.new(:name => 'foo', :monthday => ['31','23','1'] ) }.should_not raise_error
|
407
|
+
proc { described_class.new(:name => 'foo', :monthday => ['1','31','23'] ) }.should_not raise_error
|
424
408
|
end
|
425
409
|
|
426
410
|
it "should not support multiple values if at least one is invalid" do
|
427
411
|
# one invalid
|
428
|
-
proc {
|
429
|
-
proc {
|
430
|
-
proc {
|
412
|
+
proc { described_class.new(:name => 'foo', :monthday => ['1','23','32'] ) }.should raise_error(Puppet::Error, /32 is not a valid monthday/)
|
413
|
+
proc { described_class.new(:name => 'foo', :monthday => ['-1','12','23'] ) }.should raise_error(Puppet::Error, /-1 is not a valid monthday/)
|
414
|
+
proc { described_class.new(:name => 'foo', :monthday => ['13','32','30'] ) }.should raise_error(Puppet::Error, /32 is not a valid monthday/)
|
431
415
|
# two invalid
|
432
|
-
proc {
|
416
|
+
proc { described_class.new(:name => 'foo', :monthday => ['-1','0','23'] ) }.should raise_error(Puppet::Error, /(-1|0) is not a valid monthday/)
|
433
417
|
# all invalid
|
434
|
-
proc {
|
418
|
+
proc { described_class.new(:name => 'foo', :monthday => ['-1','0','32'] ) }.should raise_error(Puppet::Error, /(-1|0|32) is not a valid monthday/)
|
435
419
|
end
|
436
420
|
|
437
421
|
it "should support valid step syntax" do
|
438
|
-
proc {
|
439
|
-
proc {
|
422
|
+
proc { described_class.new(:name => 'foo', :monthday => '*/2' ) }.should_not raise_error
|
423
|
+
proc { described_class.new(:name => 'foo', :monthday => '10-16/2' ) }.should_not raise_error
|
440
424
|
end
|
441
425
|
|
442
426
|
it "should not support invalid steps" do
|
443
|
-
proc {
|
444
|
-
proc {
|
427
|
+
proc { described_class.new(:name => 'foo', :monthday => '*/A' ) }.should raise_error(Puppet::Error, /\*\/A is not a valid monthday/)
|
428
|
+
proc { described_class.new(:name => 'foo', :monthday => '*/2A' ) }.should raise_error(Puppet::Error, /\*\/2A is not a valid monthday/)
|
445
429
|
# As it turns out cron does not complaining about steps that exceed the valid range
|
446
|
-
# proc {
|
430
|
+
# proc { described_class.new(:name => 'foo', :monthday => '*/32' ) }.should raise_error(Puppet::Error, /is not a valid monthday/)
|
447
431
|
end
|
448
|
-
|
449
432
|
end
|
450
433
|
|
451
434
|
describe "environment" do
|
452
|
-
|
453
435
|
it "it should accept an :environment that looks like a path" do
|
454
436
|
lambda do
|
455
|
-
|
437
|
+
described_class.new(:name => 'foo',:environment => 'PATH=/bin:/usr/bin:/usr/sbin')
|
456
438
|
end.should_not raise_error
|
457
439
|
end
|
458
440
|
|
459
441
|
it "should not accept environment variables that do not contain '='" do
|
460
442
|
lambda do
|
461
|
-
|
462
|
-
end.should raise_error(Puppet::Error)
|
443
|
+
described_class.new(:name => 'foo',:environment => 'INVALID')
|
444
|
+
end.should raise_error(Puppet::Error, /Invalid environment setting "INVALID"/)
|
463
445
|
end
|
464
446
|
|
465
447
|
it "should accept empty environment variables that do not contain '='" do
|
466
448
|
lambda do
|
467
|
-
|
449
|
+
described_class.new(:name => 'foo',:environment => 'MAILTO=')
|
468
450
|
end.should_not raise_error(Puppet::Error)
|
469
451
|
end
|
470
452
|
|
471
453
|
it "should accept 'absent'" do
|
472
454
|
lambda do
|
473
|
-
|
455
|
+
described_class.new(:name => 'foo',:environment => 'absent')
|
474
456
|
end.should_not raise_error(Puppet::Error)
|
475
457
|
end
|
476
458
|
|
477
459
|
end
|
478
|
-
|
479
460
|
end
|
480
461
|
|
481
462
|
it "should require a command when adding an entry" do
|
482
|
-
entry =
|
483
|
-
expect { entry.value(:command) }.should raise_error(/No command/)
|
463
|
+
entry = described_class.new(:name => "test_entry", :ensure => :present)
|
464
|
+
expect { entry.value(:command) }.should raise_error(Puppet::Error, /No command/)
|
484
465
|
end
|
485
466
|
|
486
467
|
it "should not require a command when removing an entry" do
|
487
|
-
entry =
|
468
|
+
entry = described_class.new(:name => "test_entry", :ensure => :absent)
|
488
469
|
entry.value(:command).should == nil
|
489
470
|
end
|
471
|
+
|
472
|
+
it "should default to user => root if Etc.getpwuid(Process.uid) returns nil (#12357)" do
|
473
|
+
Etc.expects(:getpwuid).returns(nil)
|
474
|
+
entry = described_class.new(:name => "test_entry", :ensure => :present)
|
475
|
+
entry.value(:user).should eql "root"
|
476
|
+
end
|
490
477
|
end
|