puppet 5.5.2 → 5.5.3

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.

Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/lib/puppet/application/device.rb +43 -30
  3. data/lib/puppet/defaults.rb +7 -4
  4. data/lib/puppet/environments.rb +2 -3
  5. data/lib/puppet/face/config.rb +1 -1
  6. data/lib/puppet/face/module/build.rb +5 -0
  7. data/lib/puppet/gettext/config.rb +28 -5
  8. data/lib/puppet/indirector/catalog/compiler.rb +5 -7
  9. data/lib/puppet/node/environment.rb +5 -1
  10. data/lib/puppet/provider/selmodule/semodule.rb +1 -1
  11. data/lib/puppet/provider/service/upstart.rb +2 -0
  12. data/lib/puppet/reference/configuration.rb +6 -0
  13. data/lib/puppet/resource/status.rb +2 -0
  14. data/lib/puppet/resource/type_collection.rb +1 -1
  15. data/lib/puppet/settings.rb +6 -0
  16. data/lib/puppet/ssl/certificate_request.rb +11 -3
  17. data/lib/puppet/transaction/event_manager.rb +3 -1
  18. data/lib/puppet/transaction/report.rb +1 -1
  19. data/lib/puppet/util.rb +2 -0
  20. data/lib/puppet/util/command_line.rb +0 -1
  21. data/lib/puppet/util/log/destinations.rb +1 -1
  22. data/lib/puppet/util/windows/file.rb +18 -0
  23. data/lib/puppet/util/windows/security.rb +26 -14
  24. data/lib/puppet/version.rb +1 -1
  25. data/locales/puppet.pot +96 -79
  26. data/man/man5/puppet.conf.5 +8 -5
  27. data/man/man8/puppet-agent.8 +1 -1
  28. data/man/man8/puppet-apply.8 +1 -1
  29. data/man/man8/puppet-ca.8 +2 -2
  30. data/man/man8/puppet-catalog.8 +1 -1
  31. data/man/man8/puppet-cert.8 +1 -1
  32. data/man/man8/puppet-certificate.8 +2 -2
  33. data/man/man8/puppet-certificate_request.8 +1 -1
  34. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  35. data/man/man8/puppet-config.8 +2 -2
  36. data/man/man8/puppet-describe.8 +1 -1
  37. data/man/man8/puppet-device.8 +6 -2
  38. data/man/man8/puppet-doc.8 +1 -1
  39. data/man/man8/puppet-epp.8 +1 -1
  40. data/man/man8/puppet-facts.8 +1 -1
  41. data/man/man8/puppet-filebucket.8 +1 -1
  42. data/man/man8/puppet-generate.8 +1 -1
  43. data/man/man8/puppet-help.8 +1 -1
  44. data/man/man8/puppet-key.8 +1 -1
  45. data/man/man8/puppet-lookup.8 +1 -1
  46. data/man/man8/puppet-man.8 +1 -1
  47. data/man/man8/puppet-master.8 +1 -1
  48. data/man/man8/puppet-module.8 +1 -1
  49. data/man/man8/puppet-node.8 +1 -1
  50. data/man/man8/puppet-parser.8 +1 -1
  51. data/man/man8/puppet-plugin.8 +1 -1
  52. data/man/man8/puppet-report.8 +1 -1
  53. data/man/man8/puppet-resource.8 +1 -1
  54. data/man/man8/puppet-script.8 +1 -1
  55. data/man/man8/puppet-status.8 +1 -1
  56. data/man/man8/puppet.8 +2 -2
  57. data/spec/integration/type/file_spec.rb +3 -1
  58. data/spec/integration/util/windows/security_spec.rb +14 -1
  59. data/spec/shared_examples/rhel_package_provider.rb +2 -2
  60. data/spec/unit/application/device_spec.rb +55 -11
  61. data/spec/unit/application/master_spec.rb +5 -4
  62. data/spec/unit/gettext/config_spec.rb +29 -10
  63. data/spec/unit/node/environment_spec.rb +4 -3
  64. data/spec/unit/provider/package/aptitude_spec.rb +1 -1
  65. data/spec/unit/provider/package/aptrpm_spec.rb +1 -1
  66. data/spec/unit/provider/package/dpkg_spec.rb +1 -1
  67. data/spec/unit/provider/package/nim_spec.rb +2 -11
  68. data/spec/unit/provider/package/opkg_spec.rb +2 -2
  69. data/spec/unit/provider/package/pkg_spec.rb +52 -17
  70. data/spec/unit/provider/package/rpm_spec.rb +30 -10
  71. data/spec/unit/provider/package/urpmi_spec.rb +9 -3
  72. data/spec/unit/provider/selmodule_spec.rb +6 -0
  73. data/spec/unit/provider/service/openrc_spec.rb +1 -1
  74. data/spec/unit/resource/status_spec.rb +2 -0
  75. data/spec/unit/resource/type_collection_spec.rb +4 -1
  76. data/spec/unit/ssl/certificate_request_spec.rb +11 -0
  77. data/spec/unit/transaction/event_manager_spec.rb +12 -0
  78. data/spec/unit/util/diff_spec.rb +11 -3
  79. data/spec/unit/util/execution_spec.rb +2 -1
  80. data/spec/unit/util/filetype_spec.rb +6 -2
  81. data/spec/unit/util/log/destinations_spec.rb +28 -12
  82. data/spec/unit/util/plist_spec.rb +12 -6
  83. metadata +2 -2
@@ -41,8 +41,12 @@ describe provider_class do
41
41
  Puppet::Util.stubs(:which).with("rpm").returns("/bin/rpm")
42
42
  provider_class.stubs(:which).with("rpm").returns("/bin/rpm")
43
43
  provider_class.instance_variable_set("@current_version", nil)
44
- Puppet::Type::Package::ProviderRpm.expects(:execute).with(["/bin/rpm", "--version"]).returns(rpm_version).at_most_once
45
- Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "--version"], execute_options).returns(rpm_version).at_most_once
44
+ Puppet::Type::Package::ProviderRpm.expects(:execute)
45
+ .with(["/bin/rpm", "--version"])
46
+ .returns(rpm_version).at_most_once
47
+ Puppet::Util::Execution.expects(:execute)
48
+ .with(["/bin/rpm", "--version"], execute_options)
49
+ .returns(Puppet::Util::Execution::ProcessOutput.new(rpm_version, 0)).at_most_once
46
50
  end
47
51
 
48
52
  describe 'provider features' do
@@ -203,7 +207,9 @@ describe provider_class do
203
207
  describe "#latest" do
204
208
  it "retrieves version string after querying rpm for version from source file" do
205
209
  resource.expects(:[]).with(:source).returns('source-string')
206
- Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-q", "--qf", "'#{nevra_format}'", "-p", "source-string"]).returns("myresource 0 1.2.3.4 5.el4 noarch\n")
210
+ Puppet::Util::Execution.expects(:execute)
211
+ .with(["/bin/rpm", "-q", "--qf", "'#{nevra_format}'", "-p", "source-string"])
212
+ .returns(Puppet::Util::Execution::ProcessOutput.new("myresource 0 1.2.3.4 5.el4 noarch\n", 0))
207
213
  expect(provider.latest).to eq("1.2.3.4-5.el4")
208
214
  end
209
215
 
@@ -227,33 +233,43 @@ describe provider_class do
227
233
 
228
234
  describe "on a modern RPM" do
229
235
  before(:each) do
230
- Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-q", "myresource", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options).returns("myresource 0 1.2.3.4 5.el4 noarch\n")
236
+ Puppet::Util::Execution.expects(:execute)
237
+ .with(["/bin/rpm", "-q", "myresource", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
238
+ .returns(Puppet::Util::Execution::ProcessOutput.new("myresource 0 1.2.3.4 5.el4 noarch\n", 0))
231
239
  end
232
240
 
233
241
  let(:rpm_version) { "RPM version 4.10.0\n" }
234
242
 
235
243
  it "includes the architecture in the package name" do
236
- Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", ["-e"], 'myresource-1.2.3.4-5.el4.noarch'], execute_options).returns('').at_most_once
244
+ Puppet::Util::Execution.expects(:execute)
245
+ .with(["/bin/rpm", ["-e"], 'myresource-1.2.3.4-5.el4.noarch'], execute_options)
246
+ .returns(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most_once
237
247
  provider.uninstall
238
248
  end
239
249
  end
240
250
 
241
251
  describe "on an ancient RPM" do
242
252
  before(:each) do
243
- Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-q", "myresource", '', '', '--qf', "'#{nevra_format}'"], execute_options).returns("myresource 0 1.2.3.4 5.el4 noarch\n")
253
+ Puppet::Util::Execution.expects(:execute)
254
+ .with(["/bin/rpm", "-q", "myresource", '', '', '--qf', "'#{nevra_format}'"], execute_options)
255
+ .returns(Puppet::Util::Execution::ProcessOutput.new("myresource 0 1.2.3.4 5.el4 noarch\n", 0))
244
256
  end
245
257
 
246
258
  let(:rpm_version) { "RPM version 3.0.6\n" }
247
259
 
248
260
  it "excludes the architecture from the package name" do
249
- Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", ["-e"], 'myresource-1.2.3.4-5.el4'], execute_options).returns('').at_most_once
261
+ Puppet::Util::Execution.expects(:execute)
262
+ .with(["/bin/rpm", ["-e"], 'myresource-1.2.3.4-5.el4'], execute_options)
263
+ .returns(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most_once
250
264
  provider.uninstall
251
265
  end
252
266
  end
253
267
 
254
268
  describe "when uninstalled with options" do
255
269
  before(:each) do
256
- Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-q", "myresource", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options).returns("myresource 0 1.2.3.4 5.el4 noarch\n")
270
+ Puppet::Util::Execution.expects(:execute)
271
+ .with(["/bin/rpm", "-q", "myresource", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
272
+ .returns(Puppet::Util::Execution::ProcessOutput.new("myresource 0 1.2.3.4 5.el4 noarch\n", 0))
257
273
  end
258
274
 
259
275
  let(:resource) do
@@ -275,7 +291,9 @@ describe provider_class do
275
291
  describe "parsing" do
276
292
  def parser_test(rpm_output_string, gold_hash, number_of_debug_logs = 0)
277
293
  Puppet.expects(:debug).times(number_of_debug_logs)
278
- Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "'#{nevra_format}'"], execute_options).returns(rpm_output_string)
294
+ Puppet::Util::Execution.expects(:execute)
295
+ .with(["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "'#{nevra_format}'"], execute_options)
296
+ .returns(Puppet::Util::Execution::ProcessOutput.new(rpm_output_string, 0))
279
297
  expect(provider.query).to eq(gold_hash)
280
298
  end
281
299
 
@@ -336,7 +354,9 @@ describe provider_class do
336
354
  provider.resource[:allow_virtual] = true
337
355
  expected_args = ["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "'#{nevra_format}'"]
338
356
  Puppet::Util::Execution.expects(:execute).with(expected_args, execute_options).raises Puppet::ExecutionFailure.new("package #{resource_name} is not installed")
339
- Puppet::Util::Execution.expects(:execute).with(expected_args + ["--whatprovides"], execute_options).returns "myresource 0 1.2.3.4 5.el4 noarch\n"
357
+ Puppet::Util::Execution.expects(:execute)
358
+ .with(expected_args + ["--whatprovides"], execute_options)
359
+ .returns(Puppet::Util::Execution::ProcessOutput.new("myresource 0 1.2.3.4 5.el4 noarch\n", 0))
340
360
  expect(provider.query).to eq({
341
361
  :name => "myresource",
342
362
  :epoch => "0",
@@ -7,7 +7,9 @@ describe Puppet::Type.type(:package).provider(:urpmi) do
7
7
  %w[rpm urpmi urpme urpmq].each do |executable|
8
8
  Puppet::Util.stubs(:which).with(executable).returns(executable)
9
9
  end
10
- Puppet::Util::Execution.stubs(:execute).with(['rpm', '--version'], anything).returns 'RPM version 4.9.1.3'
10
+ Puppet::Util::Execution.stubs(:execute)
11
+ .with(['rpm', '--version'], anything)
12
+ .returns(Puppet::Util::Execution::ProcessOutput.new('RPM version 4.9.1.3', 0))
11
13
  end
12
14
 
13
15
  let(:resource) do
@@ -53,13 +55,17 @@ describe Puppet::Type.type(:package).provider(:urpmi) do
53
55
  let(:urpmq_output) { 'foopkg : Lorem ipsum dolor sit amet, consectetur adipisicing elit ( 7.8.9-1.mga2 )' }
54
56
 
55
57
  it "uses urpmq to determine the latest package" do
56
- Puppet::Util::Execution.expects(:execute).with(['urpmq', '-S', 'foopkg'], anything).returns urpmq_output
58
+ Puppet::Util::Execution.expects(:execute)
59
+ .with(['urpmq', '-S', 'foopkg'], anything)
60
+ .returns(Puppet::Util::Execution::ProcessOutput.new(urpmq_output, 0))
57
61
  expect(subject.latest).to eq('7.8.9-1.mga2')
58
62
  end
59
63
 
60
64
  it "falls back to the current version" do
61
65
  resource[:ensure] = '5.4.3'
62
- Puppet::Util::Execution.expects(:execute).with(['urpmq', '-S', 'foopkg'], anything).returns ''
66
+ Puppet::Util::Execution.expects(:execute)
67
+ .with(['urpmq', '-S', 'foopkg'], anything)
68
+ .returns(Puppet::Util::Execution::ProcessOutput.new('', 0))
63
69
  expect(subject.latest).to eq('5.4.3')
64
70
  end
65
71
  end
@@ -30,6 +30,12 @@ describe provider_class do
30
30
  expect(@provider.exists?).to be_nil
31
31
  end
32
32
 
33
+ it "should return nil if module with same suffix is loaded" do
34
+ @provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
35
+ @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields StringIO.new("bar\t1.2.3\nmyfoo\t1.0.0\n")
36
+ expect(@provider.exists?).to be_nil
37
+ end
38
+
33
39
  it "should return nil if no modules are loaded" do
34
40
  @provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
35
41
  @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields StringIO.new("")
@@ -74,7 +74,7 @@ describe Puppet::Type.type(:service).provider(:openrc) do
74
74
  Puppet::Util::Execution.expects(:execute).with(
75
75
  includes('/bin/rc-status'),
76
76
  has_entry(:custom_environment, {:RC_SVCNAME => nil})
77
- ).returns ''
77
+ ).returns(Puppet::Util::Execution::ProcessOutput.new('', 0))
78
78
  subject.enabled?
79
79
  end
80
80
  end
@@ -165,6 +165,7 @@ describe Puppet::Resource::Status do
165
165
  s.out_of_sync = true
166
166
  s.skipped = false
167
167
  s.provider_used = 'provider_used_class_name'
168
+ s.failed_to_restart = false
168
169
  s
169
170
  end
170
171
 
@@ -187,6 +188,7 @@ describe Puppet::Resource::Status do
187
188
  expect(tripped.changed).to eq(status.changed)
188
189
  expect(tripped.out_of_sync).to eq(status.out_of_sync)
189
190
  expect(tripped.skipped).to eq(status.skipped)
191
+ expect(tripped.failed_to_restart).to eq(status.failed_to_restart)
190
192
 
191
193
  expect(tripped.change_count).to eq(status.change_count)
192
194
  expect(tripped.out_of_sync_count).to eq(status.out_of_sync_count)
@@ -320,7 +320,10 @@ describe Puppet::Resource::TypeCollection do
320
320
  let(:environment) { Puppet::Node::Environment.create(:testing, [], '', '/my/foo') }
321
321
 
322
322
  it "should use the output of the environment's config_version setting if one is provided" do
323
- Puppet::Util::Execution.expects(:execute).with(["/my/foo"]).returns "output\n"
323
+ Puppet::Util::Execution.expects(:execute)
324
+ .with(["/my/foo"])
325
+ .returns Puppet::Util::Execution::ProcessOutput.new("output\n", 0)
326
+ expect(@code.version).to be_instance_of(String)
324
327
  expect(@code.version).to eq("output")
325
328
  end
326
329
 
@@ -177,6 +177,17 @@ describe Puppet::SSL::CertificateRequest do
177
177
  end
178
178
  end
179
179
 
180
+ context "with DNS and IP SAN specified" do
181
+ before :each do
182
+ Puppet[:dns_alt_names] = ""
183
+ end
184
+
185
+ it "should return the subjectAltName values" do
186
+ request.generate(key, :dns_alt_names => 'DNS:foo, bar, IP:172.16.254.1')
187
+ expect(request.subject_alt_names).to match_array(["DNS:bar", "DNS:foo", "DNS:myname", "IP Address:172.16.254.1"])
188
+ end
189
+ end
190
+
180
191
  context "with custom CSR attributes" do
181
192
 
182
193
  it "adds attributes with single values" do
@@ -287,6 +287,18 @@ describe Puppet::Transaction::EventManager do
287
287
  expect(@transaction.resource_status(@resource)).to be_failed_to_restart
288
288
  end
289
289
 
290
+ it "should set the 'failed' state on the resource status" do
291
+ @manager.process_events(@resource)
292
+ expect(@transaction.resource_status(@resource)).to be_failed
293
+ end
294
+
295
+ it "should record a failed event on the resource status" do
296
+ @manager.process_events(@resource)
297
+
298
+ expect(@transaction.resource_status(@resource).events.length).to eq(1)
299
+ expect(@transaction.resource_status(@resource).events[0].status).to eq('failure')
300
+ end
301
+
290
302
  it "should not queue a 'restarted' event" do
291
303
  @manager.expects(:queue_events).never
292
304
  @manager.process_events(@resource)
@@ -4,12 +4,16 @@ require 'puppet/util/diff'
4
4
  require 'puppet/util/execution'
5
5
 
6
6
  describe Puppet::Util::Diff do
7
+ let(:baz_output) { Puppet::Util::Execution::ProcessOutput.new('baz', 0) }
8
+
7
9
  describe ".diff" do
8
10
  it "should execute the diff command with arguments" do
9
11
  Puppet[:diff] = 'foo'
10
12
  Puppet[:diff_args] = 'bar'
11
13
 
12
- Puppet::Util::Execution.expects(:execute).with(['foo', 'bar', 'a', 'b'], {:failonfail => false, :combine => false}).returns('baz')
14
+ Puppet::Util::Execution.expects(:execute)
15
+ .with(['foo', 'bar', 'a', 'b'], {:failonfail => false, :combine => false})
16
+ .returns(baz_output)
13
17
  expect(subject.diff('a', 'b')).to eq('baz')
14
18
  end
15
19
 
@@ -17,7 +21,9 @@ describe Puppet::Util::Diff do
17
21
  Puppet[:diff] = 'foo'
18
22
  Puppet[:diff_args] = 'bar qux'
19
23
 
20
- Puppet::Util::Execution.expects(:execute).with(['foo', 'bar', 'qux', 'a', 'b'], anything).returns('baz')
24
+ Puppet::Util::Execution.expects(:execute)
25
+ .with(['foo', 'bar', 'qux', 'a', 'b'], anything)
26
+ .returns(baz_output)
21
27
  expect(subject.diff('a', 'b')).to eq('baz')
22
28
  end
23
29
 
@@ -25,7 +31,9 @@ describe Puppet::Util::Diff do
25
31
  Puppet[:diff] = 'foo'
26
32
  Puppet[:diff_args] = ''
27
33
 
28
- Puppet::Util::Execution.expects(:execute).with(['foo', 'a', 'b'], {:failonfail => false, :combine => false}).returns('baz')
34
+ Puppet::Util::Execution.expects(:execute)
35
+ .with(['foo', 'a', 'b'], {:failonfail => false, :combine => false})
36
+ .returns(baz_output)
29
37
  expect(subject.diff('a', 'b')).to eq('baz')
30
38
  end
31
39
 
@@ -821,7 +821,8 @@ describe Puppet::Util::Execution do
821
821
 
822
822
  describe "execfail" do
823
823
  it "returns the executed command output" do
824
- Puppet::Util::Execution.stubs(:execute).returns("process output")
824
+ Puppet::Util::Execution.stubs(:execute)
825
+ .returns(Puppet::Util::Execution::ProcessOutput.new("process output", 0))
825
826
  expect(Puppet::Util::Execution.execfail('echo hello', Puppet::Error)).to eq('process output')
826
827
  end
827
828
 
@@ -108,14 +108,18 @@ describe Puppet::Util::FileType do
108
108
 
109
109
  describe "#read" do
110
110
  it "should run crontab -l as the target user" do
111
- Puppet::Util::Execution.expects(:execute).with(['crontab', '-l'], user_options).returns crontab
111
+ Puppet::Util::Execution.expects(:execute)
112
+ .with(['crontab', '-l'], user_options)
113
+ .returns(Puppet::Util::Execution::ProcessOutput.new(crontab, 0))
112
114
  expect(cron.read).to eq(crontab)
113
115
  end
114
116
 
115
117
  it "should not switch user if current user is the target user" do
116
118
  Puppet::Util.expects(:uid).with(uid).returns 9000
117
119
  Puppet::Util::SUIDManager.expects(:uid).returns 9000
118
- Puppet::Util::Execution.expects(:execute).with(['crontab', '-l'], options).returns crontab
120
+ Puppet::Util::Execution
121
+ .expects(:execute).with(['crontab', '-l'], options)
122
+ .returns(Puppet::Util::Execution::ProcessOutput.new(crontab, 0))
119
123
  expect(cron.read).to eq(crontab)
120
124
  end
121
125
 
@@ -47,24 +47,40 @@ describe Puppet::Util::Log.desttypes[:file] do
47
47
  end
48
48
 
49
49
  describe "on POSIX systems", :if => Puppet.features.posix? do
50
- let (:abspath) { '/tmp/log' }
51
- let (:relpath) { 'log' }
50
+ describe "with a normal file" do
51
+ let (:abspath) { '/tmp/log' }
52
+ let (:relpath) { 'log' }
52
53
 
53
- it_behaves_like "file destination"
54
+ it_behaves_like "file destination"
55
+
56
+ it "logs an error if it can't chown the file owner & group" do
57
+ FileUtils.expects(:chown).with(Puppet[:user], Puppet[:group], abspath).raises(Errno::EPERM)
58
+ Puppet.features.expects(:root?).returns(true)
59
+ Puppet.expects(:err).with("Unable to set ownership to #{Puppet[:user]}:#{Puppet[:group]} for log file: #{abspath}")
54
60
 
55
- it "logs an error if it can't chown the file owner & group" do
56
- FileUtils.expects(:chown).with(Puppet[:user], Puppet[:group], abspath).raises(Errno::EPERM)
57
- Puppet.features.expects(:root?).returns(true)
58
- Puppet.expects(:err).with("Unable to set ownership to #{Puppet[:user]}:#{Puppet[:group]} for log file: #{abspath}")
61
+ @class.new(abspath)
62
+ end
59
63
 
60
- @class.new(abspath)
64
+ it "doesn't attempt to chown when running as non-root" do
65
+ FileUtils.expects(:chown).with(Puppet[:user], Puppet[:group], abspath).never
66
+ Puppet.features.expects(:root?).returns(false)
67
+
68
+ @class.new(abspath)
69
+ end
61
70
  end
62
71
 
63
- it "doesn't attempt to chown when running as non-root" do
64
- FileUtils.expects(:chown).with(Puppet[:user], Puppet[:group], abspath).never
65
- Puppet.features.expects(:root?).returns(false)
72
+ describe "with a JSON file" do
73
+ let (:abspath) { '/tmp/log.json' }
74
+ let (:relpath) { 'log.json' }
75
+
76
+ it_behaves_like "file destination"
66
77
 
67
- @class.new(abspath)
78
+ it "should log messages as JSON" do
79
+ msg = Puppet::Util::Log.new(:level => :info, :message => "don't panic")
80
+ dest = @class.new(abspath)
81
+ dest.handle(msg)
82
+ expect(JSON.parse(File.read(abspath) + ']')).to include(a_hash_including({"message" => "don't panic"}))
83
+ end
68
84
  end
69
85
  end
70
86
 
@@ -92,8 +92,10 @@ describe Puppet::Util::Plist, :if => Puppet.features.cfpropertylist? do
92
92
  subject.stubs(:open_file_with_args).with(plist_path, 'r:UTF-8').returns(invalid_xml_plist)
93
93
  Puppet.expects(:debug).with(regexp_matches(/^Failed with CFFormatError/))
94
94
  Puppet.expects(:debug).with("Plist #{plist_path} ill-formatted, converting with plutil")
95
- Puppet::Util::Execution.expects(:execute).with(['/usr/bin/plutil', '-convert', 'xml1', '-o', '-', plist_path],
96
- {:failonfail => true, :combine => true}).returns(valid_xml_plist)
95
+ Puppet::Util::Execution.expects(:execute)
96
+ .with(['/usr/bin/plutil', '-convert', 'xml1', '-o', '-', plist_path],
97
+ {:failonfail => true, :combine => true})
98
+ .returns(Puppet::Util::Execution::ProcessOutput.new(valid_xml_plist, 0))
97
99
  expect(subject.read_plist_file(plist_path)).to eq(valid_xml_plist_hash)
98
100
  end
99
101
  it "returns nil when direct parsing and plutil conversion both fail" do
@@ -101,8 +103,10 @@ describe Puppet::Util::Plist, :if => Puppet.features.cfpropertylist? do
101
103
  subject.stubs(:open_file_with_args).with(plist_path, 'r:UTF-8').returns(non_plist_data)
102
104
  Puppet.expects(:debug).with(regexp_matches(/^Failed with (CFFormatError|NoMethodError)/))
103
105
  Puppet.expects(:debug).with("Plist #{plist_path} ill-formatted, converting with plutil")
104
- Puppet::Util::Execution.expects(:execute).with(['/usr/bin/plutil', '-convert', 'xml1', '-o', '-', plist_path],
105
- {:failonfail => true, :combine => true}).raises(Puppet::ExecutionFailure, 'boom')
106
+ Puppet::Util::Execution.expects(:execute)
107
+ .with(['/usr/bin/plutil', '-convert', 'xml1', '-o', '-', plist_path],
108
+ {:failonfail => true, :combine => true})
109
+ .raises(Puppet::ExecutionFailure, 'boom')
106
110
  expect(subject.read_plist_file(plist_path)).to eq(nil)
107
111
  end
108
112
  it "returns nil when file is a non-plist binary blob" do
@@ -110,8 +114,10 @@ describe Puppet::Util::Plist, :if => Puppet.features.cfpropertylist? do
110
114
  subject.stubs(:open_file_with_args).with(plist_path, 'r:UTF-8').returns(binary_data)
111
115
  Puppet.expects(:debug).with(regexp_matches(/^Failed with (CFFormatError|ArgumentError)/))
112
116
  Puppet.expects(:debug).with("Plist #{plist_path} ill-formatted, converting with plutil")
113
- Puppet::Util::Execution.expects(:execute).with(['/usr/bin/plutil', '-convert', 'xml1', '-o', '-', plist_path],
114
- {:failonfail => true, :combine => true}).raises(Puppet::ExecutionFailure, 'boom')
117
+ Puppet::Util::Execution.expects(:execute)
118
+ .with(['/usr/bin/plutil', '-convert', 'xml1', '-o', '-', plist_path],
119
+ {:failonfail => true, :combine => true})
120
+ .raises(Puppet::ExecutionFailure, 'boom')
115
121
  expect(subject.read_plist_file(plist_path)).to eq(nil)
116
122
  end
117
123
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.2
4
+ version: 5.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-29 00:00:00.000000000 Z
11
+ date: 2018-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facter