puppet 6.0.4-x64-mingw32 → 6.0.5-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 (125) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +15 -15
  3. data/Rakefile +3 -1
  4. data/ext/solaris/smf/svc-puppetd +8 -1
  5. data/ext/solaris/smf/svc-puppetmasterd +8 -1
  6. data/lib/puppet/application/device.rb +48 -32
  7. data/lib/puppet/application/ssl.rb +31 -17
  8. data/lib/puppet/defaults.rb +2 -1
  9. data/lib/puppet/face/config.rb +1 -1
  10. data/lib/puppet/forge.rb +4 -1
  11. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
  12. data/lib/puppet/pops/model/pn_transformer.rb +5 -0
  13. data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
  14. data/lib/puppet/pops/types/string_converter.rb +11 -2
  15. data/lib/puppet/provider/package/dnf.rb +2 -1
  16. data/lib/puppet/provider/package/windows/exe_package.rb +13 -0
  17. data/lib/puppet/provider/package/windows/msi_package.rb +8 -0
  18. data/lib/puppet/provider/package/windows/package.rb +9 -1
  19. data/lib/puppet/provider/package/yum.rb +1 -1
  20. data/lib/puppet/provider/parsedfile.rb +25 -4
  21. data/lib/puppet/provider/service/smf.rb +54 -0
  22. data/lib/puppet/provider/service/systemd.rb +2 -0
  23. data/lib/puppet/provider/service/upstart.rb +1 -0
  24. data/lib/puppet/rest/route.rb +1 -1
  25. data/lib/puppet/ssl/host.rb +23 -11
  26. data/lib/puppet/transaction.rb +4 -1
  27. data/lib/puppet/transaction/event_manager.rb +13 -1
  28. data/lib/puppet/transaction/resource_harness.rb +3 -1
  29. data/lib/puppet/util/command_line.rb +2 -3
  30. data/lib/puppet/util/filetype.rb +36 -4
  31. data/lib/puppet/util/selinux.rb +1 -1
  32. data/lib/puppet/util/windows/api_types.rb +1 -1
  33. data/lib/puppet/util/windows/registry.rb +29 -5
  34. data/lib/puppet/util/windows/service.rb +106 -99
  35. data/lib/puppet/version.rb +1 -1
  36. data/locales/ja/puppet.po +232 -183
  37. data/locales/puppet.pot +145 -117
  38. data/man/man5/puppet.conf.5 +3 -3
  39. data/man/man8/puppet-agent.8 +1 -1
  40. data/man/man8/puppet-apply.8 +1 -1
  41. data/man/man8/puppet-catalog.8 +1 -1
  42. data/man/man8/puppet-config.8 +2 -2
  43. data/man/man8/puppet-describe.8 +1 -1
  44. data/man/man8/puppet-device.8 +23 -19
  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-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-ssl.8 +6 -3
  62. data/man/man8/puppet-status.8 +1 -1
  63. data/man/man8/puppet.8 +2 -2
  64. data/spec/fixtures/unit/provider/service/smf/svcs_fmri.out +6 -0
  65. data/spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out +13 -0
  66. data/spec/integration/ssl/key_spec.rb +0 -4
  67. data/spec/integration/transaction_spec.rb +559 -0
  68. data/spec/integration/util/windows/registry_spec.rb +39 -0
  69. data/spec/unit/application/device_spec.rb +10 -7
  70. data/spec/unit/application/lookup_spec.rb +2 -1
  71. data/spec/unit/application/ssl_spec.rb +21 -2
  72. data/spec/unit/forge/forge_spec.rb +4 -2
  73. data/spec/unit/functions/logging_spec.rb +10 -3
  74. data/spec/unit/indirector/yaml_spec.rb +1 -1
  75. data/spec/unit/pops/loaders/loader_spec.rb +6 -7
  76. data/spec/unit/pops/model/pn_transformer_spec.rb +4 -0
  77. data/spec/unit/pops/types/p_timespan_type_spec.rb +22 -0
  78. data/spec/unit/pops/types/p_timestamp_type_spec.rb +19 -0
  79. data/spec/unit/pops/types/string_converter_spec.rb +20 -0
  80. data/spec/unit/provider/group/ldap_spec.rb +22 -25
  81. data/spec/unit/provider/group/pw_spec.rb +7 -10
  82. data/spec/unit/provider/nameservice/directoryservice_spec.rb +97 -103
  83. data/spec/unit/provider/package/aix_spec.rb +5 -8
  84. data/spec/unit/provider/package/apt_spec.rb +3 -6
  85. data/spec/unit/provider/package/dnf_spec.rb +36 -37
  86. data/spec/unit/provider/package/dpkg_spec.rb +18 -21
  87. data/spec/unit/provider/package/freebsd_spec.rb +4 -7
  88. data/spec/unit/provider/package/gem_spec.rb +41 -41
  89. data/spec/unit/provider/package/hpux_spec.rb +7 -10
  90. data/spec/unit/provider/package/macports_spec.rb +13 -15
  91. data/spec/unit/provider/package/nim_spec.rb +3 -10
  92. data/spec/unit/provider/package/openbsd_spec.rb +14 -17
  93. data/spec/unit/provider/package/pip3_spec.rb +3 -6
  94. data/spec/unit/provider/package/pip_spec.rb +45 -49
  95. data/spec/unit/provider/package/pkgin_spec.rb +13 -18
  96. data/spec/unit/provider/package/pkgng_spec.rb +21 -24
  97. data/spec/unit/provider/package/puppet_gem_spec.rb +6 -9
  98. data/spec/unit/provider/package/tdnf_spec.rb +9 -12
  99. data/spec/unit/provider/package/yum_spec.rb +30 -16
  100. data/spec/unit/provider/package/zypper_spec.rb +17 -19
  101. data/spec/unit/provider/service/bsd_spec.rb +7 -9
  102. data/spec/unit/provider/service/daemontools_spec.rb +12 -16
  103. data/spec/unit/provider/service/debian_spec.rb +6 -10
  104. data/spec/unit/provider/service/freebsd_spec.rb +2 -2
  105. data/spec/unit/provider/service/openbsd_spec.rb +13 -17
  106. data/spec/unit/provider/service/rcng_spec.rb +2 -4
  107. data/spec/unit/provider/service/redhat_spec.rb +12 -11
  108. data/spec/unit/provider/service/runit_spec.rb +7 -14
  109. data/spec/unit/provider/service/smf_spec.rb +77 -13
  110. data/spec/unit/provider/service/src_spec.rb +11 -16
  111. data/spec/unit/provider/service/systemd_spec.rb +18 -0
  112. data/spec/unit/provider/user/hpux_spec.rb +3 -5
  113. data/spec/unit/provider/user/ldap_spec.rb +29 -32
  114. data/spec/unit/provider/user/pw_spec.rb +10 -13
  115. data/spec/unit/rest/route_spec.rb +1 -1
  116. data/spec/unit/ssl/host_spec.rb +21 -0
  117. data/spec/unit/ssl/key_spec.rb +2 -4
  118. data/spec/unit/transaction/event_manager_spec.rb +12 -1
  119. data/spec/unit/transaction/resource_harness_spec.rb +18 -0
  120. data/spec/unit/transaction_spec.rb +25 -0
  121. data/spec/unit/util/filetype_spec.rb +13 -5
  122. data/spec/unit/util/logging_spec.rb +0 -41
  123. data/spec/unit/util/monkey_patches_spec.rb +18 -5
  124. data/spec/unit/util/selinux_spec.rb +4 -0
  125. metadata +8 -2
@@ -253,5 +253,44 @@ describe Puppet::Util::Windows::Registry do
253
253
  end
254
254
  end
255
255
  end
256
+
257
+ context "#values_by_name" do
258
+ let(:hkey) { stub 'hklm' }
259
+ let(:subkey) { stub 'subkey' }
260
+
261
+ before :each do
262
+ subject.stubs(:root).returns(hkey)
263
+ end
264
+
265
+ context "when reading values" do
266
+ let (:hklm) { Win32::Registry::HKEY_LOCAL_MACHINE }
267
+ let (:puppet_key) { "SOFTWARE\\Puppet Labs"}
268
+ let (:subkey_name) { "PuppetRegistryTest#{SecureRandom.uuid}" }
269
+
270
+ before(:each) do
271
+ hklm.create("#{puppet_key}\\#{subkey_name}", Win32::Registry::KEY_ALL_ACCESS) do |reg|
272
+ reg.write('valuename1', Win32::Registry::REG_SZ, 'value1')
273
+ reg.write('valuename2', Win32::Registry::REG_SZ, 'value2')
274
+ end
275
+ end
276
+
277
+ after(:each) do
278
+ hklm.open(puppet_key, Win32::Registry::KEY_ALL_ACCESS) do |reg|
279
+ subject.delete_key(reg, subkey_name)
280
+ end
281
+ end
282
+
283
+ it "should return only the values for the names specified" do
284
+ hklm.open("#{puppet_key}\\#{subkey_name}", Win32::Registry::KEY_ALL_ACCESS) do |reg_key|
285
+ vals = subject.values_by_name(reg_key, ['valuename1', 'missingname'])
286
+
287
+ expect(vals).to have_key('valuename1')
288
+ expect(vals).to_not have_key('valuename2')
289
+ expect(vals['valuename1']).to eq('value1')
290
+ expect(vals['missingname']).to be_nil
291
+ end
292
+ end
293
+ end
294
+ end
256
295
  end
257
296
  end
@@ -75,25 +75,25 @@ describe Puppet::Application::Device do
75
75
  it "should set waitforcert to 0 with --onetime and if --waitforcert wasn't given" do
76
76
  Puppet[:onetime] = true
77
77
  Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(0)
78
- @device.setup_host
78
+ @device.setup_host('device.example.com')
79
79
  end
80
80
 
81
81
  it "should use supplied waitforcert when --onetime is specified" do
82
82
  Puppet[:onetime] = true
83
83
  @device.handle_waitforcert(60)
84
84
  Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(60)
85
- @device.setup_host
85
+ @device.setup_host('device.example.com')
86
86
  end
87
87
 
88
88
  it "should use a default value for waitforcert when --onetime and --waitforcert are not specified" do
89
89
  Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(120)
90
- @device.setup_host
90
+ @device.setup_host('device.example.com')
91
91
  end
92
92
 
93
93
  it "should use the waitforcert setting when checking for a signed certificate" do
94
94
  Puppet[:waitforcert] = 10
95
95
  Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(10)
96
- @device.setup_host
96
+ @device.setup_host('device.example.com')
97
97
  end
98
98
 
99
99
  it "should set the log destination with --logdest" do
@@ -271,14 +271,14 @@ describe Puppet::Application::Device do
271
271
 
272
272
  it "should create a new ssl host" do
273
273
  Puppet::SSL::Host.expects(:new).returns(@host)
274
- @device.setup_host
274
+ @device.setup_host('device.example.com')
275
275
  end
276
276
 
277
277
  it "should wait for a certificate" do
278
278
  @device.options.stubs(:[]).with(:waitforcert).returns(123)
279
279
  @host.expects(:wait_for_cert).with(123)
280
280
 
281
- @device.setup_host
281
+ @device.setup_host('device.example.com')
282
282
  end
283
283
  end
284
284
 
@@ -292,6 +292,7 @@ describe Puppet::Application::Device do
292
292
  @device.options.stubs(:[]).with(:facts).returns(false)
293
293
  @device.options.stubs(:[]).with(:resource).returns(false)
294
294
  @device.options.stubs(:[]).with(:to_yaml).returns(false)
295
+ @device.options.stubs(:[]).with(:libdir).returns(nil)
295
296
  @device.options.stubs(:[]).with(:client)
296
297
  @device.command_line.stubs(:args).returns([])
297
298
  Puppet::Util::NetworkDevice::Config.stubs(:devices).returns({})
@@ -497,7 +498,9 @@ describe Puppet::Application::Device do
497
498
  expect { @device.main }.to exit_with 1
498
499
  end
499
500
 
500
- it "should print the device url scheme, host, and port" do
501
+ it "should retrieve plugins and print the device url scheme, host, and port" do
502
+ Puppet.stubs(:info)
503
+ Puppet.expects(:info).with "Retrieving pluginfacts"
501
504
  Puppet.expects(:info).with "starting applying configuration to device1 at ssh://testhost"
502
505
  Puppet.expects(:info).with "starting applying configuration to device2 at https://testhost:443/some/path"
503
506
  expect { @device.main }.to exit_with 1
@@ -13,7 +13,8 @@ describe Puppet::Application::Lookup do
13
13
  ensure
14
14
  $stdout = saved_stdout
15
15
  end
16
- capture.string.strip
16
+ # Drop end of line and an optional yaml end of document
17
+ capture.string.gsub(/\n(\.\.\.\n)?\Z/m, '')
17
18
  end
18
19
 
19
20
  context "when running with incorrect command line options" do
@@ -5,6 +5,8 @@ require 'openssl'
5
5
  require 'puppet/test_ca'
6
6
 
7
7
  describe Puppet::Application::Ssl, unless: Puppet::Util::Platform.jruby? do
8
+ include PuppetSpec::Files
9
+
8
10
  let(:ssl) do
9
11
  app = Puppet::Application[:ssl]
10
12
  app.options[:verbose] = true
@@ -25,6 +27,7 @@ describe Puppet::Application::Ssl, unless: Puppet::Util::Platform.jruby? do
25
27
 
26
28
  Puppet.settings.use(:main)
27
29
  Puppet[:certname] = name
30
+ Puppet[:vardir] = tmpdir("ssl_testing")
28
31
 
29
32
  # Host assumes ca cert and crl are present
30
33
  File.open(Puppet[:localcacert], 'w') { |f| f.write(@ca_cert.to_pem) }
@@ -293,9 +296,10 @@ describe Puppet::Application::Ssl, unless: Puppet::Util::Platform.jruby? do
293
296
  end
294
297
 
295
298
  it 'deletes the request' do
296
- File.open(Puppet[:hostcsr], 'w') { |f| f.write(@host[:csr].to_pem) }
299
+ path = File.join(Puppet[:requestdir], "#{Puppet[:certname]}.pem")
300
+ File.open(path, 'w') { |f| f.write(@host[:csr].to_pem) }
297
301
 
298
- expects_command_to_pass(%r{Removed certificate request #{Puppet[:hostcsr]}})
302
+ expects_command_to_pass(%r{Removed certificate request #{path}})
299
303
  end
300
304
 
301
305
  it 'deletes the passfile' do
@@ -368,5 +372,20 @@ describe Puppet::Application::Ssl, unless: Puppet::Util::Platform.jruby? do
368
372
  expects_command_to_pass(%r{Removed certificate .*puppetserver.pem})
369
373
  end
370
374
  end
375
+
376
+ context 'when cleaning a device' do
377
+ before do
378
+ ssl.command_line.args = ['clean', '--target', 'device.example.com']
379
+ ssl.parse_options
380
+ end
381
+
382
+ it 'deletes the device certificate' do
383
+ device_cert_path = File.join(Puppet[:devicedir], 'device.example.com', 'ssl', 'certs')
384
+ device_cert_file = File.join(device_cert_path, 'device.example.com.pem')
385
+ FileUtils.mkdir_p(device_cert_path)
386
+ File.open(device_cert_file, 'w') { |f| f.write('device.example.com') }
387
+ expects_command_to_pass(%r{Removed certificate #{device_cert_file}})
388
+ end
389
+ end
371
390
  end
372
391
  end
@@ -59,10 +59,11 @@ describe Puppet::Forge do
59
59
  it "includes any defined module_groups, ensuring to only encode them once in the URI" do
60
60
  Puppet[:module_groups] = 'base+pe'
61
61
  module_name = 'puppetlabs-acl'
62
+ exclusions = "readme%2Cchangelog%2Clicense%2Curi%2Cmodule%2Ctags%2Csupported%2Cfile_size%2Cdownloads%2Ccreated_at%2Cupdated_at%2Cdeleted_at"
62
63
 
63
64
  # ignores Puppet::Forge::Repository#read_response, provides response to fetch
64
65
  performs_an_http_request(ok_response) do |http|
65
- encoded_uri = "/v3/releases?module=#{module_name}&sort_by=version&module_groups=base%20pe"
66
+ encoded_uri = "/v3/releases?module=#{module_name}&sort_by=version&exclude_fields=#{exclusions}&module_groups=base%20pe"
66
67
  http.expects(:request).with(responds_with(:path, encoded_uri))
67
68
  end
68
69
 
@@ -71,10 +72,11 @@ describe Puppet::Forge do
71
72
 
72
73
  it "single encodes the module name term in the URI" do
73
74
  module_name = "puppetlabs-#{mixed_utf8_query_param}"
75
+ exclusions = "readme%2Cchangelog%2Clicense%2Curi%2Cmodule%2Ctags%2Csupported%2Cfile_size%2Cdownloads%2Ccreated_at%2Cupdated_at%2Cdeleted_at"
74
76
 
75
77
  # ignores Puppet::Forge::Repository#read_response, provides response to fetch
76
78
  performs_an_http_request(ok_response) do |http|
77
- encoded_uri = "/v3/releases?module=puppetlabs-#{mixed_utf8_query_param_encoded}&sort_by=version"
79
+ encoded_uri = "/v3/releases?module=puppetlabs-#{mixed_utf8_query_param_encoded}&sort_by=version&exclude_fields=#{exclusions}"
78
80
  http.expects(:request).with(responds_with(:path, encoded_uri))
79
81
  end
80
82
 
@@ -18,9 +18,16 @@ describe 'the log function' do
18
18
 
19
19
  def expect_log(code, log_level, message)
20
20
  logs = collect_logs(code)
21
- expect(logs.size).to eql(1)
22
- expect(logs[0].level).to eql(log_level)
23
- expect(logs[0].message).to eql(message)
21
+
22
+ # There's a chance that additional messages could have been
23
+ # added during code compilation like debug messages from
24
+ # Facter. This happened on Appveyor when the Appveyor image
25
+ # failed to resolve the domain fact. Since these messages are
26
+ # not relevant to our test, and since they can (possibly) be
27
+ # injected at any location in our logs array, it is good enough
28
+ # to assert that our desired log _is_ included in the logs array
29
+ # instead of trying to figure out _where_ it is included.
30
+ expect(logs).to include(satisfy { |log| log.level == log_level && log.message == message })
24
31
  end
25
32
 
26
33
  before(:each) do
@@ -141,7 +141,7 @@ describe Puppet::Indirector::Yaml do
141
141
  dir_containing_instances([one, two])
142
142
 
143
143
  request = indirection.request(:search, "*", nil)
144
- expect(terminus.search(request)).to eq([one, two])
144
+ expect(terminus.search(request)).to contain_exactly(one, two)
145
145
  end
146
146
 
147
147
  it "should return an array containing a single instance of fact when globbing 'one*'" do
@@ -447,8 +447,7 @@ describe 'The Loader' do
447
447
  end
448
448
 
449
449
  context 'with no explicit dependencies' do
450
-
451
- let(:modules) {
450
+ let(:modules) do
452
451
  {
453
452
  'a' => {
454
453
  'functions' => a_functions,
@@ -468,12 +467,12 @@ describe 'The Loader' do
468
467
  'types' => c_types,
469
468
  },
470
469
  }
470
+ end
471
471
 
472
- it 'discover is only called once on dependent loader' do
473
- ModuleLoaders::FileBased.any_instance.expects(:discover).times(4).with(:type, Pcore::RUNTIME_NAME_AUTHORITY).returns([])
474
- expect(loader.private_loader.discover(:type) { |t| t.name =~ /^.::.*\z/ }).to(contain_exactly())
475
- end
476
- }
472
+ it 'discover is only called once on dependent loader' do
473
+ ModuleLoaders::FileBased.any_instance.expects(:discover).times(4).with(:type, nil, Pcore::RUNTIME_NAME_AUTHORITY).returns([])
474
+ expect(loader.private_loader.discover(:type) { |t| t.name =~ /^.::.*\z/ }).to(contain_exactly())
475
+ end
477
476
  end
478
477
  end
479
478
  end
@@ -42,6 +42,10 @@ describe 'Puppet::Pops::Model::PNTransformer' do
42
42
  expect(Puppet::Pops::Model::PNTransformer.transform(x.model)).to eq(
43
43
  call('hash', call('=>', 'a', 1), call('=>', 'b', 2)))
44
44
  end
45
+
46
+ it 'replaces empty/nil body with a Nop' do
47
+ expect(Puppet::Pops::Model::PNTransformer.transform(nil)).to eq(call('nop'))
48
+ end
45
49
  end
46
50
 
47
51
  def lit(value)
@@ -68,6 +68,28 @@ describe 'Timespan type' do
68
68
  CODE
69
69
  expect(eval_and_collect_notices(code)).to eq(%w(true false))
70
70
  end
71
+
72
+ it 'accepts integer values when specifying the range' do
73
+ code = <<-CODE
74
+ notice(Timespan(1) =~ Timespan[1, 2])
75
+ notice(Timespan(3) =~ Timespan[1])
76
+ notice(Timespan(0) =~ Timespan[default, 2])
77
+ notice(Timespan(0) =~ Timespan[1, 2])
78
+ notice(Timespan(3) =~ Timespan[1, 2])
79
+ CODE
80
+ expect(eval_and_collect_notices(code)).to eq(%w(true true true false false))
81
+ end
82
+
83
+ it 'accepts float values when specifying the range' do
84
+ code = <<-CODE
85
+ notice(Timespan(1.0) =~ Timespan[1.0, 2.0])
86
+ notice(Timespan(3.0) =~ Timespan[1.0])
87
+ notice(Timespan(0.0) =~ Timespan[default, 2.0])
88
+ notice(Timespan(0.0) =~ Timespan[1.0, 2.0])
89
+ notice(Timespan(3.0) =~ Timespan[1.0, 2.0])
90
+ CODE
91
+ expect(eval_and_collect_notices(code)).to eq(%w(true true true false false))
92
+ end
71
93
  end
72
94
 
73
95
  context 'a Timespan instance' do
@@ -74,6 +74,25 @@ describe 'Timestamp type' do
74
74
  CODE
75
75
  expect(eval_and_collect_notices(code)).to eq(%w(true false))
76
76
  end
77
+
78
+ it 'accepts integer values when specifying the range' do
79
+ code = <<-CODE
80
+ notice(Timestamp(1) =~ Timestamp[1, 2])
81
+ notice(Timestamp(3) =~ Timestamp[1])
82
+ notice(Timestamp(0) =~ Timestamp[default, 2])
83
+ CODE
84
+ expect(eval_and_collect_notices(code)).to eq(%w(true true true))
85
+ end
86
+
87
+ it 'accepts float values when specifying the range' do
88
+ code = <<-CODE
89
+ notice(Timestamp(1.0) =~ Timestamp[1.0, 2.0])
90
+ notice(Timestamp(3.0) =~ Timestamp[1.0])
91
+ notice(Timestamp(0.0) =~ Timestamp[default, 2.0])
92
+ CODE
93
+ expect(eval_and_collect_notices(code)).to eq(%w(true true true))
94
+ end
95
+
77
96
  end
78
97
 
79
98
  context 'a Timestamp instance' do
@@ -707,6 +707,15 @@ describe 'The string converter' do
707
707
  expect(formatted).to eq(result)
708
708
  end
709
709
 
710
+ it 'applies a short form format' do
711
+ result = [
712
+ "[1,",
713
+ " [2, 3],",
714
+ " 4]"
715
+ ].join("\n")
716
+ expect(converter.convert([1, [2,3], 4], '%#a')).to eq(result)
717
+ end
718
+
710
719
  it 'treats hashes as nested arrays wrt indentation' do
711
720
  string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#a', 'separator' =>", " } }
712
721
  # formatting matters here
@@ -855,6 +864,17 @@ describe 'The string converter' do
855
864
  expect(converter.convert({1 => "hello", 2 => {3=> "world"}}, string_formats)).to eq(result)
856
865
  end
857
866
 
867
+ it 'applies a short form format' do
868
+ result = [
869
+ "{",
870
+ " 1 => {",
871
+ " 2 => 3",
872
+ " },",
873
+ " 4 => 5",
874
+ "}"].join("\n")
875
+ expect(converter.convert({1 => {2 => 3}, 4 => 5}, '%#h')).to eq(result)
876
+ end
877
+
858
878
  context "containing an array" do
859
879
  it 'the hash and array renders without breaks and indentation by default' do
860
880
  result = "{1 => [1, 2, 3]}"
@@ -1,54 +1,51 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
 
4
- provider_class = Puppet::Type.type(:group).provider(:ldap)
5
-
6
- describe provider_class do
3
+ describe Puppet::Type.type(:group).provider(:ldap) do
7
4
  it "should have the Ldap provider class as its baseclass" do
8
- expect(provider_class.superclass).to equal(Puppet::Provider::Ldap)
5
+ expect(described_class.superclass).to equal(Puppet::Provider::Ldap)
9
6
  end
10
7
 
11
8
  it "should manage :posixGroup objectclass" do
12
- expect(provider_class.manager.objectclasses).to eq([:posixGroup])
9
+ expect(described_class.manager.objectclasses).to eq([:posixGroup])
13
10
  end
14
11
 
15
12
  it "should use 'ou=Groups' as its relative base" do
16
- expect(provider_class.manager.location).to eq("ou=Groups")
13
+ expect(described_class.manager.location).to eq("ou=Groups")
17
14
  end
18
15
 
19
16
  it "should use :cn as its rdn" do
20
- expect(provider_class.manager.rdn).to eq(:cn)
17
+ expect(described_class.manager.rdn).to eq(:cn)
21
18
  end
22
19
 
23
20
  it "should map :name to 'cn'" do
24
- expect(provider_class.manager.ldap_name(:name)).to eq('cn')
21
+ expect(described_class.manager.ldap_name(:name)).to eq('cn')
25
22
  end
26
23
 
27
24
  it "should map :gid to 'gidNumber'" do
28
- expect(provider_class.manager.ldap_name(:gid)).to eq('gidNumber')
25
+ expect(described_class.manager.ldap_name(:gid)).to eq('gidNumber')
29
26
  end
30
27
 
31
28
  it "should map :members to 'memberUid', to be used by the user ldap provider" do
32
- expect(provider_class.manager.ldap_name(:members)).to eq('memberUid')
29
+ expect(described_class.manager.ldap_name(:members)).to eq('memberUid')
33
30
  end
34
31
 
35
32
  describe "when being created" do
36
33
  before do
37
34
  # So we don't try to actually talk to ldap
38
35
  @connection = mock 'connection'
39
- provider_class.manager.stubs(:connect).yields @connection
36
+ described_class.manager.stubs(:connect).yields @connection
40
37
  end
41
38
 
42
39
  describe "with no gid specified" do
43
40
  it "should pick the first available GID after the largest existing GID" do
44
41
  low = {:name=>["luke"], :gid=>["600"]}
45
42
  high = {:name=>["testing"], :gid=>["640"]}
46
- provider_class.manager.expects(:search).returns([low, high])
43
+ described_class.manager.expects(:search).returns([low, high])
47
44
 
48
45
  resource = stub 'resource', :should => %w{whatever}
49
46
  resource.stubs(:should).with(:gid).returns nil
50
47
  resource.stubs(:should).with(:ensure).returns :present
51
- instance = provider_class.new(:name => "luke", :ensure => :absent)
48
+ instance = described_class.new(:name => "luke", :ensure => :absent)
52
49
  instance.stubs(:resource).returns resource
53
50
 
54
51
  @connection.expects(:add).with { |dn, attrs| attrs["gidNumber"] == ["641"] }
@@ -58,12 +55,12 @@ describe provider_class do
58
55
  end
59
56
 
60
57
  it "should pick '501' as its GID if no groups are found" do
61
- provider_class.manager.expects(:search).returns nil
58
+ described_class.manager.expects(:search).returns nil
62
59
 
63
60
  resource = stub 'resource', :should => %w{whatever}
64
61
  resource.stubs(:should).with(:gid).returns nil
65
62
  resource.stubs(:should).with(:ensure).returns :present
66
- instance = provider_class.new(:name => "luke", :ensure => :absent)
63
+ instance = described_class.new(:name => "luke", :ensure => :absent)
67
64
  instance.stubs(:resource).returns resource
68
65
 
69
66
  @connection.expects(:add).with { |dn, attrs| attrs["gidNumber"] == ["501"] }
@@ -75,27 +72,27 @@ describe provider_class do
75
72
  end
76
73
 
77
74
  it "should have a method for converting group names to GIDs" do
78
- expect(provider_class).to respond_to(:name2id)
75
+ expect(described_class).to respond_to(:name2id)
79
76
  end
80
77
 
81
78
  describe "when converting from a group name to GID" do
82
79
  it "should use the ldap manager to look up the GID" do
83
- provider_class.manager.expects(:search).with("cn=foo")
84
- provider_class.name2id("foo")
80
+ described_class.manager.expects(:search).with("cn=foo")
81
+ described_class.name2id("foo")
85
82
  end
86
83
 
87
84
  it "should return nil if no group is found" do
88
- provider_class.manager.expects(:search).with("cn=foo").returns nil
89
- expect(provider_class.name2id("foo")).to be_nil
90
- provider_class.manager.expects(:search).with("cn=bar").returns []
91
- expect(provider_class.name2id("bar")).to be_nil
85
+ described_class.manager.expects(:search).with("cn=foo").returns nil
86
+ expect(described_class.name2id("foo")).to be_nil
87
+ described_class.manager.expects(:search).with("cn=bar").returns []
88
+ expect(described_class.name2id("bar")).to be_nil
92
89
  end
93
90
 
94
91
  # We shouldn't ever actually have more than one gid, but it doesn't hurt
95
92
  # to test for the possibility.
96
93
  it "should return the first gid from the first returned group" do
97
- provider_class.manager.expects(:search).with("cn=foo").returns [{:name => "foo", :gid => [10, 11]}, {:name => :bar, :gid => [20, 21]}]
98
- expect(provider_class.name2id("foo")).to eq(10)
94
+ described_class.manager.expects(:search).with("cn=foo").returns [{:name => "foo", :gid => [10, 11]}, {:name => :bar, :gid => [20, 21]}]
95
+ expect(described_class.name2id("foo")).to eq(10)
99
96
  end
100
97
  end
101
98
  end