puppet 5.5.18-x86-mingw32 → 5.5.19-x86-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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +12 -11
  3. data/lib/puppet.rb +5 -2
  4. data/lib/puppet/application/filebucket.rb +13 -0
  5. data/lib/puppet/defaults.rb +60 -33
  6. data/lib/puppet/indirector/catalog/compiler.rb +8 -0
  7. data/lib/puppet/network/http/connection.rb +4 -0
  8. data/lib/puppet/network/http/pool.rb +5 -1
  9. data/lib/puppet/pops/evaluator/access_operator.rb +2 -2
  10. data/lib/puppet/pops/evaluator/evaluator_impl.rb +1 -1
  11. data/lib/puppet/pops/types/type_calculator.rb +24 -0
  12. data/lib/puppet/provider/group/groupadd.rb +19 -19
  13. data/lib/puppet/provider/mailalias/aliases.rb +1 -1
  14. data/lib/puppet/provider/package/apt.rb +14 -3
  15. data/lib/puppet/provider/package/dnfmodule.rb +9 -2
  16. data/lib/puppet/provider/package/dpkg.rb +13 -6
  17. data/lib/puppet/provider/package/fink.rb +20 -3
  18. data/lib/puppet/provider/package/openbsd.rb +13 -1
  19. data/lib/puppet/provider/package/pkg.rb +18 -5
  20. data/lib/puppet/provider/package/yum.rb +9 -5
  21. data/lib/puppet/provider/user/directoryservice.rb +30 -5
  22. data/lib/puppet/provider/user/useradd.rb +5 -6
  23. data/lib/puppet/ssl/certificate.rb +2 -1
  24. data/lib/puppet/ssl/certificate_authority.rb +6 -5
  25. data/lib/puppet/test/test_helper.rb +7 -0
  26. data/lib/puppet/transaction/resource_harness.rb +1 -1
  27. data/lib/puppet/type/file.rb +13 -0
  28. data/lib/puppet/type/package.rb +63 -9
  29. data/lib/puppet/util/plist.rb +6 -0
  30. data/lib/puppet/version.rb +1 -1
  31. data/locales/puppet.pot +100 -92
  32. data/man/man5/puppet.conf.5 +12 -6
  33. data/man/man8/puppet-agent.8 +1 -1
  34. data/man/man8/puppet-apply.8 +1 -1
  35. data/man/man8/puppet-ca.8 +1 -1
  36. data/man/man8/puppet-catalog.8 +1 -1
  37. data/man/man8/puppet-cert.8 +1 -1
  38. data/man/man8/puppet-certificate.8 +1 -1
  39. data/man/man8/puppet-certificate_request.8 +1 -1
  40. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  41. data/man/man8/puppet-config.8 +1 -1
  42. data/man/man8/puppet-describe.8 +1 -1
  43. data/man/man8/puppet-device.8 +1 -1
  44. data/man/man8/puppet-doc.8 +1 -1
  45. data/man/man8/puppet-epp.8 +1 -1
  46. data/man/man8/puppet-facts.8 +1 -1
  47. data/man/man8/puppet-filebucket.8 +16 -1
  48. data/man/man8/puppet-generate.8 +1 -1
  49. data/man/man8/puppet-help.8 +1 -1
  50. data/man/man8/puppet-key.8 +1 -1
  51. data/man/man8/puppet-lookup.8 +1 -1
  52. data/man/man8/puppet-man.8 +1 -1
  53. data/man/man8/puppet-master.8 +1 -1
  54. data/man/man8/puppet-module.8 +1 -1
  55. data/man/man8/puppet-node.8 +1 -1
  56. data/man/man8/puppet-parser.8 +1 -1
  57. data/man/man8/puppet-plugin.8 +1 -1
  58. data/man/man8/puppet-report.8 +1 -1
  59. data/man/man8/puppet-resource.8 +1 -1
  60. data/man/man8/puppet-script.8 +1 -1
  61. data/man/man8/puppet-status.8 +1 -1
  62. data/man/man8/puppet.8 +2 -2
  63. data/spec/fixtures/integration/provider/mailalias/aliases/test1 +1 -0
  64. data/spec/integration/indirector/facts/facter_spec.rb +4 -0
  65. data/spec/unit/application/apply_spec.rb +2 -12
  66. data/spec/unit/configurer/fact_handler_spec.rb +0 -4
  67. data/spec/unit/configurer_spec.rb +0 -3
  68. data/spec/unit/indirector/catalog/compiler_spec.rb +45 -26
  69. data/spec/unit/network/http/connection_spec.rb +17 -1
  70. data/spec/unit/network/http/pool_spec.rb +32 -0
  71. data/spec/unit/node_spec.rb +7 -4
  72. data/spec/unit/provider/group/groupadd_spec.rb +30 -1
  73. data/spec/unit/provider/package/apt_spec.rb +13 -2
  74. data/spec/unit/provider/package/aptitude_spec.rb +1 -0
  75. data/spec/unit/provider/package/dnfmodule_spec.rb +22 -0
  76. data/spec/unit/provider/package/dpkg_spec.rb +20 -4
  77. data/spec/unit/provider/package/openbsd_spec.rb +17 -0
  78. data/spec/unit/provider/package/pkg_spec.rb +13 -1
  79. data/spec/unit/provider/package/yum_spec.rb +50 -0
  80. data/spec/unit/provider/user/directoryservice_spec.rb +41 -0
  81. data/spec/unit/provider/user/useradd_spec.rb +7 -2
  82. data/spec/unit/puppet_pal_2pec.rb +3 -0
  83. data/spec/unit/ssl/certificate_authority_spec.rb +2 -3
  84. data/spec/unit/ssl/certificate_spec.rb +7 -0
  85. data/spec/unit/type/package_spec.rb +8 -0
  86. data/spec/unit/util/plist_spec.rb +20 -0
  87. metadata +2 -2
@@ -33,6 +33,7 @@ describe Puppet::Type.type(:package).provider(:aptitude) do
33
33
  expect(pkg.provider).to receive(:aptitude).
34
34
  with('-y', '-o', 'DPkg::Options::=--force-confold', :install, 'faff').
35
35
  and_return(0)
36
+ expect(pkg.provider).to receive(:properties).and_return({:mark => :none})
36
37
 
37
38
  pkg.provider.install
38
39
  end
@@ -161,6 +161,28 @@ describe Puppet::Type.type(:package).provider(:dnfmodule) do
161
161
  provider.install
162
162
  end
163
163
  end
164
+
165
+ context "with an installed flavor" do
166
+ before do
167
+ provider.instance_variable_get('@property_hash')[:flavor] = 'minimal'
168
+ end
169
+
170
+ it "should remove existing packages and reset the module stream before installing another flavor" do
171
+ resource[:flavor] = 'common'
172
+ expect(provider).to receive(:execute).thrice.with(array_including(/remove|reset|install/))
173
+ provider.flavor = resource[:flavor]
174
+ end
175
+
176
+ it "should not do anything if the flavor doesn't change" do
177
+ resource[:flavor] = 'minimal'
178
+ expect(provider).not_to receive(:execute)
179
+ provider.flavor = resource[:flavor]
180
+ end
181
+
182
+ it "should return the existing flavor" do
183
+ expect(provider.flavor).to eq('minimal')
184
+ end
185
+ end
164
186
  end
165
187
 
166
188
  context "parsing the output of module list --installed" do
@@ -126,7 +126,10 @@ describe Puppet::Type.type(:package).provider(:dpkg) do
126
126
 
127
127
  it "considers the package held if its state is 'hold'" do
128
128
  dpkg_query_execution_returns(bash_installed_output.gsub("install","hold"))
129
- expect(provider.query[:ensure]).to eq(:held)
129
+ query=provider.query
130
+ expect(query[:ensure]).to eq("4.2-5ubuntu3")
131
+ expect(query[:mark]).to eq(:hold)
132
+
130
133
  end
131
134
 
132
135
  context "parsing tests" do
@@ -184,14 +187,15 @@ describe Puppet::Type.type(:package).provider(:dpkg) do
184
187
 
185
188
  it "uses 'dpkg -i' to install the package" do
186
189
  expect(resource).to receive(:[]).with(:source).and_return("mypackagefile")
190
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
187
191
  expect(provider).to receive(:unhold)
188
192
  expect(provider).to receive(:dpkg).with(any_args, "-i", "mypackagefile")
189
-
190
193
  provider.install
191
194
  end
192
195
 
193
196
  it "keeps old config files if told to do so" do
194
197
  expect(resource).to receive(:[]).with(:configfiles).and_return(:keep)
198
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
195
199
  expect(provider).to receive(:unhold)
196
200
  expect(provider).to receive(:dpkg).with("--force-confold", any_args)
197
201
 
@@ -200,6 +204,7 @@ describe Puppet::Type.type(:package).provider(:dpkg) do
200
204
 
201
205
  it "replaces old config files if told to do so" do
202
206
  expect(resource).to receive(:[]).with(:configfiles).and_return(:replace)
207
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
203
208
  expect(provider).to receive(:unhold)
204
209
  expect(provider).to receive(:dpkg).with("--force-confnew", any_args)
205
210
 
@@ -207,6 +212,7 @@ describe Puppet::Type.type(:package).provider(:dpkg) do
207
212
  end
208
213
 
209
214
  it "ensures any hold is removed" do
215
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
210
216
  expect(provider).to receive(:unhold).once
211
217
  expect(provider).to receive(:dpkg)
212
218
  provider.install
@@ -222,18 +228,28 @@ describe Puppet::Type.type(:package).provider(:dpkg) do
222
228
  end
223
229
 
224
230
  it "installs first if package is not present and ensure holding" do
231
+ allow(provider).to receive(:execute)
232
+ allow(provider).to receive(:package_not_installed?).and_return(true)
233
+ expect(provider).to receive(:install).once
234
+ expect(provider).to receive(:hold)
235
+ provider.deprecated_hold
236
+ end
237
+
225
238
 
239
+ it "skips install new package if hold is true" do
226
240
  allow(provider).to receive(:execute)
227
241
  allow(provider).to receive(:package_not_installed?).and_return(true)
228
242
  expect(provider).to receive(:install).once
229
- provider.hold
243
+ expect(provider).to receive(:hold)
244
+ provider.deprecated_hold
230
245
  end
231
246
 
232
247
  it "skips install new package if package is allready installed" do
233
248
  allow(provider).to receive(:execute)
234
249
  allow(provider).to receive(:package_not_installed?).and_return(false)
235
250
  expect(provider).not_to receive(:install)
236
- provider.hold
251
+ expect(provider).to receive(:hold)
252
+ provider.deprecated_hold
237
253
  end
238
254
 
239
255
  it "executes dpkg --set-selections when holding" do
@@ -395,4 +395,21 @@ describe Puppet::Type.type(:package).provider(:openbsd) do
395
395
  end
396
396
  end
397
397
  end
398
+
399
+ context "#flavor" do
400
+ before do
401
+ provider.instance_variable_get('@property_hash')[:flavor] = 'no_x11-python'
402
+ end
403
+
404
+ it 'should return the existing flavor' do
405
+ expect(provider.flavor).to eq('no_x11-python')
406
+ end
407
+
408
+ it 'should remove and install the new flavor if different' do
409
+ provider.resource[:flavor] = 'no_x11-ruby'
410
+ expect(provider).to receive(:uninstall).ordered
411
+ expect(provider).to receive(:install).ordered
412
+ provider.flavor = provider.resource[:flavor]
413
+ end
414
+ end
398
415
  end
@@ -90,7 +90,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
90
90
 
91
91
  {
92
92
  'pkg://omnios/SUNWcs@0.5.11,5.11-0.151006:20130506T161045Z i--' => {:name => 'SUNWcs', :ensure => '0.5.11,5.11-0.151006:20130506T161045Z', :status => 'installed', :provider => :pkg, :publisher => 'omnios'},
93
- 'pkg://omnios/incorporation/jeos/illumos-gate@11,5.11-0.151006:20130506T183443Z if-' => {:name => 'incorporation/jeos/illumos-gate', :ensure => 'held', :status => 'installed', :provider => :pkg, :publisher => 'omnios'},
93
+ 'pkg://omnios/incorporation/jeos/illumos-gate@11,5.11-0.151006:20130506T183443Z if-' => {:name => 'incorporation/jeos/illumos-gate', :ensure => "11,5.11-0.151006:20130506T183443Z", :mark => :hold, :status => 'installed', :provider => :pkg, :publisher => 'omnios'},
94
94
  'pkg://solaris/SUNWcs@0.5.11,5.11-0.151.0.1:20101105T001108Z installed -----' => {:name => 'SUNWcs', :ensure => '0.5.11,5.11-0.151.0.1:20101105T001108Z', :status => 'installed', :provider => :pkg, :publisher => 'solaris'},
95
95
  }.each do |k, v|
96
96
  it "[#{k}] should correctly parse" do
@@ -251,6 +251,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
251
251
 
252
252
  it "should accept all licenses" do
253
253
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => :absent})
254
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
254
255
  expect(Puppet::Util::Execution).to receive(:execute)
255
256
  .with(['/bin/pkg', 'install', *hash[:flags], 'dummy'], {:failonfail => false, :combine => true})
256
257
  .and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))
@@ -265,6 +266,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
265
266
  # Should install also check if the version installed is the same version we are asked to install? or should we rely on puppet for that?
266
267
  resource[:ensure] = '0.0.7,5.11-0.151006:20131230T130000Z'
267
268
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
269
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
268
270
  expect(Puppet::Util::Execution).to receive(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
269
271
  expect(Puppet::Util::Execution).to receive(:execute)
270
272
  .with(['/bin/pkg', 'list', '-Hv', 'dummy'], {:failonfail => false, :combine => true})
@@ -277,6 +279,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
277
279
 
278
280
  it "should install specific version(2)" do
279
281
  resource[:ensure] = '0.0.8'
282
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
280
283
  expect(Puppet::Util::Execution).to receive(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
281
284
  expect(Puppet::Util::Execution).to receive(:execute)
282
285
  .with(['/bin/pkg', 'list', '-Hv', 'dummy'], {:failonfail => false, :combine => true})
@@ -290,6 +293,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
290
293
 
291
294
  it "should downgrade to specific version" do
292
295
  resource[:ensure] = '0.0.7'
296
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
293
297
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => '0.0.8,5.11-0.151106:20131230T130000Z'})
294
298
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
295
299
  expect(Puppet::Util::Execution).to receive(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
@@ -301,6 +305,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
301
305
 
302
306
  it "should install any if version is not specified" do
303
307
  resource[:ensure] = :present
308
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
304
309
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => :absent})
305
310
  expect(Puppet::Util::Execution).to receive(:execute)
306
311
  .with(['/bin/pkg', 'install', *hash[:flags], 'dummy'], {:failonfail => false, :combine => true})
@@ -312,6 +317,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
312
317
 
313
318
  it "should install if no version was previously installed, and a specific version was requested" do
314
319
  resource[:ensure] = '0.0.7'
320
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
315
321
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => :absent})
316
322
  expect(Puppet::Util::Execution).to receive(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
317
323
  expect(Puppet::Util::Execution).to receive(:execute)
@@ -325,6 +331,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
325
331
  resource[:ensure] = '1.0-0.151006'
326
332
  is = :absent
327
333
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => is})
334
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
328
335
  expect(described_class).to receive(:pkg)
329
336
  .with(:list, '-Hvfa', 'dummy@1.0-0.151006')
330
337
  .and_return(Puppet::Util::Execution::ProcessOutput.new(File.read(my_fixture('dummy_implicit_version')), 0))
@@ -340,6 +347,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
340
347
  resource[:ensure] = '1.0-0.151006'
341
348
  is = '1.0,5.11-0.151006:20140219T191204Z'
342
349
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => is})
350
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
343
351
  expect(described_class).to receive(:pkg).with(:list, '-Hvfa', 'dummy@1.0-0.151006').and_return(File.read(my_fixture('dummy_implicit_version')))
344
352
  expect(Puppet::Util::Execution).to receive(:execute).with(['/bin/pkg', 'update', '-n', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
345
353
  expect(provider).to receive(:unhold).with(no_args)
@@ -398,12 +406,16 @@ describe Puppet::Type.type(:package).provider(:pkg) do
398
406
  it "should support current pkg version" do
399
407
  expect(described_class).to receive(:pkg).with(:version).and_return('630e1ffc7a19')
400
408
  expect(described_class).to receive(:pkg).with([:uninstall, resource[:name]])
409
+ expect(provider).to receive(:properties).and_return({:hold => false})
410
+
401
411
  provider.uninstall
402
412
  end
403
413
 
404
414
  it "should support original pkg commands" do
405
415
  expect(described_class).to receive(:pkg).with(:version).and_return('052adf36c3f4')
406
416
  expect(described_class).to receive(:pkg).with([:uninstall, '-r', resource[:name]])
417
+ expect(provider).to receive(:properties).and_return({:hold => false})
418
+
407
419
  provider.uninstall
408
420
  end
409
421
  end
@@ -54,6 +54,56 @@ describe Puppet::Type.type(:package).provider(:yum) do
54
54
  provider.install
55
55
  end
56
56
  end
57
+
58
+ describe 'with install_options' do
59
+ it 'can parse disable-repo with array of strings' do
60
+ resource[:install_options] = ['--disable-repo=dev*', '--disable-repo=prod*']
61
+ expect(provider).to receive(:execute) do | arr|
62
+ expect(arr[-3]).to eq(["--disable-repo=dev*", "--disable-repo=prod*"])
63
+ end
64
+ provider.install
65
+ end
66
+
67
+ it 'can parse disable-repo with array of hashes' do
68
+ resource[:install_options] = [{'--disable-repo' => 'dev*'}, {'--disable-repo' => 'prod*'}]
69
+ expect(provider).to receive(:execute) do | arr|
70
+ expect(arr[-3]).to eq(["--disable-repo=dev*", "--disable-repo=prod*"])
71
+ end
72
+ provider.install
73
+ end
74
+
75
+ it 'can parse enable-repo with array of strings' do
76
+ resource[:install_options] = ['--enable-repo=dev*', '--enable-repo=prod*']
77
+ expect(provider).to receive(:execute) do | arr|
78
+ expect(arr[-3]).to eq(["--enable-repo=dev*", "--enable-repo=prod*"])
79
+ end
80
+ provider.install
81
+ end
82
+
83
+ it 'can parse enable-repo with array of hashes' do
84
+ resource[:install_options] = [{'--enable-repo' => 'dev*'}, {'--disable-repo' => 'prod*'}]
85
+ expect(provider).to receive(:execute) do | arr|
86
+ expect(arr[-3]).to eq(["--enable-repo=dev*", "--disable-repo=prod*"])
87
+ end
88
+ provider.install
89
+ end
90
+
91
+ it 'can parse enable-repo with single hash' do
92
+ resource[:install_options] = [{'--enable-repo' => 'dev*','--disable-repo' => 'prod*'}]
93
+ expect(provider).to receive(:execute) do | arr|
94
+ expect(arr[-3]).to eq(["--disable-repo=prod*", "--enable-repo=dev*"])
95
+ end
96
+ provider.install
97
+ end
98
+
99
+ it 'can parse enable-repo with empty array' do
100
+ resource[:install_options] = []
101
+ expect(provider).to receive(:execute) do | arr|
102
+ expect(arr[-3]).to eq([])
103
+ end
104
+ provider.install
105
+ end
106
+ end
57
107
  end
58
108
 
59
109
  context "parsing the output of check-update" do
@@ -196,6 +196,17 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
196
196
  }
197
197
  end
198
198
 
199
+ let (:dsimport_preamble) do
200
+ '0x0A 0x5C 0x3A 0x2C dsRecTypeStandard:Users 2 dsAttrTypeStandard:RecordName base64:dsAttrTypeNative:ShadowHashData'
201
+ end
202
+
203
+ let (:dsimport_contents) do
204
+ <<-DSIMPORT
205
+ #{dsimport_preamble}
206
+ #{username}:#{Base64.strict_encode64(sha512_embedded_bplist)}
207
+ DSIMPORT
208
+ end
209
+
199
210
  # The below represents output of 'dscl -plist . readall /Users' converted to
200
211
  # a native Ruby hash if only one user were installed on the system.
201
212
  # This lets us check the behavior of all the methods necessary to return a
@@ -960,6 +971,24 @@ end
960
971
  end
961
972
  end
962
973
 
974
+ describe '#set_shadow_hash_data' do
975
+ let(:users_plist) { {'ShadowHashData' => ['string_data'] } }
976
+
977
+ it 'should flush the plist data to disk on OS X < 10.15' do
978
+ allow(provider.class).to receive(:get_os_version).and_return('10.12')
979
+
980
+ expect(provider).to receive(:write_users_plist_to_disk)
981
+ provider.set_shadow_hash_data(users_plist, pbkdf2_embedded_plist)
982
+ end
983
+
984
+ it 'should flush the plist data a temporary file on OS X >= 10.15' do
985
+ allow(provider.class).to receive(:get_os_version).and_return('10.15')
986
+
987
+ expect(provider).to receive(:write_and_import_shadow_hash_data)
988
+ provider.set_shadow_hash_data(users_plist, pbkdf2_embedded_plist)
989
+ end
990
+ end
991
+
963
992
  describe '#set_salted_pbkdf2' do
964
993
  let(:users_plist) { {'ShadowHashData' => ['string_data'] } }
965
994
  let(:entropy_shadow_hash_data) do
@@ -1011,6 +1040,18 @@ end
1011
1040
  end
1012
1041
  end
1013
1042
 
1043
+ describe '#write_and_import_shadow_hash_data' do
1044
+ it 'should save the passed plist to a temporary file and import it' do
1045
+ tmpfile = double('tempfile', :path => "/tmp/dsimport_#{username}", :flush => nil)
1046
+ allow(Tempfile).to receive(:create).and_yield(tmpfile)
1047
+ allow(provider).to receive(:dscl).with('.', 'delete', user_path, 'ShadowHashData')
1048
+
1049
+ expect(tmpfile).to receive(:write).with(dsimport_contents)
1050
+ expect(provider).to receive(:dsimport).with(tmpfile.path, '/Local/Default', 'M')
1051
+ provider.write_and_import_shadow_hash_data(sha512_embedded_bplist)
1052
+ end
1053
+ end
1054
+
1014
1055
  describe '#merge_attribute_with_dscl' do
1015
1056
  it 'should raise an error if a dscl command raises an error' do
1016
1057
  expect(provider).to receive(:dscl).with('.', '-merge', user_path, 'GeneratedUID', 'GUID').and_raise(Puppet::ExecutionFailure, 'boom')
@@ -324,7 +324,7 @@ describe Puppet::Type.type(:user).provider(:useradd) do
324
324
 
325
325
  it "should return the local comment string when forcelocal is true" do
326
326
  resource[:forcelocal] = true
327
- allow(File).to receive(:open).with('/etc/passwd').and_yield(content)
327
+ allow(File).to receive(:read).with('/etc/passwd').and_return(content)
328
328
  expect(provider.comment).to eq('local comment')
329
329
  end
330
330
 
@@ -337,7 +337,7 @@ describe Puppet::Type.type(:user).provider(:useradd) do
337
337
  end
338
338
 
339
339
  describe "#finduser" do
340
- before { allow(File).to receive(:open).with('/etc/passwd').and_yield(content) }
340
+ before { allow(File).to receive(:read).with('/etc/passwd').and_return(content) }
341
341
 
342
342
  let(:content) { "sample_account:sample_password:sample_uid:sample_gid:sample_gecos:sample_directory:sample_shell" }
343
343
  let(:output) do
@@ -361,6 +361,11 @@ describe Puppet::Type.type(:user).provider(:useradd) do
361
361
  it "returns false when specified key/value pair is not found" do
362
362
  expect(provider.finduser(:account, 'invalid_account')).to eq(false)
363
363
  end
364
+
365
+ it "reads the user file only once per resource" do
366
+ expect(File).to receive(:read).with('/etc/passwd').once
367
+ 5.times { provider.finduser(:account, 'sample_account') }
368
+ end
364
369
  end
365
370
 
366
371
  describe "#check_allow_dup" do
@@ -714,6 +714,9 @@ describe 'Puppet Pal' do
714
714
 
715
715
  context 'facts are supported such that' do
716
716
  it 'they are obtained if they are not given' do
717
+ facts = Puppet::Node::Facts.new(Puppet[:certname], 'puppetversion' => Puppet.version)
718
+ Puppet::Node::Facts.indirection.save(facts)
719
+
717
720
  testing_env_dir # creates the structure
718
721
  result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath ) do |ctx|
719
722
  ctx.with_script_compiler {|c| c.evaluate_string("$facts =~ Hash and $facts[puppetversion] == '#{Puppet.version}'") }
@@ -876,9 +876,8 @@ describe Puppet::SSL::CertificateAuthority do
876
876
  @ca.verify("me")
877
877
  end
878
878
 
879
- it "should set the store purpose to OpenSSL::X509::PURPOSE_SSL_CLIENT" do
880
- Puppet[:cacert] = cacert
881
- expect(@store).to receive(:add_file).with(cacert)
879
+ it "should set the store purpose to OpenSSL::X509::PURPOSE_ANY" do
880
+ expect(@store).to receive(:purpose=).with OpenSSL::X509::PURPOSE_ANY
882
881
 
883
882
  @ca.verify("me")
884
883
  end
@@ -138,6 +138,13 @@ describe Puppet::SSL::Certificate do
138
138
  expect(cert.custom_extensions).to include('oid' => '1.3.6.1.4.1.34380.1.2.1', 'value' => 'x509 :(')
139
139
  end
140
140
 
141
+ it "returns extensions under the ppAuthCertExt" do
142
+ exts = {'pp_auth_role' => 'taketwo'}
143
+ cert = build_cert(:extension_requests => exts)
144
+ sign_wrapped_cert(cert)
145
+ expect(cert.custom_extensions).to include('oid' => 'pp_auth_role', 'value' => 'taketwo')
146
+ end
147
+
141
148
  it "doesn't return standard extensions" do
142
149
  cert = build_cert(:dns_alt_names => 'foo')
143
150
  expect(cert.custom_extensions).to be_empty
@@ -30,6 +30,10 @@ describe Puppet::Type.type(:package) do
30
30
  expect(Puppet::Type.type(:package).provider_feature(:versionable)).not_to be_nil
31
31
  end
32
32
 
33
+ it "should have a :supports_flavors feature" do
34
+ expect(Puppet::Type.type(:package).provider_feature(:supports_flavors)).not_to be_nil
35
+ end
36
+
33
37
  it "should have a :package_settings feature that requires :package_settings_insync?, :package_settings and :package_settings=" do
34
38
  expect(Puppet::Type.type(:package).provider_feature(:package_settings).methods).to eq([:package_settings_insync?, :package_settings, :package_settings=])
35
39
  end
@@ -53,6 +57,10 @@ describe Puppet::Type.type(:package) do
53
57
  it "should have a package_settings property" do
54
58
  expect(Puppet::Type.type(:package).attrtype(:package_settings)).to eq(:property)
55
59
  end
60
+
61
+ it "should have a flavor property" do
62
+ expect(Puppet::Type.type(:package).attrtype(:flavor)).to eq(:property)
63
+ end
56
64
  end
57
65
 
58
66
  describe "when validating attribute values" do
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'puppet/util/plist'
3
5
  require 'puppet_spec/files'
@@ -52,6 +54,19 @@ describe Puppet::Util::Plist, :if => Puppet.features.cfpropertylist? do
52
54
  </dict>
53
55
  </plist>'
54
56
  end
57
+ let(:ascii_xml_plist) do
58
+ '<?xml version="1.0" encoding="UTF-8"?>
59
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
60
+ <plist version="1.0">
61
+ <dict>
62
+ <key>RecordName</key>
63
+ <array>
64
+ <string>Timișoara</string>
65
+ <string>Tōkyō</string>
66
+ </array>
67
+ </dict>
68
+ </plist>'.force_encoding(Encoding::US_ASCII)
69
+ end
55
70
  let(:non_plist_data) do
56
71
  "Take my love, take my land
57
72
  Take me where I cannot stand
@@ -62,6 +77,7 @@ describe Puppet::Util::Plist, :if => Puppet.features.cfpropertylist? do
62
77
  "\xCF\xFA\xED\xFE\a\u0000\u0000\u0001\u0003\u0000\u0000\x80\u0002\u0000\u0000\u0000\u0012\u0000\u0000\u0000\b"
63
78
  end
64
79
  let(:valid_xml_plist_hash) { {"LastUsedPrinters"=>[{"Network"=>"10.85.132.1", "PrinterID"=>"baskerville_corp_puppetlabs_net"}, {"Network"=>"10.14.96.1", "PrinterID"=>"Statler"}]} }
80
+ let(:ascii_xml_plist_hash) { {"RecordName"=>["Timișoara", "Tōkyō"]} }
65
81
  let(:plist_path) { file_containing('sample.plist', valid_xml_plist) }
66
82
  let(:binary_plist_magic_number) { 'bplist00' }
67
83
  let(:bad_xml_doctype) { '<!DOCTYPE plist PUBLIC -//Apple Computer' }
@@ -132,6 +148,10 @@ describe Puppet::Util::Plist, :if => Puppet.features.cfpropertylist? do
132
148
  expect(subject.parse_plist(valid_xml_plist)).to eq(valid_xml_plist_hash)
133
149
  end
134
150
 
151
+ it "returns a valid hash when an ASCII XML plist is provided" do
152
+ expect(subject.parse_plist(ascii_xml_plist)).to eq(ascii_xml_plist_hash)
153
+ end
154
+
135
155
  it "raises a debug message and replaces a bad XML plist doctype should one be encountered" do
136
156
  expect(subject).to receive(:new_cfpropertylist).with({:data => good_xml_doctype}).and_return('plist_object')
137
157
  allow(subject).to receive(:convert_cfpropertylist_to_native_types).with('plist_object')