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
@@ -19,19 +19,19 @@ describe provider_class do
|
|
19
19
|
describe "exists? method" do
|
20
20
|
it "should find a module if it is already loaded" do
|
21
21
|
@provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
|
22
|
-
@provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields
|
22
|
+
@provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields "bar\t1.2.3\nfoo\t4.4.4\nbang\t1.0.0\n"
|
23
23
|
@provider.exists?.should == :true
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should return nil if not loaded" do
|
27
27
|
@provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
|
28
|
-
@provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields
|
28
|
+
@provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields "bar\t1.2.3\nbang\t1.0.0\n"
|
29
29
|
@provider.exists?.should be_nil
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should return nil if no modules are loaded" do
|
33
33
|
@provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
|
34
|
-
@provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields
|
34
|
+
@provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields ""
|
35
35
|
@provider.exists?.should be_nil
|
36
36
|
end
|
37
37
|
end
|
@@ -7,6 +7,8 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
7
7
|
let (:joblabel) { "com.foo.food" }
|
8
8
|
let (:provider) { subject.class }
|
9
9
|
let (:launchd_overrides) { '/var/db/launchd.db/com.apple.launchd/overrides.plist' }
|
10
|
+
let(:resource) { Puppet::Type.type(:service).new(:name => joblabel) }
|
11
|
+
subject { Puppet::Type.type(:service).provider(:launchd).new(resource) }
|
10
12
|
|
11
13
|
describe "the type interface" do
|
12
14
|
%w{ start stop enabled? enable disable status}.each do |method|
|
@@ -39,18 +41,15 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
39
41
|
it "should return true in if the job plist says disabled is false" do
|
40
42
|
subject.expects(:has_macosx_plist_overrides?).returns(false)
|
41
43
|
subject.expects(:plist_from_label).with(joblabel).returns(["foo", {"Disabled" => false}])
|
42
|
-
subject.expects(:resource).returns({:name => joblabel})
|
43
44
|
subject.enabled?.should == :true
|
44
45
|
end
|
45
46
|
it "should return true in if the job plist has no disabled key" do
|
46
47
|
subject.expects(:has_macosx_plist_overrides?).returns(false)
|
47
|
-
subject.expects(:resource).returns({:name => joblabel})
|
48
48
|
subject.expects(:plist_from_label).returns(["foo", {}])
|
49
49
|
subject.enabled?.should == :true
|
50
50
|
end
|
51
51
|
it "should return false in if the job plist says disabled is true" do
|
52
52
|
subject.expects(:has_macosx_plist_overrides?).returns(false)
|
53
|
-
subject.expects(:resource).returns({:name => joblabel})
|
54
53
|
subject.expects(:plist_from_label).returns(["foo", {"Disabled" => true}])
|
55
54
|
subject.enabled?.should == :false
|
56
55
|
end
|
@@ -62,7 +61,6 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
62
61
|
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => true}])
|
63
62
|
provider.expects(:read_plist).returns({joblabel => {"Disabled" => false}})
|
64
63
|
FileTest.expects(:file?).with(launchd_overrides).returns(true)
|
65
|
-
subject.stubs(:resource).returns({:name => joblabel})
|
66
64
|
subject.enabled?.should == :true
|
67
65
|
end
|
68
66
|
it "should return false if the job plist says disabled is false and the global overrides says disabled is true" do
|
@@ -70,7 +68,6 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
70
68
|
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => false}])
|
71
69
|
provider.expects(:read_plist).returns({joblabel => {"Disabled" => true}})
|
72
70
|
FileTest.expects(:file?).with(launchd_overrides).returns(true)
|
73
|
-
subject.stubs(:resource).returns({:name => joblabel})
|
74
71
|
subject.enabled?.should == :false
|
75
72
|
end
|
76
73
|
it "should return true if the job plist and the global overrides have no disabled keys" do
|
@@ -78,38 +75,40 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
78
75
|
subject.expects(:plist_from_label).returns([joblabel, {}])
|
79
76
|
provider.expects(:read_plist).returns({})
|
80
77
|
FileTest.expects(:file?).with(launchd_overrides).returns(true)
|
81
|
-
subject.stubs(:resource).returns({:name => joblabel})
|
82
78
|
subject.enabled?.should == :true
|
83
79
|
end
|
84
80
|
end
|
85
81
|
|
86
82
|
describe "when starting the service" do
|
83
|
+
it "should call any explicit 'start' command" do
|
84
|
+
resource[:start] = "/bin/false"
|
85
|
+
subject.expects(:texecute).with(:start, ["/bin/false"], true)
|
86
|
+
subject.start
|
87
|
+
end
|
88
|
+
|
87
89
|
it "should look for the relevant plist once" do
|
88
90
|
subject.expects(:plist_from_label).returns([joblabel, {}]).once
|
89
91
|
subject.expects(:enabled?).returns :true
|
90
92
|
subject.expects(:execute).with([:launchctl, :load, joblabel])
|
91
|
-
subject.stubs(:resource).returns({:name => joblabel})
|
92
93
|
subject.start
|
93
94
|
end
|
94
95
|
it "should execute 'launchctl load' once without writing to the plist if the job is enabled" do
|
95
96
|
subject.expects(:plist_from_label).returns([joblabel, {}])
|
96
97
|
subject.expects(:enabled?).returns :true
|
97
98
|
subject.expects(:execute).with([:launchctl, :load, joblabel]).once
|
98
|
-
subject.stubs(:resource).returns({:name => joblabel})
|
99
99
|
subject.start
|
100
100
|
end
|
101
101
|
it "should execute 'launchctl load' with writing to the plist once if the job is disabled" do
|
102
102
|
subject.expects(:plist_from_label).returns([joblabel, {}])
|
103
103
|
subject.expects(:enabled?).returns(:false)
|
104
|
-
subject.stubs(:resource).returns({:name => joblabel})
|
105
104
|
subject.expects(:execute).with([:launchctl, :load, "-w", joblabel]).once
|
106
105
|
subject.start
|
107
106
|
end
|
108
107
|
it "should disable the job once if the job is disabled and should be disabled at boot" do
|
108
|
+
resource[:enable] = false
|
109
109
|
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => true}])
|
110
110
|
subject.expects(:enabled?).returns :false
|
111
111
|
subject.expects(:execute).with([:launchctl, :load, "-w", joblabel])
|
112
|
-
subject.stubs(:resource).returns({:name => joblabel, :enable => :false})
|
113
112
|
subject.expects(:disable).once
|
114
113
|
subject.start
|
115
114
|
end
|
@@ -117,39 +116,41 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
117
116
|
subject.expects(:plist_from_label).returns([joblabel, {}])
|
118
117
|
subject.expects(:enabled?).returns(:true)
|
119
118
|
subject.expects(:status).returns(:stopped)
|
120
|
-
subject.expects(:resource).returns({:name => joblabel}).twice
|
121
119
|
subject.expects(:execute).with([:launchctl, :load, '-w', joblabel])
|
122
120
|
subject.start
|
123
121
|
end
|
124
122
|
end
|
125
123
|
|
126
124
|
describe "when stopping the service" do
|
125
|
+
it "should call any explicit 'stop' command" do
|
126
|
+
resource[:stop] = "/bin/false"
|
127
|
+
subject.expects(:texecute).with(:stop, ["/bin/false"], true)
|
128
|
+
subject.stop
|
129
|
+
end
|
130
|
+
|
127
131
|
it "should look for the relevant plist once" do
|
128
132
|
subject.expects(:plist_from_label).returns([joblabel, {}]).once
|
129
133
|
subject.expects(:enabled?).returns :true
|
130
134
|
subject.expects(:execute).with([:launchctl, :unload, '-w', joblabel])
|
131
|
-
subject.stubs(:resource).returns({:name => joblabel})
|
132
135
|
subject.stop
|
133
136
|
end
|
134
137
|
it "should execute 'launchctl unload' once without writing to the plist if the job is disabled" do
|
135
138
|
subject.expects(:plist_from_label).returns([joblabel, {}])
|
136
139
|
subject.expects(:enabled?).returns :false
|
137
140
|
subject.expects(:execute).with([:launchctl, :unload, joblabel]).once
|
138
|
-
subject.stubs(:resource).returns({:name => joblabel})
|
139
141
|
subject.stop
|
140
142
|
end
|
141
143
|
it "should execute 'launchctl unload' with writing to the plist once if the job is enabled" do
|
142
144
|
subject.expects(:plist_from_label).returns([joblabel, {}])
|
143
145
|
subject.expects(:enabled?).returns :true
|
144
146
|
subject.expects(:execute).with([:launchctl, :unload, '-w', joblabel]).once
|
145
|
-
subject.stubs(:resource).returns({:name => joblabel})
|
146
147
|
subject.stop
|
147
148
|
end
|
148
149
|
it "should enable the job once if the job is enabled and should be enabled at boot" do
|
150
|
+
resource[:enable] = true
|
149
151
|
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => false}])
|
150
152
|
subject.expects(:enabled?).returns :true
|
151
153
|
subject.expects(:execute).with([:launchctl, :unload, "-w", joblabel])
|
152
|
-
subject.stubs(:resource).returns({:name => joblabel, :enable => :true})
|
153
154
|
subject.expects(:enable).once
|
154
155
|
subject.stop
|
155
156
|
end
|
@@ -157,47 +158,47 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
157
158
|
|
158
159
|
describe "when enabling the service" do
|
159
160
|
it "should look for the relevant plist once" do ### Do we need this test? Differentiating it?
|
161
|
+
resource[:enable] = true
|
160
162
|
subject.expects(:plist_from_label).returns([joblabel, {}]).once
|
161
163
|
subject.expects(:enabled?).returns :false
|
162
164
|
subject.expects(:execute).with([:launchctl, :unload, joblabel])
|
163
|
-
subject.stubs(:resource).returns({:name => joblabel, :enable => :true})
|
164
165
|
subject.stop
|
165
166
|
end
|
166
167
|
it "should check if the job is enabled once" do
|
168
|
+
resource[:enable] = true
|
167
169
|
subject.expects(:plist_from_label).returns([joblabel, {}]).once
|
168
170
|
subject.expects(:enabled?).once
|
169
171
|
subject.expects(:execute).with([:launchctl, :unload, joblabel])
|
170
|
-
subject.stubs(:resource).returns({:name => joblabel, :enable => :true})
|
171
172
|
subject.stop
|
172
173
|
end
|
173
174
|
end
|
174
175
|
|
175
176
|
describe "when disabling the service" do
|
176
177
|
it "should look for the relevant plist once" do
|
178
|
+
resource[:enable] = false
|
177
179
|
subject.expects(:plist_from_label).returns([joblabel, {}]).once
|
178
180
|
subject.expects(:enabled?).returns :true
|
179
181
|
subject.expects(:execute).with([:launchctl, :unload, '-w', joblabel])
|
180
|
-
subject.stubs(:resource).returns({:name => joblabel, :enable => :false})
|
181
182
|
subject.stop
|
182
183
|
end
|
183
184
|
end
|
184
185
|
|
185
186
|
describe "when enabling the service on OS X 10.6" do
|
186
187
|
it "should write to the global launchd overrides file once" do
|
188
|
+
resource[:enable] = true
|
187
189
|
provider.expects(:get_macosx_version_major).returns("10.6")
|
188
190
|
provider.expects(:read_plist).returns({})
|
189
191
|
Plist::Emit.expects(:save_plist).once
|
190
|
-
subject.stubs(:resource).returns({:name => joblabel, :enable => :true})
|
191
192
|
subject.enable
|
192
193
|
end
|
193
194
|
end
|
194
195
|
|
195
196
|
describe "when disabling the service on OS X 10.6" do
|
196
197
|
it "should write to the global launchd overrides file once" do
|
198
|
+
resource[:enable] = false
|
197
199
|
provider.stubs(:get_macosx_version_major).returns("10.6")
|
198
200
|
provider.stubs(:read_plist).returns({})
|
199
201
|
Plist::Emit.expects(:save_plist).once
|
200
|
-
subject.stubs(:resource).returns({:name => joblabel, :enable => :false})
|
201
202
|
subject.enable
|
202
203
|
end
|
203
204
|
end
|
@@ -207,6 +208,7 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
207
208
|
provider.instance_variable_set(:@macosx_version_major, nil)
|
208
209
|
end
|
209
210
|
it "should display a deprecation warning" do
|
211
|
+
resource[:enable] = true
|
210
212
|
Facter.expects(:value).with(:macosx_productversion_major).returns(nil)
|
211
213
|
Facter.expects(:value).with(:macosx_productversion).returns('10.5.8')
|
212
214
|
Facter.expects(:loadfacts)
|
@@ -214,7 +216,6 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
214
216
|
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => false}])
|
215
217
|
subject.expects(:enabled?).returns :false
|
216
218
|
File.expects(:open).returns('')
|
217
|
-
subject.stubs(:resource).returns({:name => joblabel, :enable => :true})
|
218
219
|
subject.enable
|
219
220
|
end
|
220
221
|
end
|
@@ -6,13 +6,13 @@ provider_class = Puppet::Type.type(:service).provider(:upstart)
|
|
6
6
|
describe provider_class do
|
7
7
|
describe "#instances" do
|
8
8
|
it "should be able to find all instances" do
|
9
|
-
processes = ["rc stop/waiting", "ssh start/running, process 712"]
|
9
|
+
processes = ["rc stop/waiting", "ssh start/running, process 712"].join("\n")
|
10
10
|
provider_class.stubs(:execpipe).yields(processes)
|
11
11
|
provider_class.instances.map {|provider| provider.name}.should =~ ["rc","ssh"]
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should attach the interface name for network interfaces" do
|
15
|
-
processes = ["network-interface (eth0)"]
|
15
|
+
processes = ["network-interface (eth0)"].join("\n")
|
16
16
|
provider_class.stubs(:execpipe).yields(processes)
|
17
17
|
provider_class.instances.first.name.should == "network-interface INTERFACE=eth0"
|
18
18
|
end
|
@@ -23,7 +23,11 @@ describe provider_class do
|
|
23
23
|
resource = Puppet::Type.type(:service).new(:name => "foo", :provider => :upstart, :status => "/bin/foo")
|
24
24
|
provider = provider_class.new(resource)
|
25
25
|
|
26
|
-
|
26
|
+
# Because we stub execution, we also need to stub the result of it, or a
|
27
|
+
# previously failing command execution will cause this test to do the
|
28
|
+
# wrong thing.
|
29
|
+
provider.expects(:ucommand)
|
30
|
+
$?.stubs(:exitstatus).returns(0)
|
27
31
|
provider.status.should == :running
|
28
32
|
end
|
29
33
|
|
@@ -106,6 +106,25 @@ describe provider_class do
|
|
106
106
|
provider.expects(:execute).with([provider_class.command(:pw), "userdel", "testuser"])
|
107
107
|
provider.delete
|
108
108
|
end
|
109
|
+
|
110
|
+
# The above test covers this, but given the consequences of
|
111
|
+
# accidently deleting a user's home directory it seems better to
|
112
|
+
# have an explicit test.
|
113
|
+
it "should not use -r when managehome is not set" do
|
114
|
+
provider = resource.provider
|
115
|
+
provider.expects(:exists?).returns true
|
116
|
+
resource[:managehome] = false
|
117
|
+
provider.expects(:execute).with(Not(includes("-r")))
|
118
|
+
provider.delete
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should use -r when managehome is set" do
|
122
|
+
provider = resource.provider
|
123
|
+
provider.expects(:exists?).returns true
|
124
|
+
resource[:managehome] = true
|
125
|
+
provider.expects(:execute).with(includes("-r"))
|
126
|
+
provider.delete
|
127
|
+
end
|
109
128
|
end
|
110
129
|
|
111
130
|
describe "when modifying users" do
|
@@ -639,7 +639,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
639
639
|
@other = Puppet::Type.type(:multiple).new(:title => "another resource", :color => "red", :designation => "5")
|
640
640
|
|
641
641
|
@catalog.add_resource(@resource)
|
642
|
-
expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, /Cannot alias Multiple\[another resource\] to \["red", "5"\].*resource \["Multiple", "red", "5"\] already
|
642
|
+
expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, /Cannot alias Multiple\[another resource\] to \["red", "5"\].*resource \["Multiple", "red", "5"\] already declared/)
|
643
643
|
end
|
644
644
|
|
645
645
|
it "should conflict when its uniqueness key matches another resource's title" do
|
@@ -648,7 +648,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
648
648
|
@other = Puppet::Type.type(:file).new(:title => "another file", :path => path)
|
649
649
|
|
650
650
|
@catalog.add_resource(@resource)
|
651
|
-
expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, /Cannot alias File\[another file\] to \["#{Regexp.escape(path)}"\].*resource \["File", "#{Regexp.escape(path)}"\] already
|
651
|
+
expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, /Cannot alias File\[another file\] to \["#{Regexp.escape(path)}"\].*resource \["File", "#{Regexp.escape(path)}"\] already declared/)
|
652
652
|
end
|
653
653
|
|
654
654
|
it "should conflict when its uniqueness key matches the uniqueness key derived from another resource's title" do
|
@@ -656,7 +656,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
656
656
|
@other = Puppet::Type.type(:multiple).new(:title => "another resource", :color => "red", :designation => "leader")
|
657
657
|
|
658
658
|
@catalog.add_resource(@resource)
|
659
|
-
expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, /Cannot alias Multiple\[another resource\] to \["red", "leader"\].*resource \["Multiple", "red", "leader"\] already
|
659
|
+
expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, /Cannot alias Multiple\[another resource\] to \["red", "leader"\].*resource \["Multiple", "red", "leader"\] already declared/)
|
660
660
|
end
|
661
661
|
end
|
662
662
|
end
|
data/spec/unit/semver_spec.rb
CHANGED
@@ -10,13 +10,13 @@ describe SemVer do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should validate special version strings' do
|
13
|
-
%w[ 0.0.
|
13
|
+
%w[ 0.0.0-foo 999.999.999-bar v0.0.0-a v999.999.999-beta ].each do |vstring|
|
14
14
|
SemVer.valid?(vstring).should be_true
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should fail to validate invalid version strings' do
|
19
|
-
%w[ nope 0.0foo 999.999 x0.0.0 z.z.z 1.2.
|
19
|
+
%w[ nope 0.0foo 999.999 x0.0.0 z.z.z 1.2.3beta 1.x.y ].each do |vstring|
|
20
20
|
SemVer.valid?(vstring).should be_false
|
21
21
|
end
|
22
22
|
end
|
@@ -27,8 +27,8 @@ describe SemVer do
|
|
27
27
|
@versions = %w[
|
28
28
|
0.0.1
|
29
29
|
0.0.2
|
30
|
-
1.0.
|
31
|
-
1.0.
|
30
|
+
1.0.0-rc1
|
31
|
+
1.0.0-rc2
|
32
32
|
1.0.0
|
33
33
|
1.0.1
|
34
34
|
1.1.0
|
@@ -38,7 +38,7 @@ describe SemVer do
|
|
38
38
|
1.1.4
|
39
39
|
1.2.0
|
40
40
|
1.2.1
|
41
|
-
2.0.
|
41
|
+
2.0.0-rc1
|
42
42
|
].map { |v| SemVer.new(v) }
|
43
43
|
end
|
44
44
|
|
@@ -49,7 +49,7 @@ describe SemVer do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should return nil if no versions match' do
|
52
|
-
%w[ 3.0.0 2.0.
|
52
|
+
%w[ 3.0.0 2.0.0-rc2 1.0.0-alpha ].each do |v|
|
53
53
|
SemVer.find_matching(v, @versions).should be_nil
|
54
54
|
end
|
55
55
|
end
|
@@ -58,7 +58,7 @@ describe SemVer do
|
|
58
58
|
SemVer.find_matching('1.0', @versions).should == 'v1.0.1'
|
59
59
|
SemVer.find_matching('1.1', @versions).should == 'v1.1.4'
|
60
60
|
SemVer.find_matching('1', @versions).should == 'v1.2.1'
|
61
|
-
SemVer.find_matching('2', @versions).should == 'v2.0.
|
61
|
+
SemVer.find_matching('2', @versions).should == 'v2.0.0-rc1'
|
62
62
|
SemVer.find_matching('2.1', @versions).should == nil
|
63
63
|
end
|
64
64
|
|
@@ -68,12 +68,105 @@ describe SemVer do
|
|
68
68
|
SemVer.find_matching('1.1.x', @versions).should == 'v1.1.4'
|
69
69
|
SemVer.find_matching('1.x', @versions).should == 'v1.2.1'
|
70
70
|
SemVer.find_matching('1.x.x', @versions).should == 'v1.2.1'
|
71
|
-
SemVer.find_matching('2.x', @versions).should == 'v2.0.
|
72
|
-
SemVer.find_matching('2.x.x', @versions).should == 'v2.0.
|
71
|
+
SemVer.find_matching('2.x', @versions).should == 'v2.0.0-rc1'
|
72
|
+
SemVer.find_matching('2.x.x', @versions).should == 'v2.0.0-rc1'
|
73
73
|
SemVer.find_matching('2.1.x', @versions).should == nil
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
describe '::[]' do
|
78
|
+
it "should produce expected ranges" do
|
79
|
+
tests = {
|
80
|
+
'1.2.3' => SemVer.new('v1.2.3-') .. SemVer.new('v1.2.3'),
|
81
|
+
'>1.2.3' => SemVer.new('v1.2.4-') .. SemVer::MAX,
|
82
|
+
'<1.2.3' => SemVer::MIN ... SemVer.new('v1.2.3-'),
|
83
|
+
'>=1.2.3' => SemVer.new('v1.2.3-') .. SemVer::MAX,
|
84
|
+
'<=1.2.3' => SemVer::MIN .. SemVer.new('v1.2.3'),
|
85
|
+
'>1.2.3 <1.2.5' => SemVer.new('v1.2.4-') ... SemVer.new('v1.2.5-'),
|
86
|
+
'>=1.2.3 <=1.2.5' => SemVer.new('v1.2.3-') .. SemVer.new('v1.2.5'),
|
87
|
+
'1.2.3 - 2.3.4' => SemVer.new('v1.2.3-') .. SemVer.new('v2.3.4'),
|
88
|
+
'~1.2.3' => SemVer.new('v1.2.3-') ... SemVer.new('v1.3.0-'),
|
89
|
+
'~1.2' => SemVer.new('v1.2.0-') ... SemVer.new('v2.0.0-'),
|
90
|
+
'~1' => SemVer.new('v1.0.0-') ... SemVer.new('v2.0.0-'),
|
91
|
+
'1.2.x' => SemVer.new('v1.2.0') ... SemVer.new('v1.3.0-'),
|
92
|
+
'1.x' => SemVer.new('v1.0.0') ... SemVer.new('v2.0.0-'),
|
93
|
+
}
|
94
|
+
|
95
|
+
tests.each do |vstring, expected|
|
96
|
+
SemVer[vstring].should == expected
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should suit up" do
|
101
|
+
suitability = {
|
102
|
+
[ '1.2.3', 'v1.2.2' ] => false,
|
103
|
+
[ '>=1.2.3', 'v1.2.2' ] => false,
|
104
|
+
[ '<=1.2.3', 'v1.2.2' ] => true,
|
105
|
+
[ '>= 1.2.3', 'v1.2.2' ] => false,
|
106
|
+
[ '<= 1.2.3', 'v1.2.2' ] => true,
|
107
|
+
[ '1.2.3 - 1.2.4', 'v1.2.2' ] => false,
|
108
|
+
[ '~1.2.3', 'v1.2.2' ] => false,
|
109
|
+
[ '~1.2', 'v1.2.2' ] => true,
|
110
|
+
[ '~1', 'v1.2.2' ] => true,
|
111
|
+
[ '1.2.x', 'v1.2.2' ] => true,
|
112
|
+
[ '1.x', 'v1.2.2' ] => true,
|
113
|
+
|
114
|
+
[ '1.2.3', 'v1.2.3-alpha' ] => true,
|
115
|
+
[ '>=1.2.3', 'v1.2.3-alpha' ] => true,
|
116
|
+
[ '<=1.2.3', 'v1.2.3-alpha' ] => true,
|
117
|
+
[ '>= 1.2.3', 'v1.2.3-alpha' ] => true,
|
118
|
+
[ '<= 1.2.3', 'v1.2.3-alpha' ] => true,
|
119
|
+
[ '>1.2.3', 'v1.2.3-alpha' ] => false,
|
120
|
+
[ '<1.2.3', 'v1.2.3-alpha' ] => false,
|
121
|
+
[ '> 1.2.3', 'v1.2.3-alpha' ] => false,
|
122
|
+
[ '< 1.2.3', 'v1.2.3-alpha' ] => false,
|
123
|
+
[ '1.2.3 - 1.2.4', 'v1.2.3-alpha' ] => true,
|
124
|
+
[ '1.2.3 - 1.2.4', 'v1.2.4-alpha' ] => true,
|
125
|
+
[ '1.2.3 - 1.2.4', 'v1.2.5-alpha' ] => false,
|
126
|
+
[ '~1.2.3', 'v1.2.3-alpha' ] => true,
|
127
|
+
[ '~1.2.3', 'v1.3.0-alpha' ] => false,
|
128
|
+
[ '~1.2', 'v1.2.3-alpha' ] => true,
|
129
|
+
[ '~1.2', 'v2.0.0-alpha' ] => false,
|
130
|
+
[ '~1', 'v1.2.3-alpha' ] => true,
|
131
|
+
[ '~1', 'v2.0.0-alpha' ] => false,
|
132
|
+
[ '1.2.x', 'v1.2.3-alpha' ] => true,
|
133
|
+
[ '1.2.x', 'v1.3.0-alpha' ] => false,
|
134
|
+
[ '1.x', 'v1.2.3-alpha' ] => true,
|
135
|
+
[ '1.x', 'v2.0.0-alpha' ] => false,
|
136
|
+
|
137
|
+
[ '1.2.3', 'v1.2.3' ] => true,
|
138
|
+
[ '>=1.2.3', 'v1.2.3' ] => true,
|
139
|
+
[ '<=1.2.3', 'v1.2.3' ] => true,
|
140
|
+
[ '>= 1.2.3', 'v1.2.3' ] => true,
|
141
|
+
[ '<= 1.2.3', 'v1.2.3' ] => true,
|
142
|
+
[ '1.2.3 - 1.2.4', 'v1.2.3' ] => true,
|
143
|
+
[ '~1.2.3', 'v1.2.3' ] => true,
|
144
|
+
[ '~1.2', 'v1.2.3' ] => true,
|
145
|
+
[ '~1', 'v1.2.3' ] => true,
|
146
|
+
[ '1.2.x', 'v1.2.3' ] => true,
|
147
|
+
[ '1.x', 'v1.2.3' ] => true,
|
148
|
+
|
149
|
+
[ '1.2.3', 'v1.2.4' ] => false,
|
150
|
+
[ '>=1.2.3', 'v1.2.4' ] => true,
|
151
|
+
[ '<=1.2.3', 'v1.2.4' ] => false,
|
152
|
+
[ '>= 1.2.3', 'v1.2.4' ] => true,
|
153
|
+
[ '<= 1.2.3', 'v1.2.4' ] => false,
|
154
|
+
[ '1.2.3 - 1.2.4', 'v1.2.4' ] => true,
|
155
|
+
[ '~1.2.3', 'v1.2.4' ] => true,
|
156
|
+
[ '~1.2', 'v1.2.4' ] => true,
|
157
|
+
[ '~1', 'v1.2.4' ] => true,
|
158
|
+
[ '1.2.x', 'v1.2.4' ] => true,
|
159
|
+
[ '1.x', 'v1.2.4' ] => true,
|
160
|
+
}
|
161
|
+
|
162
|
+
suitability.each do |arguments, expected|
|
163
|
+
range, vstring = arguments
|
164
|
+
actual = SemVer[range] === SemVer.new(vstring)
|
165
|
+
actual.should == expected
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
77
170
|
describe 'instantiation' do
|
78
171
|
it 'should raise an exception when passed an invalid version string' do
|
79
172
|
expect { SemVer.new('invalidVersion') }.to raise_exception ArgumentError
|
@@ -88,25 +181,25 @@ describe SemVer do
|
|
88
181
|
end
|
89
182
|
|
90
183
|
it 'should populate the appropriate fields for a special version string' do
|
91
|
-
version = SemVer.new('3.4.
|
184
|
+
version = SemVer.new('3.4.5-beta6')
|
92
185
|
version.major.should == 3
|
93
186
|
version.minor.should == 4
|
94
187
|
version.tiny.should == 5
|
95
|
-
version.special.should == 'beta6'
|
188
|
+
version.special.should == '-beta6'
|
96
189
|
end
|
97
190
|
end
|
98
191
|
|
99
192
|
describe '#matched_by?' do
|
100
|
-
subject { SemVer.new('v1.2.
|
193
|
+
subject { SemVer.new('v1.2.3-beta') }
|
101
194
|
|
102
195
|
describe 'should match against' do
|
103
196
|
describe 'literal version strings' do
|
104
|
-
it { should be_matched_by('1.2.
|
197
|
+
it { should be_matched_by('1.2.3-beta') }
|
105
198
|
|
106
|
-
it { should_not be_matched_by('1.2.
|
107
|
-
it { should_not be_matched_by('1.2.
|
108
|
-
it { should_not be_matched_by('1.3.
|
109
|
-
it { should_not be_matched_by('2.2.
|
199
|
+
it { should_not be_matched_by('1.2.3-alpha') }
|
200
|
+
it { should_not be_matched_by('1.2.4-beta') }
|
201
|
+
it { should_not be_matched_by('1.3.3-beta') }
|
202
|
+
it { should_not be_matched_by('2.2.3-beta') }
|
110
203
|
end
|
111
204
|
|
112
205
|
describe 'partial version strings' do
|
@@ -155,14 +248,14 @@ describe SemVer do
|
|
155
248
|
it { should < SemVer.new('1.2.4') }
|
156
249
|
|
157
250
|
# Against special versions
|
158
|
-
it { should > SemVer.new('1.2.
|
159
|
-
it { should < SemVer.new('1.2.
|
251
|
+
it { should > SemVer.new('1.2.3-beta') }
|
252
|
+
it { should < SemVer.new('1.2.4-beta') }
|
160
253
|
end
|
161
254
|
|
162
|
-
describe 'on a special version (v1.2.
|
163
|
-
subject { SemVer.new('v1.2.
|
255
|
+
describe 'on a special version (v1.2.3-beta)' do
|
256
|
+
subject { SemVer.new('v1.2.3-beta') }
|
164
257
|
|
165
|
-
it { should == SemVer.new('1.2.
|
258
|
+
it { should == SemVer.new('1.2.3-beta') }
|
166
259
|
|
167
260
|
# Same version, final release
|
168
261
|
it { should < SemVer.new('1.2.3') }
|
@@ -180,8 +273,8 @@ describe SemVer do
|
|
180
273
|
it { should < SemVer.new('1.2.4') }
|
181
274
|
|
182
275
|
# Against special versions
|
183
|
-
it { should > SemVer.new('1.2.
|
184
|
-
it { should < SemVer.new('1.2.
|
276
|
+
it { should > SemVer.new('1.2.3-alpha') }
|
277
|
+
it { should < SemVer.new('1.2.3-beta2') }
|
185
278
|
end
|
186
279
|
end
|
187
280
|
end
|