puppet 3.8.2-x64-mingw32 → 3.8.3-x64-mingw32
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/ext/build_defaults.yaml +4 -4
- data/lib/puppet/parser/compiler.rb +1 -3
- data/lib/puppet/parser/resource.rb +13 -10
- data/lib/puppet/pops/issues.rb +1 -1
- data/lib/puppet/pops/parser/egrammar.ra +6 -0
- data/lib/puppet/pops/parser/eparser.rb +908 -877
- data/lib/puppet/pops/validation/checker4_0.rb +12 -0
- data/lib/puppet/provider/exec.rb +6 -1
- data/lib/puppet/provider/service/launchd.rb +35 -8
- data/lib/puppet/resource/catalog.rb +0 -4
- data/lib/puppet/util/execution.rb +18 -2
- data/lib/puppet/version.rb +1 -1
- data/spec/integration/transaction_spec.rb +1 -1
- data/spec/integration/type/file_spec.rb +0 -1
- data/spec/integration/util/windows/security_spec.rb +14 -5
- data/spec/unit/pops/validator/validator_spec.rb +15 -0
- data/spec/unit/provider/service/launchd_spec.rb +75 -24
- data/spec/unit/type/exec_spec.rb +16 -8
- data/spec/unit/util/windows/sid_spec.rb +0 -10
- metadata +2 -2
@@ -296,6 +296,12 @@ class Puppet::Pops::Validation::Checker4_0
|
|
296
296
|
'runtime' => true,
|
297
297
|
}
|
298
298
|
|
299
|
+
FUTURE_RESERVED_WORDS = {
|
300
|
+
'application' => true,
|
301
|
+
'produces' => true,
|
302
|
+
'consumes' => true
|
303
|
+
}
|
304
|
+
|
299
305
|
# for 'class', 'define', and function
|
300
306
|
def check_NamedDefinition(o)
|
301
307
|
top(o.eContainer, o)
|
@@ -307,6 +313,12 @@ class Puppet::Pops::Validation::Checker4_0
|
|
307
313
|
acceptor.accept(Issues::RESERVED_TYPE_NAME, o, {:name => o.name})
|
308
314
|
end
|
309
315
|
|
316
|
+
# This is perhaps not ideal but it's very difficult to pass a ReservedWord through
|
317
|
+
# the mechanism that creates qualified names (namestack, namepop etc.)
|
318
|
+
if FUTURE_RESERVED_WORDS[o.name]
|
319
|
+
acceptor.accept(Issues::FUTURE_RESERVED_WORD, o, {:word => o.name})
|
320
|
+
end
|
321
|
+
|
310
322
|
if violator = ends_with_idem(o.body)
|
311
323
|
acceptor.accept(Issues::IDEM_NOT_ALLOWED_LAST, violator, {:container => o})
|
312
324
|
end
|
data/lib/puppet/provider/exec.rb
CHANGED
@@ -56,7 +56,12 @@ class Puppet::Provider::Exec < Puppet::Provider
|
|
56
56
|
exec_user = resource[:user]
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
# Ruby 2.1 and later interrupt execution in a way that bypasses error
|
60
|
+
# handling by default. Passing Timeout::Error causes an exception to be
|
61
|
+
# raised that can be rescued inside of the block by cleanup routines.
|
62
|
+
#
|
63
|
+
# This is backwards compatible all the way to Ruby 1.8.7.
|
64
|
+
Timeout.timeout(resource[:timeout], Timeout::Error) do
|
60
65
|
# note that we are passing "false" for the "override_locale" parameter, which ensures that the user's
|
61
66
|
# default/system locale will be respected. Callers may override this behavior by setting locale-related
|
62
67
|
# environment variables (LANG, LC_ALL, etc.) in their 'environment' configuration.
|
@@ -66,12 +66,27 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
66
66
|
]
|
67
67
|
end
|
68
68
|
|
69
|
+
# Gets the current Darwin version, example 10.6 returns 9 and 10.10 returns 14
|
70
|
+
# See https://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history
|
71
|
+
# for more information.
|
72
|
+
#
|
73
|
+
# @api private
|
74
|
+
def self.get_os_version
|
75
|
+
@os_version ||= Facter.value(:operatingsystemmajrelease).to_i
|
76
|
+
end
|
77
|
+
|
69
78
|
# Defines the path to the overrides plist file where service enabling
|
70
79
|
# behavior is defined in 10.6 and greater.
|
71
80
|
#
|
81
|
+
# With the rewrite of launchd in 10.10+, this moves and slightly changes format.
|
82
|
+
#
|
72
83
|
# @api private
|
73
84
|
def self.launchd_overrides
|
74
|
-
|
85
|
+
if self.get_os_version < 14
|
86
|
+
"/var/db/launchd.db/com.apple.launchd/overrides.plist"
|
87
|
+
else
|
88
|
+
"/var/db/com.apple.xpc.launchd/disabled.plist"
|
89
|
+
end
|
75
90
|
end
|
76
91
|
|
77
92
|
# Caching is enabled through the following three methods. Self.prefetch will
|
@@ -181,11 +196,9 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
181
196
|
# it is 10.6 or greater. This allows us to implement different plist
|
182
197
|
# behavior for versions >= 10.6
|
183
198
|
def has_macosx_plist_overrides?
|
184
|
-
@product_version ||= self.class.get_macosx_version_major
|
185
199
|
# (#11593) Remove support for OS X 10.4 & earlier
|
186
200
|
# leaving this as is because 10.5 still didn't have plist support
|
187
|
-
return
|
188
|
-
return false
|
201
|
+
return self.class.get_os_version > 9
|
189
202
|
end
|
190
203
|
|
191
204
|
# Read a plist, whether its format is XML or in Apple's "binary1"
|
@@ -246,8 +259,10 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
246
259
|
did_enable_job = false
|
247
260
|
cmds = []
|
248
261
|
cmds << :launchctl << :load
|
262
|
+
# always add -w so it always starts the job, it is a noop if it is not needed, this means we do
|
263
|
+
# not have to rescan all launchd plists.
|
264
|
+
cmds << "-w"
|
249
265
|
if self.enabled? == :false || self.status == :stopped # launchctl won't load disabled jobs
|
250
|
-
cmds << "-w"
|
251
266
|
did_enable_job = true
|
252
267
|
end
|
253
268
|
cmds << job_path
|
@@ -305,7 +320,11 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
305
320
|
if has_macosx_plist_overrides?
|
306
321
|
if FileTest.file?(self.class.launchd_overrides) and overrides = self.class.read_plist(self.class.launchd_overrides)
|
307
322
|
if overrides.has_key?(resource[:name])
|
308
|
-
|
323
|
+
if self.class.get_os_version < 14
|
324
|
+
overrides_disabled = overrides[resource[:name]]["Disabled"] if overrides[resource[:name]].has_key?("Disabled")
|
325
|
+
else
|
326
|
+
overrides_disabled = overrides[resource[:name]]
|
327
|
+
end
|
309
328
|
end
|
310
329
|
end
|
311
330
|
end
|
@@ -328,7 +347,11 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
328
347
|
def enable
|
329
348
|
if has_macosx_plist_overrides?
|
330
349
|
overrides = self.class.read_plist(self.class.launchd_overrides)
|
331
|
-
|
350
|
+
if self.class.get_os_version < 14
|
351
|
+
overrides[resource[:name]] = { "Disabled" => false }
|
352
|
+
else
|
353
|
+
overrides[resource[:name]] = false
|
354
|
+
end
|
332
355
|
Plist::Emit.save_plist(overrides, self.class.launchd_overrides)
|
333
356
|
else
|
334
357
|
job_path, job_plist = plist_from_label(resource[:name])
|
@@ -342,7 +365,11 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
342
365
|
def disable
|
343
366
|
if has_macosx_plist_overrides?
|
344
367
|
overrides = self.class.read_plist(self.class.launchd_overrides)
|
345
|
-
|
368
|
+
if self.class.get_os_version < 14
|
369
|
+
overrides[resource[:name]] = { "Disabled" => true }
|
370
|
+
else
|
371
|
+
overrides[resource[:name]] = true
|
372
|
+
end
|
346
373
|
Plist::Emit.save_plist(overrides, self.class.launchd_overrides)
|
347
374
|
else
|
348
375
|
job_path, job_plist = plist_from_label(resource[:name])
|
@@ -168,10 +168,6 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
|
|
168
168
|
transaction.report.as_logging_destination do
|
169
169
|
transaction.evaluate
|
170
170
|
end
|
171
|
-
rescue Puppet::Error => detail
|
172
|
-
Puppet.log_exception(detail, "Could not apply complete catalog: #{detail}")
|
173
|
-
rescue => detail
|
174
|
-
Puppet.log_exception(detail, "Got an uncaught exception of type #{detail.class}: #{detail}")
|
175
171
|
ensure
|
176
172
|
# Don't try to store state unless we're a host config
|
177
173
|
# too recursive.
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'timeout'
|
1
2
|
require 'puppet/file_system/uniquefile'
|
2
3
|
|
3
4
|
module Puppet
|
@@ -179,8 +180,23 @@ module Puppet::Util::Execution
|
|
179
180
|
if execution_stub = Puppet::Util::ExecutionStub.current_value
|
180
181
|
return execution_stub.call(*exec_args)
|
181
182
|
elsif Puppet.features.posix?
|
182
|
-
child_pid =
|
183
|
-
|
183
|
+
child_pid = nil
|
184
|
+
begin
|
185
|
+
child_pid = execute_posix(*exec_args)
|
186
|
+
exit_status = Process.waitpid2(child_pid).last.exitstatus
|
187
|
+
child_pid = nil
|
188
|
+
rescue Timeout::Error => e
|
189
|
+
# NOTE: For Ruby 2.1+, an explicit Timeout::Error class has to be
|
190
|
+
# passed to Timeout.timeout in order for there to be something for
|
191
|
+
# this block to rescue.
|
192
|
+
unless child_pid.nil?
|
193
|
+
Process.kill(:TERM, child_pid)
|
194
|
+
# Spawn a thread to reap the process if it dies.
|
195
|
+
Thread.new { Process.waitpid(child_pid) }
|
196
|
+
end
|
197
|
+
|
198
|
+
raise e
|
199
|
+
end
|
184
200
|
elsif Puppet.features.microsoft_windows?
|
185
201
|
process_info = execute_windows(*exec_args)
|
186
202
|
begin
|
data/lib/puppet/version.rb
CHANGED
@@ -205,7 +205,7 @@ describe Puppet::Transaction do
|
|
205
205
|
notify.expects(:pre_run_check).raises(Puppet::Error, "fail for testing")
|
206
206
|
|
207
207
|
catalog = mk_catalog(file, notify)
|
208
|
-
catalog.apply
|
208
|
+
expect { catalog.apply }.to raise_error(Puppet::Error, /Some pre-run checks failed/)
|
209
209
|
Puppet::FileSystem.exist?(path).should_not be_true
|
210
210
|
end
|
211
211
|
|
@@ -1053,7 +1053,6 @@ describe Puppet::Type.type(:file), :uses_checksums => true do
|
|
1053
1053
|
@sids = {
|
1054
1054
|
:current_user => Puppet::Util::Windows::SID.name_to_sid(Puppet::Util::Windows::ADSI::User.current_user_name),
|
1055
1055
|
:system => Win32::Security::SID::LocalSystem,
|
1056
|
-
:admin => Puppet::Util::Windows::SID.name_to_sid("Administrator"),
|
1057
1056
|
:guest => Puppet::Util::Windows::SID.name_to_sid("Guest"),
|
1058
1057
|
:users => Win32::Security::SID::BuiltinUsers,
|
1059
1058
|
:power_users => Win32::Security::SID::PowerUsers,
|
@@ -15,7 +15,6 @@ describe "Puppet::Util::Windows::Security", :if => Puppet.features.microsoft_win
|
|
15
15
|
@sids = {
|
16
16
|
:current_user => Puppet::Util::Windows::SID.name_to_sid(Puppet::Util::Windows::ADSI::User.current_user_name),
|
17
17
|
:system => Win32::Security::SID::LocalSystem,
|
18
|
-
:admin => Puppet::Util::Windows::SID.name_to_sid("Administrator"),
|
19
18
|
:administrators => Win32::Security::SID::BuiltinAdministrators,
|
20
19
|
:guest => Puppet::Util::Windows::SID.name_to_sid("Guest"),
|
21
20
|
:users => Win32::Security::SID::BuiltinUsers,
|
@@ -386,9 +385,14 @@ describe "Puppet::Util::Windows::Security", :if => Puppet.features.microsoft_win
|
|
386
385
|
end
|
387
386
|
|
388
387
|
describe "#owner=" do
|
388
|
+
it "should accept the guest sid" do
|
389
|
+
winsec.set_owner(sids[:guest], path)
|
390
|
+
expect(winsec.get_owner(path)).to eq(sids[:guest])
|
391
|
+
end
|
392
|
+
|
389
393
|
it "should accept a user sid" do
|
390
|
-
winsec.set_owner(sids[:
|
391
|
-
winsec.get_owner(path).should == sids[:
|
394
|
+
winsec.set_owner(sids[:current_user], path)
|
395
|
+
winsec.get_owner(path).should == sids[:current_user]
|
392
396
|
end
|
393
397
|
|
394
398
|
it "should accept a group sid" do
|
@@ -406,14 +410,19 @@ describe "Puppet::Util::Windows::Security", :if => Puppet.features.microsoft_win
|
|
406
410
|
end
|
407
411
|
|
408
412
|
describe "#group=" do
|
413
|
+
it "should accept the test group" do
|
414
|
+
winsec.set_group(sids[:guest], path)
|
415
|
+
expect(winsec.get_group(path)).to eq(sids[:guest])
|
416
|
+
end
|
417
|
+
|
409
418
|
it "should accept a group sid" do
|
410
419
|
winsec.set_group(sids[:power_users], path)
|
411
420
|
winsec.get_group(path).should == sids[:power_users]
|
412
421
|
end
|
413
422
|
|
414
423
|
it "should accept a user sid" do
|
415
|
-
winsec.set_group(sids[:
|
416
|
-
winsec.get_group(path).should == sids[:
|
424
|
+
winsec.set_group(sids[:current_user], path)
|
425
|
+
winsec.get_group(path).should == sids[:current_user]
|
417
426
|
end
|
418
427
|
|
419
428
|
it "should combine owner and group rights when they are the same sid" do
|
@@ -125,6 +125,21 @@ describe "validating 4x" do
|
|
125
125
|
source = "$a = #{word}"
|
126
126
|
expect(validate(parse(source))).to have_issue(Puppet::Pops::Issues::FUTURE_RESERVED_WORD)
|
127
127
|
end
|
128
|
+
|
129
|
+
it 'produces a warning issue when used as a class name' do
|
130
|
+
source = "class #{word} {}"
|
131
|
+
expect(validate(parse(source))).to have_issue(Puppet::Pops::Issues::FUTURE_RESERVED_WORD)
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'produces no warning or error when used as a parameter name' do
|
135
|
+
source = "define foo($#{word}) { notice $#{word} }"
|
136
|
+
expect(validate(parse(source)).diagnostics.empty?).to eq(true)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'produces no warning or error when used as an attribute name' do
|
140
|
+
source = "foo { bar: #{word} => ok }"
|
141
|
+
expect(validate(parse(source)).diagnostics.empty?).to eq(true)
|
142
|
+
end
|
128
143
|
end
|
129
144
|
end
|
130
145
|
|
@@ -6,8 +6,9 @@ require 'spec_helper'
|
|
6
6
|
describe Puppet::Type.type(:service).provider(:launchd) do
|
7
7
|
let (:joblabel) { "com.foo.food" }
|
8
8
|
let (:provider) { subject.class }
|
9
|
-
let (:launchd_overrides) { '/var/db/launchd.db/com.apple.launchd/overrides.plist' }
|
10
9
|
let(:resource) { Puppet::Type.type(:service).new(:name => joblabel, :provider => :launchd) }
|
10
|
+
let (:launchd_overrides_6_9) { '/var/db/launchd.db/com.apple.launchd/overrides.plist' }
|
11
|
+
let (:launchd_overrides_10_) { '/var/db/com.apple.xpc.launchd/disabled.plist' }
|
11
12
|
subject { resource.provider }
|
12
13
|
|
13
14
|
describe "the type interface" do
|
@@ -39,42 +40,70 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
39
40
|
|
40
41
|
describe "when checking whether the service is enabled on OS X 10.5" do
|
41
42
|
it "should return true in if the job plist says disabled is false" do
|
42
|
-
|
43
|
+
provider.expects(:get_os_version).returns(9)
|
43
44
|
subject.expects(:plist_from_label).with(joblabel).returns(["foo", {"Disabled" => false}])
|
45
|
+
provider.expects(:read_plist).never
|
44
46
|
subject.enabled?.should == :true
|
45
47
|
end
|
46
48
|
it "should return true in if the job plist has no disabled key" do
|
47
|
-
|
49
|
+
provider.expects(:get_os_version).returns(9)
|
48
50
|
subject.expects(:plist_from_label).returns(["foo", {}])
|
49
51
|
subject.enabled?.should == :true
|
50
52
|
end
|
51
53
|
it "should return false in if the job plist says disabled is true" do
|
52
54
|
subject.expects(:has_macosx_plist_overrides?).returns(false)
|
53
55
|
subject.expects(:plist_from_label).returns(["foo", {"Disabled" => true}])
|
56
|
+
provider.expects(:read_plist).never
|
54
57
|
subject.enabled?.should == :false
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
58
|
-
|
61
|
+
[[10, '10.6'], [13, '10.9']].each do |kernel, version|
|
62
|
+
describe "when checking whether the service is enabled on OS X #{version}" do
|
63
|
+
it "should return true if the job plist says disabled is true and the global overrides says disabled is false" do
|
64
|
+
provider.expects(:get_os_version).returns(kernel).at_least_once
|
65
|
+
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => true}])
|
66
|
+
provider.expects(:read_plist).with(launchd_overrides_6_9).returns({joblabel => {"Disabled" => false}})
|
67
|
+
FileTest.expects(:file?).with(launchd_overrides_6_9).returns(true)
|
68
|
+
subject.enabled?.should == :true
|
69
|
+
end
|
70
|
+
it "should return false if the job plist says disabled is false and the global overrides says disabled is true" do
|
71
|
+
provider.expects(:get_os_version).returns(kernel).at_least_once
|
72
|
+
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => false}])
|
73
|
+
provider.expects(:read_plist).with(launchd_overrides_6_9).returns({joblabel => {"Disabled" => true}})
|
74
|
+
FileTest.expects(:file?).with(launchd_overrides_6_9).returns(true)
|
75
|
+
subject.enabled?.should == :false
|
76
|
+
end
|
77
|
+
it "should return true if the job plist and the global overrides have no disabled keys" do
|
78
|
+
provider.expects(:get_os_version).returns(kernel).at_least_once
|
79
|
+
subject.expects(:plist_from_label).returns([joblabel, {}])
|
80
|
+
provider.expects(:read_plist).with(launchd_overrides_6_9).returns({})
|
81
|
+
FileTest.expects(:file?).with(launchd_overrides_6_9).returns(true)
|
82
|
+
subject.enabled?.should == :true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "when checking whether the service is enabled on OS X 10.10" do
|
59
88
|
it "should return true if the job plist says disabled is true and the global overrides says disabled is false" do
|
60
|
-
provider.expects(:
|
89
|
+
provider.expects(:get_os_version).returns(14).at_least_once
|
61
90
|
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => true}])
|
62
|
-
provider.expects(:read_plist).returns({joblabel =>
|
63
|
-
FileTest.expects(:file?).with(
|
91
|
+
provider.expects(:read_plist).with(launchd_overrides_10_).returns({joblabel => false})
|
92
|
+
FileTest.expects(:file?).with(launchd_overrides_10_).returns(true)
|
64
93
|
subject.enabled?.should == :true
|
65
94
|
end
|
66
95
|
it "should return false if the job plist says disabled is false and the global overrides says disabled is true" do
|
67
|
-
provider.expects(:
|
96
|
+
provider.expects(:get_os_version).returns(14).at_least_once
|
68
97
|
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => false}])
|
69
|
-
provider.expects(:read_plist).returns({joblabel =>
|
70
|
-
FileTest.expects(:file?).with(
|
98
|
+
provider.expects(:read_plist).with(launchd_overrides_10_).returns({joblabel => true})
|
99
|
+
FileTest.expects(:file?).with(launchd_overrides_10_).returns(true)
|
71
100
|
subject.enabled?.should == :false
|
72
101
|
end
|
73
102
|
it "should return true if the job plist and the global overrides have no disabled keys" do
|
74
|
-
provider.expects(:
|
103
|
+
provider.expects(:get_os_version).returns(14).at_least_once
|
75
104
|
subject.expects(:plist_from_label).returns([joblabel, {}])
|
76
|
-
provider.expects(:read_plist).returns({})
|
77
|
-
FileTest.expects(:file?).with(
|
105
|
+
provider.expects(:read_plist).with(launchd_overrides_10_).returns({})
|
106
|
+
FileTest.expects(:file?).with(launchd_overrides_10_).returns(true)
|
78
107
|
subject.enabled?.should == :true
|
79
108
|
end
|
80
109
|
end
|
@@ -89,13 +118,13 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
89
118
|
it "should look for the relevant plist once" do
|
90
119
|
subject.expects(:plist_from_label).returns([joblabel, {}]).once
|
91
120
|
subject.expects(:enabled?).returns :true
|
92
|
-
subject.expects(:execute).with([:launchctl, :load, joblabel])
|
121
|
+
subject.expects(:execute).with([:launchctl, :load, "-w", joblabel])
|
93
122
|
subject.start
|
94
123
|
end
|
95
124
|
it "should execute 'launchctl load' once without writing to the plist if the job is enabled" do
|
96
125
|
subject.expects(:plist_from_label).returns([joblabel, {}])
|
97
126
|
subject.expects(:enabled?).returns :true
|
98
|
-
subject.expects(:execute).with([:launchctl, :load, joblabel]).once
|
127
|
+
subject.expects(:execute).with([:launchctl, :load, "-w", joblabel]).once
|
99
128
|
subject.start
|
100
129
|
end
|
101
130
|
it "should execute 'launchctl load' with writing to the plist once if the job is disabled" do
|
@@ -189,23 +218,45 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
189
218
|
end
|
190
219
|
end
|
191
220
|
|
192
|
-
|
221
|
+
[[10, "10.6"], [13, "10.9"]].each do |kernel, version|
|
222
|
+
describe "when enabling the service on OS X #{version}" do
|
223
|
+
it "should write to the global launchd overrides file once" do
|
224
|
+
resource[:enable] = true
|
225
|
+
provider.expects(:get_os_version).returns(kernel).at_least_once
|
226
|
+
provider.expects(:read_plist).with(launchd_overrides_6_9).returns({})
|
227
|
+
Plist::Emit.expects(:save_plist).with(has_entry(resource[:name], {'Disabled' => false}), launchd_overrides_6_9).once
|
228
|
+
subject.enable
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
describe "when disabling the service on OS X #{version}" do
|
233
|
+
it "should write to the global launchd overrides file once" do
|
234
|
+
resource[:enable] = false
|
235
|
+
provider.expects(:get_os_version).returns(kernel).at_least_once
|
236
|
+
provider.expects(:read_plist).with(launchd_overrides_6_9).returns({})
|
237
|
+
Plist::Emit.expects(:save_plist).with(has_entry(resource[:name], {'Disabled' => true}), launchd_overrides_6_9).once
|
238
|
+
subject.disable
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
describe "when enabling the service on OS X 10.10" do
|
193
244
|
it "should write to the global launchd overrides file once" do
|
194
245
|
resource[:enable] = true
|
195
|
-
provider.expects(:
|
196
|
-
provider.expects(:read_plist).returns({})
|
197
|
-
Plist::Emit.expects(:save_plist).once
|
246
|
+
provider.expects(:get_os_version).returns(14).at_least_once
|
247
|
+
provider.expects(:read_plist).with(launchd_overrides_10_).returns({})
|
248
|
+
Plist::Emit.expects(:save_plist).with(has_entry(resource[:name], false), launchd_overrides_10_).once
|
198
249
|
subject.enable
|
199
250
|
end
|
200
251
|
end
|
201
252
|
|
202
|
-
describe "when disabling the service on OS X 10.
|
253
|
+
describe "when disabling the service on OS X 10.10" do
|
203
254
|
it "should write to the global launchd overrides file once" do
|
204
255
|
resource[:enable] = false
|
205
|
-
provider.
|
206
|
-
provider.
|
207
|
-
Plist::Emit.expects(:save_plist).once
|
208
|
-
subject.
|
256
|
+
provider.expects(:get_os_version).returns(14).at_least_once
|
257
|
+
provider.expects(:read_plist).with(launchd_overrides_10_).returns({})
|
258
|
+
Plist::Emit.expects(:save_plist).with(has_entry(resource[:name], true), launchd_overrides_10_).once
|
259
|
+
subject.disable
|
209
260
|
end
|
210
261
|
end
|
211
262
|
|
data/spec/unit/type/exec_spec.rb
CHANGED
@@ -396,16 +396,24 @@ describe Puppet::Type.type(:exec) do
|
|
396
396
|
end
|
397
397
|
end
|
398
398
|
|
399
|
-
|
400
|
-
|
399
|
+
describe 'when timeout is exceeded' do
|
400
|
+
subject do
|
401
|
+
ruby_path = Puppet::Util::Execution.ruby_path()
|
402
|
+
Puppet::Type.type(:exec).new(:name => "#{ruby_path} -e 'sleep 1'", :timeout => '0.1')
|
403
|
+
end
|
401
404
|
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
405
|
+
context 'on POSIX', :unless => Puppet.features.microsoft_windows? do
|
406
|
+
it 'sends a SIGTERM and raises a Puppet::Error' do
|
407
|
+
Process.expects(:kill).at_least_once
|
408
|
+
expect { subject.refresh }.to raise_error Puppet::Error, "Command exceeded timeout"
|
409
|
+
end
|
410
|
+
end
|
407
411
|
|
408
|
-
|
412
|
+
context 'on Windows', :if => Puppet.features.microsoft_windows? do
|
413
|
+
it 'raises a Puppet::Error' do
|
414
|
+
expect { subject.refresh }.to raise_error Puppet::Error, "Command exceeded timeout"
|
415
|
+
end
|
416
|
+
end
|
409
417
|
end
|
410
418
|
|
411
419
|
it "should convert timeout to a float" do
|