puppet 5.5.14-x64-mingw32 → 5.5.16-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.

Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +18 -17
  4. data/ext/solaris/smf/puppet.xml +2 -0
  5. data/lib/hiera/scope.rb +7 -0
  6. data/lib/puppet.rb +1 -1
  7. data/lib/puppet/application/device.rb +22 -10
  8. data/lib/puppet/configurer.rb +23 -38
  9. data/lib/puppet/network/http/connection.rb +2 -0
  10. data/lib/puppet/pops/types/types.rb +5 -3
  11. data/lib/puppet/provider.rb +1 -2
  12. data/lib/puppet/provider/cron/crontab.rb +1 -1
  13. data/lib/puppet/provider/package.rb +2 -0
  14. data/lib/puppet/provider/package/dpkg.rb +15 -2
  15. data/lib/puppet/provider/package/gem.rb +65 -29
  16. data/lib/puppet/provider/package/pip.rb +136 -111
  17. data/lib/puppet/provider/package/pip3.rb +1 -1
  18. data/lib/puppet/provider/package/puppet_gem.rb +1 -1
  19. data/lib/puppet/provider/package/rpm.rb +27 -16
  20. data/lib/puppet/provider/package/yum.rb +1 -1
  21. data/lib/puppet/provider/package_targetable.rb +68 -0
  22. data/lib/puppet/provider/service/upstart.rb +8 -8
  23. data/lib/puppet/provider/user/useradd.rb +16 -13
  24. data/lib/puppet/settings/server_list_setting.rb +9 -0
  25. data/lib/puppet/ssl/validator/default_validator.rb +30 -0
  26. data/lib/puppet/type/package.rb +46 -9
  27. data/lib/puppet/util/pidlock.rb +15 -1
  28. data/lib/puppet/util/windows/process.rb +70 -0
  29. data/lib/puppet/util/windows/registry.rb +7 -1
  30. data/lib/puppet/util/windows/user.rb +14 -4
  31. data/lib/puppet/version.rb +1 -1
  32. data/locales/puppet.pot +81 -78
  33. data/man/man5/puppet.conf.5 +2 -2
  34. data/man/man8/puppet-agent.8 +1 -1
  35. data/man/man8/puppet-apply.8 +1 -1
  36. data/man/man8/puppet-ca.8 +1 -1
  37. data/man/man8/puppet-catalog.8 +1 -1
  38. data/man/man8/puppet-cert.8 +1 -1
  39. data/man/man8/puppet-certificate.8 +1 -1
  40. data/man/man8/puppet-certificate_request.8 +1 -1
  41. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  42. data/man/man8/puppet-config.8 +1 -1
  43. data/man/man8/puppet-describe.8 +1 -1
  44. data/man/man8/puppet-device.8 +1 -1
  45. data/man/man8/puppet-doc.8 +1 -1
  46. data/man/man8/puppet-epp.8 +1 -1
  47. data/man/man8/puppet-facts.8 +1 -1
  48. data/man/man8/puppet-filebucket.8 +1 -1
  49. data/man/man8/puppet-generate.8 +1 -1
  50. data/man/man8/puppet-help.8 +1 -1
  51. data/man/man8/puppet-key.8 +1 -1
  52. data/man/man8/puppet-lookup.8 +1 -1
  53. data/man/man8/puppet-man.8 +1 -1
  54. data/man/man8/puppet-master.8 +1 -1
  55. data/man/man8/puppet-module.8 +1 -1
  56. data/man/man8/puppet-node.8 +1 -1
  57. data/man/man8/puppet-parser.8 +1 -1
  58. data/man/man8/puppet-plugin.8 +1 -1
  59. data/man/man8/puppet-report.8 +1 -1
  60. data/man/man8/puppet-resource.8 +1 -1
  61. data/man/man8/puppet-script.8 +1 -1
  62. data/man/man8/puppet-status.8 +1 -1
  63. data/man/man8/puppet.8 +2 -2
  64. data/spec/integration/network/http_pool_spec.rb +120 -0
  65. data/spec/integration/type/package_spec.rb +1 -1
  66. data/spec/integration/util/windows/registry_spec.rb +52 -0
  67. data/spec/integration/util/windows/user_spec.rb +19 -0
  68. data/spec/lib/puppet_spec/https.rb +166 -0
  69. data/spec/unit/configurer_spec.rb +49 -13
  70. data/spec/unit/functions/new_spec.rb +15 -0
  71. data/spec/unit/hiera/scope_spec.rb +7 -0
  72. data/spec/unit/network/http/connection_spec.rb +0 -130
  73. data/spec/unit/provider/package/dpkg_spec.rb +18 -1
  74. data/spec/unit/provider/package/gem_spec.rb +101 -48
  75. data/spec/unit/provider/package/pip3_spec.rb +17 -0
  76. data/spec/unit/provider/package/pip_spec.rb +59 -68
  77. data/spec/unit/provider/package/puppet_gem_spec.rb +22 -6
  78. data/spec/unit/provider/package/rpm_spec.rb +116 -27
  79. data/spec/unit/provider/service/upstart_spec.rb +3 -19
  80. data/spec/unit/settings/server_list_setting_spec.rb +21 -0
  81. data/spec/unit/ssl/validator_spec.rb +2 -0
  82. data/spec/unit/util/pidlock_spec.rb +46 -0
  83. metadata +9 -2
@@ -33,40 +33,56 @@ describe Puppet::Type.type(:package).provider(:puppet_gem) do
33
33
  end
34
34
 
35
35
  it "should use the path to the gem command" do
36
- allow(described_class).to receive(:which).with(provider_gem_cmd).and_return(provider_gem_cmd)
36
+ allow(described_class).to receive(:validate_command).with(provider_gem_cmd)
37
37
  expect(described_class).to receive(:execute).with(be_a(Array), execute_options) { |args| expect(args[0]).to eq(provider_gem_cmd) }.and_return('')
38
38
  provider.install
39
39
  end
40
40
 
41
41
  it "should not append install_options by default" do
42
- expect(described_class).to receive(:execute_gem_command).with(%w{install --no-rdoc --no-ri myresource}).and_return('')
42
+ expect(described_class).to receive(:execute_gem_command).with(provider_gem_cmd, %w{install --no-rdoc --no-ri myresource}).and_return('')
43
43
  provider.install
44
44
  end
45
45
 
46
46
  it "should allow setting an install_options parameter" do
47
47
  resource[:install_options] = [ '--force', {'--bindir' => '/usr/bin' } ]
48
- expect(described_class).to receive(:execute_gem_command).with(%w{install --force --bindir=/usr/bin --no-rdoc --no-ri myresource}).and_return('')
48
+ expect(described_class).to receive(:execute_gem_command).with(provider_gem_cmd, %w{install --force --bindir=/usr/bin --no-rdoc --no-ri myresource}).and_return('')
49
49
  provider.install
50
50
  end
51
51
  end
52
52
 
53
53
  context "when uninstalling" do
54
54
  it "should use the path to the gem command" do
55
- allow(described_class).to receive(:which).with(provider_gem_cmd).and_return(provider_gem_cmd)
55
+ allow(described_class).to receive(:validate_command).with(provider_gem_cmd)
56
56
  expect(described_class).to receive(:execute).with(be_a(Array), execute_options) { |args| expect(args[0]).to eq(provider_gem_cmd) }.and_return('')
57
57
  provider.uninstall
58
58
  end
59
59
 
60
60
  it "should not append uninstall_options by default" do
61
- expect(described_class).to receive(:execute_gem_command).with(%w{uninstall --executables --all myresource}).and_return('')
61
+ expect(described_class).to receive(:execute_gem_command).with(provider_gem_cmd, %w{uninstall --executables --all myresource}).and_return('')
62
62
  provider.uninstall
63
63
  end
64
64
 
65
65
  it "should allow setting an uninstall_options parameter" do
66
66
  resource[:uninstall_options] = [ '--force', {'--bindir' => '/usr/bin' } ]
67
- expect(described_class).to receive(:execute_gem_command).with(%w{uninstall --executables --all myresource --force --bindir=/usr/bin}).and_return('')
67
+ expect(described_class).to receive(:execute_gem_command).with(provider_gem_cmd, %w{uninstall --executables --all myresource --force --bindir=/usr/bin}).and_return('')
68
68
  provider.uninstall
69
69
  end
70
70
  end
71
71
 
72
+ context 'calculated specificity' do
73
+ context 'when is not defaultfor' do
74
+ subject { described_class.specificity }
75
+ it { is_expected.to eql 1 }
76
+ end
77
+
78
+ context 'when is defaultfor' do
79
+ let(:os) { Facter.value(:operatingsystem) }
80
+ subject do
81
+ described_class.defaultfor(operatingsystem: os)
82
+ described_class.specificity
83
+ end
84
+ it { is_expected.to be > 100 }
85
+ end
86
+ end
87
+
72
88
  end
@@ -56,7 +56,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
56
56
  describe "self.instances" do
57
57
  describe "with a modern version of RPM" do
58
58
  it "includes all the modern flags" do
59
- expect(Puppet::Util::Execution).to receive(:execpipe).with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}'").and_yield(packages)
59
+ expect(Puppet::Util::Execution).to receive(:execpipe)
60
+ .with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}'")
61
+ .and_yield(packages)
60
62
 
61
63
  described_class.instances
62
64
  end
@@ -66,7 +68,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
66
68
  let(:rpm_version) { "RPM version 4.0.2\n" }
67
69
 
68
70
  it "excludes the --nosignature flag" do
69
- expect(Puppet::Util::Execution).to receive(:execpipe).with("/bin/rpm -qa --nodigest --qf '#{nevra_format}'").and_yield(packages)
71
+ expect(Puppet::Util::Execution).to receive(:execpipe)
72
+ .with("/bin/rpm -qa --nodigest --qf '#{nevra_format}'")
73
+ .and_yield(packages)
70
74
 
71
75
  described_class.instances
72
76
  end
@@ -76,14 +80,18 @@ describe Puppet::Type.type(:package).provider(:rpm) do
76
80
  let(:rpm_version) { "RPM version 3.0.5\n" }
77
81
 
78
82
  it "excludes the --nodigest flag" do
79
- expect(Puppet::Util::Execution).to receive(:execpipe).with("/bin/rpm -qa --qf '#{nevra_format}'").and_yield(packages)
83
+ expect(Puppet::Util::Execution).to receive(:execpipe)
84
+ .with("/bin/rpm -qa --qf '#{nevra_format}'")
85
+ .and_yield(packages)
80
86
 
81
87
  described_class.instances
82
88
  end
83
89
  end
84
90
 
85
91
  it "returns an array of packages" do
86
- expect(Puppet::Util::Execution).to receive(:execpipe).with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}'").and_yield(packages)
92
+ expect(Puppet::Util::Execution).to receive(:execpipe)
93
+ .with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}'")
94
+ .and_yield(packages)
87
95
 
88
96
  installed_packages = described_class.instances
89
97
 
@@ -167,7 +175,8 @@ describe Puppet::Type.type(:package).provider(:rpm) do
167
175
 
168
176
  describe "when not already installed" do
169
177
  it "only includes the '-i' flag" do
170
- expect(Puppet::Util::Execution).to receive(:execute).with(["/bin/rpm", ["-i"], '/path/to/package'], execute_options)
178
+ expect(Puppet::Util::Execution).to receive(:execute)
179
+ .with(["/bin/rpm", ["-i"], '/path/to/package'], execute_options)
171
180
  provider.install
172
181
  end
173
182
  end
@@ -184,7 +193,8 @@ describe Puppet::Type.type(:package).provider(:rpm) do
184
193
  end
185
194
 
186
195
  it "includes the options" do
187
- expect(Puppet::Util::Execution).to receive(:execute).with(["/bin/rpm", ["-i", "-D", "--test=value", "-Q"], '/path/to/package'], execute_options)
196
+ expect(Puppet::Util::Execution).to receive(:execute)
197
+ .with(["/bin/rpm", ["-i", "-D", "--test=value", "-Q"], '/path/to/package'], execute_options)
188
198
  provider.install
189
199
  end
190
200
  end
@@ -197,7 +207,8 @@ describe Puppet::Type.type(:package).provider(:rpm) do
197
207
  end
198
208
 
199
209
  it "includes the '-U --oldpackage' flags" do
200
- expect(Puppet::Util::Execution).to receive(:execute).with(["/bin/rpm", ["-U", "--oldpackage"], '/path/to/package'], execute_options)
210
+ expect(Puppet::Util::Execution).to receive(:execute)
211
+ .with(["/bin/rpm", ["-U", "--oldpackage"], '/path/to/package'], execute_options)
201
212
  provider.install
202
213
  end
203
214
  end
@@ -214,7 +225,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
214
225
 
215
226
  it "raises an error if the rpm command fails" do
216
227
  expect(resource).to receive(:[]).with(:source).and_return('source-string')
217
- expect(Puppet::Util::Execution).to receive(:execute).with(["/bin/rpm", "-q", "--qf", "'#{nevra_format}'", "-p", "source-string"]).and_raise(Puppet::ExecutionFailure, 'rpm command failed')
228
+ expect(Puppet::Util::Execution).to receive(:execute)
229
+ .with(["/bin/rpm", "-q", "--qf", "'#{nevra_format}'", "-p", "source-string"])
230
+ .and_raise(Puppet::ExecutionFailure, 'rpm command failed')
218
231
 
219
232
  expect {
220
233
  provider.latest
@@ -225,52 +238,115 @@ describe Puppet::Type.type(:package).provider(:rpm) do
225
238
  describe "#uninstall" do
226
239
  let(:resource) do
227
240
  Puppet::Type.type(:package).new(
228
- :name => 'myresource',
229
- :ensure => :installed
241
+ :name => resource_name,
242
+ :ensure => :installed
230
243
  )
231
244
  end
232
245
 
246
+ describe "on an ancient RPM" do
247
+ let(:rpm_version) { "RPM version 3.0.6\n" }
248
+
249
+ before(:each) do
250
+ expect(Puppet::Util::Execution).to receive(:execute)
251
+ .with(["/bin/rpm", "-q", resource_name, '', '', '--qf', "'#{nevra_format}'"], execute_options)
252
+ .and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
253
+ end
254
+
255
+ it "excludes the architecture from the package name" do
256
+ expect(Puppet::Util::Execution).to receive(:execute)
257
+ .with(["/bin/rpm", ["-e"], resource_name], execute_options)
258
+ .and_return(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most(:once)
259
+ provider.uninstall
260
+ end
261
+ end
262
+
233
263
  describe "on a modern RPM" do
264
+ let(:rpm_version) { "RPM version 4.10.0\n" }
265
+
266
+
234
267
  before(:each) do
235
268
  expect(Puppet::Util::Execution).to receive(:execute)
236
- .with(["/bin/rpm", "-q", "myresource", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
237
- .and_return(Puppet::Util::Execution::ProcessOutput.new("myresource 0 1.2.3.4 5.el4 noarch\n", 0))
269
+ .with(["/bin/rpm", "-q", resource_name, '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
270
+ .and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
238
271
  end
239
272
 
273
+ it "excludes the architecture from the package name" do
274
+ expect(Puppet::Util::Execution).to receive(:execute)
275
+ .with(["/bin/rpm", ["-e"], resource_name], execute_options)
276
+ .and_return(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most(:once)
277
+ provider.uninstall
278
+ end
279
+ end
280
+
281
+ describe "on a modern RPM when architecture is specified" do
240
282
  let(:rpm_version) { "RPM version 4.10.0\n" }
241
283
 
284
+ let(:resource) do
285
+ Puppet::Type.type(:package).new(
286
+ :name => "#{resource_name}.noarch",
287
+ :ensure => :absent,
288
+ )
289
+ end
290
+
291
+ before(:each) do
292
+ expect(Puppet::Util::Execution).to receive(:execute)
293
+ .with(["/bin/rpm", "-q", "#{resource_name}.noarch", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
294
+ .and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
295
+ end
296
+
242
297
  it "includes the architecture in the package name" do
243
298
  expect(Puppet::Util::Execution).to receive(:execute)
244
- .with(["/bin/rpm", ["-e"], 'myresource-1.2.3.4-5.el4.noarch'], execute_options)
299
+ .with(["/bin/rpm", ["-e"], "#{resource_name}.noarch"], execute_options)
245
300
  .and_return(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most(:once)
246
301
  provider.uninstall
247
302
  end
248
303
  end
249
304
 
250
- describe "on an ancient RPM" do
305
+ describe "when version and release are specified" do
306
+ let(:resource) do
307
+ Puppet::Type.type(:package).new(
308
+ :name => "#{resource_name}-1.2.3.4-5.el4",
309
+ :ensure => :absent,
310
+ )
311
+ end
312
+
251
313
  before(:each) do
252
314
  expect(Puppet::Util::Execution).to receive(:execute)
253
- .with(["/bin/rpm", "-q", "myresource", '', '', '--qf', "'#{nevra_format}'"], execute_options)
254
- .and_return(Puppet::Util::Execution::ProcessOutput.new("myresource 0 1.2.3.4 5.el4 noarch\n", 0))
315
+ .with(["/bin/rpm", "-q", "#{resource_name}-1.2.3.4-5.el4", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
316
+ .and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
255
317
  end
256
318
 
257
- let(:rpm_version) { "RPM version 3.0.6\n" }
258
-
259
- it "excludes the architecture from the package name" do
319
+ it "includes the version and release in the package name" do
260
320
  expect(Puppet::Util::Execution).to receive(:execute)
261
- .with(["/bin/rpm", ["-e"], 'myresource-1.2.3.4-5.el4'], execute_options)
321
+ .with(["/bin/rpm", ["-e"], "#{resource_name}-1.2.3.4-5.el4"], execute_options)
262
322
  .and_return(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most(:once)
263
323
  provider.uninstall
264
324
  end
265
325
  end
266
326
 
267
- describe "when uninstalled with options" do
327
+ describe "when only version is specified" do
328
+ let(:resource) do
329
+ Puppet::Type.type(:package).new(
330
+ :name => "#{resource_name}-1.2.3.4",
331
+ :ensure => :absent,
332
+ )
333
+ end
334
+
268
335
  before(:each) do
269
336
  expect(Puppet::Util::Execution).to receive(:execute)
270
- .with(["/bin/rpm", "-q", "myresource", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
271
- .and_return(Puppet::Util::Execution::ProcessOutput.new("myresource 0 1.2.3.4 5.el4 noarch\n", 0))
337
+ .with(["/bin/rpm", "-q", "#{resource_name}-1.2.3.4", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
338
+ .and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
272
339
  end
273
340
 
341
+ it "includes the version in the package name" do
342
+ expect(Puppet::Util::Execution).to receive(:execute)
343
+ .with(["/bin/rpm", ["-e"], "#{resource_name}-1.2.3.4"], execute_options)
344
+ .and_return(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most(:once)
345
+ provider.uninstall
346
+ end
347
+ end
348
+
349
+ describe "when uninstalled with options" do
274
350
  let(:resource) do
275
351
  Puppet::Type.type(:package).new(
276
352
  :name => resource_name,
@@ -280,8 +356,15 @@ describe Puppet::Type.type(:package).provider(:rpm) do
280
356
  )
281
357
  end
282
358
 
359
+ before(:each) do
360
+ expect(Puppet::Util::Execution).to receive(:execute)
361
+ .with(["/bin/rpm", "-q", resource_name, '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
362
+ .and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
363
+ end
364
+
283
365
  it "includes the options" do
284
- expect(Puppet::Util::Execution).to receive(:execute).with(["/bin/rpm", ["-e", "--nodeps"], 'myresource-1.2.3.4-5.el4.noarch'], execute_options)
366
+ expect(Puppet::Util::Execution).to receive(:execute)
367
+ .with(["/bin/rpm", ["-e", "--nodeps"], resource_name], execute_options)
285
368
  provider.uninstall
286
369
  end
287
370
  end
@@ -331,7 +414,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
331
414
  before do
332
415
  expect(Puppet).not_to receive(:debug)
333
416
  expected_args = ["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "'#{nevra_format}'"]
334
- expect(Puppet::Util::Execution).to receive(:execute).with(expected_args, execute_options).and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not installed"))
417
+ expect(Puppet::Util::Execution).to receive(:execute)
418
+ .with(expected_args, execute_options)
419
+ .and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not installed"))
335
420
  end
336
421
 
337
422
  it "does not log or fail if allow_virtual is false" do
@@ -342,7 +427,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
342
427
  it "does not log or fail if allow_virtual is true" do
343
428
  resource[:allow_virtual] = true
344
429
  expected_args = ['/bin/rpm', '-q', resource_name, '--nosignature', '--nodigest', '--qf', "'#{nevra_format}'", '--whatprovides']
345
- expect(Puppet::Util::Execution).to receive(:execute).with(expected_args, execute_options).and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not provided"))
430
+ expect(Puppet::Util::Execution).to receive(:execute)
431
+ .with(expected_args, execute_options)
432
+ .and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not provided"))
346
433
  expect(provider.query).to be_nil
347
434
  end
348
435
  end
@@ -350,7 +437,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
350
437
  it "parses virtual package" do
351
438
  provider.resource[:allow_virtual] = true
352
439
  expected_args = ["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "'#{nevra_format}'"]
353
- expect(Puppet::Util::Execution).to receive(:execute).with(expected_args, execute_options).and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not installed"))
440
+ expect(Puppet::Util::Execution).to receive(:execute)
441
+ .with(expected_args, execute_options)
442
+ .and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not installed"))
354
443
  expect(Puppet::Util::Execution).to receive(:execute)
355
444
  .with(expected_args + ["--whatprovides"], execute_options)
356
445
  .and_return(Puppet::Util::Execution::ProcessOutput.new("myresource 0 1.2.3.4 5.el4 noarch\n", 0))
@@ -33,32 +33,16 @@ describe Puppet::Type.type(:service).provider(:upstart) do
33
33
  end
34
34
 
35
35
  context "upstart daemon existence confine" do
36
- # We have a separate method here because our search for the upstart daemon
37
- # confine expects it to be the last confine declared in the upstart provider.
38
- # If in the future we add other confines below it or change its order, these
39
- # unit tests will fail. Placing knowledge of where this confine is located
40
- # in one place makes updating it less painful in case we ever need to do this.
41
- def assert_upstart_daemon_existence_confine_is(expected_value)
42
- upstart_daemon_existence_confine = provider_class.confine_collection.instance_variable_get(:@confines)[-1]
43
- expect(upstart_daemon_existence_confine.valid?).to be(expected_value)
44
- end
45
-
46
36
  let(:initctl_version) { ['/sbin/initctl', 'version', '--quiet'] }
47
37
 
48
38
  before(:each) do
49
- # Stub out /sbin/initctl
50
39
  allow(Puppet::Util).to receive(:which).with('/sbin/initctl').and_return('/sbin/initctl')
51
-
52
- # Both of our tests are asserting the confine :true block that shells out to
53
- # `initctl version --quiet`. Its expression is evaluated at provider load-time.
54
- # Hence before each test, we want to reload the upstart provider so that the
55
- # confine is re-evaluated.
56
- Puppet::Type.type(:service).unprovide(:upstart)
57
40
  end
58
41
 
59
42
  it "should return true when the daemon is running" do
60
43
  expect(Puppet::Util::Execution).to receive(:execute).with(initctl_version, instance_of(Hash))
61
- assert_upstart_daemon_existence_confine_is(true)
44
+
45
+ expect(provider_class).to be_has_initctl
62
46
  end
63
47
 
64
48
  it "should return false when the daemon is not running" do
@@ -66,7 +50,7 @@ describe Puppet::Type.type(:service).provider(:upstart) do
66
50
  .with(initctl_version, instance_of(Hash))
67
51
  .and_raise(Puppet::ExecutionFailure, "initctl failed!")
68
52
 
69
- assert_upstart_daemon_existence_confine_is(false)
53
+ expect(provider_class).to_not be_has_initctl
70
54
  end
71
55
  end
72
56
 
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ require 'puppet/settings/server_list_setting'
3
+
4
+ describe Puppet::Settings::ServerListSetting do
5
+
6
+ it "prints strings as strings" do
7
+ settings = Puppet::Settings.new
8
+ settings.define_settings(:main, neptune: {type: :server_list, desc: 'list of servers'})
9
+ server_list_setting = settings.setting(:neptune)
10
+ expect(server_list_setting.print("jupiter,mars")).to eq("jupiter,mars")
11
+ end
12
+
13
+ it "prints arrays as strings" do
14
+ settings = Puppet::Settings.new
15
+ settings.define_settings(:main, neptune: {type: :server_list, desc: 'list of servers'})
16
+ server_list_setting = settings.setting(:neptune)
17
+ expect(server_list_setting.print([["main", 1234],["production", 8140]])).to eq("main:1234,production:8140")
18
+ expect(server_list_setting.print([])).to eq("")
19
+ end
20
+
21
+ end
@@ -186,6 +186,7 @@ describe Puppet::SSL::Validator::DefaultValidator do
186
186
  allow(subject).to receive(:ssl_certificates_are_present?).and_return(true)
187
187
  connection = double('Net::HTTP')
188
188
 
189
+ allow(connection).to receive(:address).and_return('puppet.com')
189
190
  expect(connection).to receive(:cert_store=).with(ssl_host.ssl_store)
190
191
  expect(connection).to receive(:ca_file=).with(ssl_configuration.ca_auth_file)
191
192
  expect(connection).to receive(:cert=).with(ssl_host.certificate.content)
@@ -200,6 +201,7 @@ describe Puppet::SSL::Validator::DefaultValidator do
200
201
  allow(subject).to receive(:ssl_certificates_are_present?).and_return(false)
201
202
  connection = double('Net::HTTP')
202
203
 
204
+ allow(connection).to receive(:address).and_return('puppet.com')
203
205
  expect(connection).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE)
204
206
 
205
207
  subject.setup_connection(connection)
@@ -22,6 +22,23 @@ describe Puppet::Util::Pidlock do
22
22
 
23
23
  it "should become locked" do
24
24
  @lock.lock
25
+ if Puppet::Util::Platform.windows?
26
+ allow(Puppet::Util::Windows::Process).to receive(:get_process_image_name_by_pid).with(@lock.lock_pid).and_return('C:\Program Files\Puppet Labs\Puppet\puppet\bin\ruby.exe')
27
+ else
28
+ allow(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', @lock.lock_pid, '-o', 'comm=']).and_return('puppet')
29
+ allow(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', @lock.lock_pid, '-o', 'args=']).and_return('puppet')
30
+ end
31
+ expect(@lock).to be_locked
32
+ end
33
+
34
+ it "should become locked if puppet is a gem" do
35
+ @lock.lock
36
+ unless Puppet::Util::Platform.windows?
37
+ expect(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', @lock.lock_pid, '-o', 'comm=']).and_return('ruby')
38
+ expect(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', @lock.lock_pid, '-o', 'args=']).and_return('ruby /root/puppet/.bundle/ruby/2.3.0/bin/puppet agent --no-daemonize -v')
39
+ else
40
+ allow(Puppet::Util::Windows::Process).to receive(:get_process_image_name_by_pid).with(@lock.lock_pid).and_return('C:\tools\ruby25\bin\ruby.exe')
41
+ end
25
42
  expect(@lock).to be_locked
26
43
  end
27
44
 
@@ -100,6 +117,23 @@ describe Puppet::Util::Pidlock do
100
117
  describe "#locked?" do
101
118
  it "should return true if locked" do
102
119
  @lock.lock
120
+ if Puppet::Util::Platform.windows?
121
+ allow(Puppet::Util::Windows::Process).to receive(:get_process_image_name_by_pid).with(@lock.lock_pid).and_return('C:\Program Files\Puppet Labs\Puppet\puppet\bin\ruby.exe')
122
+ else
123
+ allow(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', @lock.lock_pid, '-o', 'comm=']).and_return('puppet')
124
+ allow(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', @lock.lock_pid, '-o', 'args=']).and_return('puppet')
125
+ end
126
+ expect(@lock).to be_locked
127
+ end
128
+
129
+ it "should return true if locked when puppet as gem" do
130
+ @lock.lock
131
+ unless Puppet::Util::Platform.windows?
132
+ expect(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', @lock.lock_pid, '-o', 'comm=']).and_return('ruby')
133
+ expect(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', @lock.lock_pid, '-o', 'args=']).and_return('ruby /root/puppet/.bundle/ruby/2.3.0/bin/puppet agent --no-daemonize -v')
134
+ else
135
+ allow(Puppet::Util::Windows::Process).to receive(:get_process_image_name_by_pid).with(@lock.lock_pid).and_return('C:\tools\ruby25\bin\ruby.exe')
136
+ end
103
137
  expect(@lock).to be_locked
104
138
  end
105
139
 
@@ -145,6 +179,12 @@ describe Puppet::Util::Pidlock do
145
179
  end
146
180
 
147
181
  it "should replace with new locks" do
182
+ if Puppet::Util::Platform.windows?
183
+ allow(Puppet::Util::Windows::Process).to receive(:get_process_image_name_by_pid).with(6789).and_return('C:\Program Files\Puppet Labs\Puppet\puppet\bin\ruby.exe')
184
+ else
185
+ allow(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', 6789, '-o', 'comm=']).and_return('puppet')
186
+ allow(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', 6789, '-o', 'args=']).and_return('puppet')
187
+ end
148
188
  @lock.lock
149
189
  expect(Puppet::FileSystem.exist?(@lockfile)).to be_truthy
150
190
  expect(@lock.lock_pid).to eq(6789)
@@ -169,6 +209,12 @@ describe Puppet::Util::Pidlock do
169
209
  before(:each) do
170
210
  # fake our pid to be 1234
171
211
  allow(Process).to receive(:pid).and_return(1234)
212
+ if Puppet::Util::Platform.windows?
213
+ allow(Puppet::Util::Windows::Process).to receive(:get_process_image_name_by_pid).with(1234).and_return('C:\Program Files\Puppet Labs\Puppet\puppet\bin\ruby.exe')
214
+ else
215
+ allow(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', 1234, '-o', 'comm=']).and_return('puppet')
216
+ allow(Puppet::Util::Execution).to receive(:execute).with(['ps', '-p', 1234, '-o', 'args=']).and_return('puppet')
217
+ end
172
218
  # lock the file
173
219
  @lock.lock
174
220
  # fake our pid to be a different pid, to simulate someone else