puppet 5.5.8 → 5.5.10

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 (117) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +14 -14
  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 +45 -29
  7. data/lib/puppet/face/config.rb +1 -1
  8. data/lib/puppet/forge.rb +4 -1
  9. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
  10. data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
  11. data/lib/puppet/pops/types/string_converter.rb +11 -2
  12. data/lib/puppet/provider/cron/crontab.rb +1 -1
  13. data/lib/puppet/provider/package/windows/exe_package.rb +13 -0
  14. data/lib/puppet/provider/package/windows/msi_package.rb +8 -0
  15. data/lib/puppet/provider/package/windows/package.rb +9 -1
  16. data/lib/puppet/provider/parsedfile.rb +25 -4
  17. data/lib/puppet/provider/service/smf.rb +54 -0
  18. data/lib/puppet/transaction.rb +4 -1
  19. data/lib/puppet/transaction/event_manager.rb +13 -1
  20. data/lib/puppet/transaction/resource_harness.rb +3 -1
  21. data/lib/puppet/util/command_line.rb +2 -3
  22. data/lib/puppet/util/filetype.rb +36 -4
  23. data/lib/puppet/util/selinux.rb +1 -1
  24. data/lib/puppet/util/windows/api_types.rb +1 -1
  25. data/lib/puppet/util/windows/registry.rb +29 -5
  26. data/lib/puppet/util/windows/service.rb +106 -99
  27. data/lib/puppet/version.rb +1 -1
  28. data/locales/puppet.pot +97 -69
  29. data/man/man5/puppet.conf.5 +2 -2
  30. data/man/man8/puppet-agent.8 +1 -1
  31. data/man/man8/puppet-apply.8 +1 -1
  32. data/man/man8/puppet-ca.8 +1 -1
  33. data/man/man8/puppet-catalog.8 +1 -1
  34. data/man/man8/puppet-cert.8 +1 -1
  35. data/man/man8/puppet-certificate.8 +1 -1
  36. data/man/man8/puppet-certificate_request.8 +1 -1
  37. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  38. data/man/man8/puppet-config.8 +2 -2
  39. data/man/man8/puppet-describe.8 +1 -1
  40. data/man/man8/puppet-device.8 +23 -19
  41. data/man/man8/puppet-doc.8 +1 -1
  42. data/man/man8/puppet-epp.8 +1 -1
  43. data/man/man8/puppet-facts.8 +1 -1
  44. data/man/man8/puppet-filebucket.8 +1 -1
  45. data/man/man8/puppet-generate.8 +1 -1
  46. data/man/man8/puppet-help.8 +1 -1
  47. data/man/man8/puppet-key.8 +1 -1
  48. data/man/man8/puppet-lookup.8 +1 -1
  49. data/man/man8/puppet-man.8 +1 -1
  50. data/man/man8/puppet-master.8 +1 -1
  51. data/man/man8/puppet-module.8 +1 -1
  52. data/man/man8/puppet-node.8 +1 -1
  53. data/man/man8/puppet-parser.8 +1 -1
  54. data/man/man8/puppet-plugin.8 +1 -1
  55. data/man/man8/puppet-report.8 +1 -1
  56. data/man/man8/puppet-resource.8 +1 -1
  57. data/man/man8/puppet-script.8 +1 -1
  58. data/man/man8/puppet-status.8 +1 -1
  59. data/man/man8/puppet.8 +2 -2
  60. data/spec/fixtures/unit/provider/service/smf/svcs_fmri.out +6 -0
  61. data/spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out +13 -0
  62. data/spec/integration/ssl/key_spec.rb +0 -4
  63. data/spec/integration/transaction_spec.rb +1 -1
  64. data/spec/integration/util/windows/registry_spec.rb +39 -0
  65. data/spec/unit/application/device_spec.rb +4 -1
  66. data/spec/unit/application/lookup_spec.rb +10 -9
  67. data/spec/unit/forge/forge_spec.rb +4 -2
  68. data/spec/unit/indirector/yaml_spec.rb +1 -1
  69. data/spec/unit/pops/loaders/loader_spec.rb +6 -7
  70. data/spec/unit/pops/types/p_timespan_type_spec.rb +22 -0
  71. data/spec/unit/pops/types/p_timestamp_type_spec.rb +19 -0
  72. data/spec/unit/pops/types/string_converter_spec.rb +20 -0
  73. data/spec/unit/provider/cron/parsed_spec.rb +4 -3
  74. data/spec/unit/provider/group/ldap_spec.rb +22 -25
  75. data/spec/unit/provider/group/pw_spec.rb +7 -10
  76. data/spec/unit/provider/host/parsed_spec.rb +3 -17
  77. data/spec/unit/provider/nameservice/directoryservice_spec.rb +97 -103
  78. data/spec/unit/provider/package/aix_spec.rb +5 -8
  79. data/spec/unit/provider/package/apt_spec.rb +3 -6
  80. data/spec/unit/provider/package/dnf_spec.rb +29 -31
  81. data/spec/unit/provider/package/dpkg_spec.rb +18 -21
  82. data/spec/unit/provider/package/freebsd_spec.rb +4 -7
  83. data/spec/unit/provider/package/gem_spec.rb +41 -41
  84. data/spec/unit/provider/package/hpux_spec.rb +7 -10
  85. data/spec/unit/provider/package/macports_spec.rb +13 -15
  86. data/spec/unit/provider/package/nim_spec.rb +3 -10
  87. data/spec/unit/provider/package/openbsd_spec.rb +14 -17
  88. data/spec/unit/provider/package/pip3_spec.rb +3 -6
  89. data/spec/unit/provider/package/pip_spec.rb +44 -72
  90. data/spec/unit/provider/package/pkgin_spec.rb +13 -18
  91. data/spec/unit/provider/package/pkgng_spec.rb +21 -24
  92. data/spec/unit/provider/package/puppet_gem_spec.rb +6 -9
  93. data/spec/unit/provider/package/tdnf_spec.rb +9 -12
  94. data/spec/unit/provider/package/yum_spec.rb +29 -15
  95. data/spec/unit/provider/package/zypper_spec.rb +17 -19
  96. data/spec/unit/provider/service/bsd_spec.rb +8 -12
  97. data/spec/unit/provider/service/daemontools_spec.rb +12 -20
  98. data/spec/unit/provider/service/debian_spec.rb +8 -16
  99. data/spec/unit/provider/service/freebsd_spec.rb +2 -5
  100. data/spec/unit/provider/service/openbsd_spec.rb +12 -18
  101. data/spec/unit/provider/service/rcng_spec.rb +3 -7
  102. data/spec/unit/provider/service/redhat_spec.rb +21 -23
  103. data/spec/unit/provider/service/runit_spec.rb +9 -19
  104. data/spec/unit/provider/service/smf_spec.rb +82 -21
  105. data/spec/unit/provider/service/src_spec.rb +14 -23
  106. data/spec/unit/provider/user/hpux_spec.rb +2 -5
  107. data/spec/unit/provider/user/ldap_spec.rb +29 -32
  108. data/spec/unit/provider/user/pw_spec.rb +10 -13
  109. data/spec/unit/ssl/key_spec.rb +2 -4
  110. data/spec/unit/transaction/event_manager_spec.rb +12 -1
  111. data/spec/unit/transaction/resource_harness_spec.rb +18 -0
  112. data/spec/unit/transaction_spec.rb +25 -0
  113. data/spec/unit/util/filetype_spec.rb +13 -5
  114. data/spec/unit/util/logging_spec.rb +0 -41
  115. data/spec/unit/util/monkey_patches_spec.rb +18 -5
  116. data/spec/unit/util/selinux_spec.rb +4 -0
  117. metadata +6 -2
@@ -299,6 +299,7 @@ describe Puppet::Application::Device do
299
299
  @device.options.stubs(:[]).with(:facts).returns(false)
300
300
  @device.options.stubs(:[]).with(:resource).returns(false)
301
301
  @device.options.stubs(:[]).with(:to_yaml).returns(false)
302
+ @device.options.stubs(:[]).with(:libdir).returns(nil)
302
303
  @device.options.stubs(:[]).with(:client)
303
304
  @device.command_line.stubs(:args).returns([])
304
305
  Puppet::Util::NetworkDevice::Config.stubs(:devices).returns({})
@@ -504,7 +505,9 @@ describe Puppet::Application::Device do
504
505
  expect { @device.main }.to exit_with 1
505
506
  end
506
507
 
507
- it "should print the device url scheme, host, and port" do
508
+ it "should retrieve plugins and print the device url scheme, host, and port" do
509
+ Puppet.stubs(:info)
510
+ Puppet.expects(:info).with "Retrieving pluginfacts"
508
511
  Puppet.expects(:info).with "starting applying configuration to device1 at ssh://testhost"
509
512
  Puppet.expects(:info).with "starting applying configuration to device2 at https://testhost:443/some/path"
510
513
  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
@@ -74,7 +75,7 @@ describe Puppet::Application::Lookup do
74
75
  lookup.command_line.stubs(:args).returns(['atton', 'kreia'])
75
76
  lookup.stubs(:generate_scope).yields('scope')
76
77
  Puppet::Pops::Lookup.stubs(:lookup).returns('rand')
77
- expect(run_lookup(lookup)).to eql("--- rand\n...")
78
+ expect(run_lookup(lookup)).to eql("--- rand")
78
79
  end
79
80
  end
80
81
 
@@ -85,7 +86,7 @@ describe Puppet::Application::Lookup do
85
86
 
86
87
  Puppet::Pops::Lookup.stubs(:lookup).returns('rand')
87
88
 
88
- expect(run_lookup(lookup)).to eql("--- rand\n...")
89
+ expect(run_lookup(lookup)).to eql("--- rand")
89
90
  end
90
91
  end
91
92
 
@@ -502,14 +503,14 @@ Searching for "a"
502
503
  it "is unaffected by global variables unless '--compile' is used" do
503
504
  lookup.options[:node] = node
504
505
  lookup.command_line.stubs(:args).returns(['c'])
505
- expect(run_lookup(lookup)).to eql("--- This is\n...")
506
+ expect(run_lookup(lookup)).to eql("--- This is")
506
507
  end
507
508
 
508
509
  it "is affected by global variables when '--compile' is used" do
509
510
  lookup.options[:node] = node
510
511
  lookup.options[:compile] = true
511
512
  lookup.command_line.stubs(:args).returns(['c'])
512
- expect(run_lookup(lookup)).to eql("--- This is C from site.pp\n...")
513
+ expect(run_lookup(lookup)).to eql("--- This is C from site.pp")
513
514
  end
514
515
 
515
516
  it 'receives extra facts in top scope' do
@@ -523,7 +524,7 @@ Searching for "a"
523
524
  lookup.options[:node] = node
524
525
  lookup.options[:fact_file] = filename
525
526
  lookup.command_line.stubs(:args).returns(['c'])
526
- expect(run_lookup(lookup)).to eql("--- This is C from facts\n...")
527
+ expect(run_lookup(lookup)).to eql("--- This is C from facts")
527
528
  end
528
529
 
529
530
  it 'receives extra facts in the facts hash' do
@@ -537,7 +538,7 @@ Searching for "a"
537
538
  lookup.options[:node] = node
538
539
  lookup.options[:fact_file] = filename
539
540
  lookup.command_line.stubs(:args).returns(['g'])
540
- expect(run_lookup(lookup)).to eql("--- This is G from facts in facts hash\n...")
541
+ expect(run_lookup(lookup)).to eql("--- This is G from facts in facts hash")
541
542
  end
542
543
  end
543
544
 
@@ -547,14 +548,14 @@ Searching for "a"
547
548
  it "works OK in the absense of '--compile'" do
548
549
  lookup.options[:node] = node
549
550
  lookup.command_line.stubs(:args).returns(['c'])
550
- expect(run_lookup(lookup)).to eql("--- This is C from data.pp\n...")
551
+ expect(run_lookup(lookup)).to eql("--- This is C from data.pp")
551
552
  end
552
553
 
553
554
  it "global scope is affected by global variables when '--compile' is used" do
554
555
  lookup.options[:node] = node
555
556
  lookup.options[:compile] = true
556
557
  lookup.command_line.stubs(:args).returns(['c'])
557
- expect(run_lookup(lookup)).to eql("--- This is C from site.pp\n...")
558
+ expect(run_lookup(lookup)).to eql("--- This is C from site.pp")
558
559
  end
559
560
  end
560
561
  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
 
@@ -124,7 +124,7 @@ describe Puppet::Indirector::Yaml do
124
124
  Dir.expects(:glob).with(:glob).returns(%w{one.yaml two.yaml})
125
125
  YAML.expects(:load_file).with("one.yaml").returns @one;
126
126
  YAML.expects(:load_file).with("two.yaml").returns @two;
127
- expect(@store.search(@request)).to eq([@one, @two])
127
+ expect(@store.search(@request)).to contain_exactly(@one, @two)
128
128
  end
129
129
 
130
130
  it "should return an array containing a single instance of fact when globbing 'one*'" do
@@ -475,8 +475,7 @@ describe 'The Loader' do
475
475
  end
476
476
 
477
477
  context 'with no explicit dependencies' do
478
-
479
- let(:modules) {
478
+ let(:modules) do
480
479
  {
481
480
  'a' => {
482
481
  'functions' => a_functions,
@@ -496,12 +495,12 @@ describe 'The Loader' do
496
495
  'types' => c_types,
497
496
  },
498
497
  }
498
+ end
499
499
 
500
- it 'discover is only called once on dependent loader' do
501
- ModuleLoaders::FileBased.any_instance.expects(:discover).times(4).with(:type, Pcore::RUNTIME_NAME_AUTHORITY).returns([])
502
- expect(loader.private_loader.discover(:type) { |t| t.name =~ /^.::.*\z/ }).to(contain_exactly())
503
- end
504
- }
500
+ it 'discover is only called once on dependent loader' do
501
+ ModuleLoaders::FileBased.any_instance.expects(:discover).times(4).with(:type, nil, Pcore::RUNTIME_NAME_AUTHORITY).returns([])
502
+ expect(loader.private_loader.discover(:type) { |t| t.name =~ /^.::.*\z/ }).to(contain_exactly())
503
+ end
505
504
  end
506
505
  end
507
506
  end
@@ -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
@@ -698,6 +698,15 @@ describe 'The string converter' do
698
698
  expect(formatted).to eq(result)
699
699
  end
700
700
 
701
+ it 'applies a short form format' do
702
+ result = [
703
+ "[1,",
704
+ " [2, 3],",
705
+ " 4]"
706
+ ].join("\n")
707
+ expect(converter.convert([1, [2,3], 4], '%#a')).to eq(result)
708
+ end
709
+
701
710
  it 'treats hashes as nested arrays wrt indentation' do
702
711
  string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#a', 'separator' =>", " } }
703
712
  # formatting matters here
@@ -846,6 +855,17 @@ describe 'The string converter' do
846
855
  expect(converter.convert({1 => "hello", 2 => {3=> "world"}}, string_formats)).to eq(result)
847
856
  end
848
857
 
858
+ it 'applies a short form format' do
859
+ result = [
860
+ "{",
861
+ " 1 => {",
862
+ " 2 => 3",
863
+ " },",
864
+ " 4 => 5",
865
+ "}"].join("\n")
866
+ expect(converter.convert({1 => {2 => 3}, 4 => 5}, '%#h')).to eq(result)
867
+ end
868
+
849
869
  context "containing an array" do
850
870
  it 'the hash and array renders without breaks and indentation by default' do
851
871
  result = "{1 => [1, 2, 3]}"
@@ -209,6 +209,8 @@ describe Puppet::Type.type(:cron).provider(:crontab) do
209
209
  end
210
210
 
211
211
  it "should contain no resources for a user who has no crontab" do
212
+ Puppet::Util.stubs(:uid).returns(10)
213
+
212
214
  Puppet::Util::Execution.expects(:execute)
213
215
  .with('crontab -u foobar -l', { failonfail: true, combine: true })
214
216
  .returns("")
@@ -218,9 +220,8 @@ describe Puppet::Type.type(:cron).provider(:crontab) do
218
220
  end
219
221
 
220
222
  it "should contain no resources for a user who is absent" do
221
- Puppet::Util::Execution.expects(:execute)
222
- .with('crontab -u foobar -l', { failonfail: true, combine: true })
223
- .returns("")
223
+ Puppet::Util.stubs(:uid).returns(nil)
224
+
224
225
  expect(described_class.instances.select { |resource|
225
226
  resource.get('target') == 'foobar'
226
227
  }).to be_empty
@@ -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
@@ -1,9 +1,6 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
 
4
- provider_class = Puppet::Type.type(:group).provider(:pw)
5
-
6
- describe provider_class do
3
+ describe Puppet::Type.type(:group).provider(:pw) do
7
4
  let :resource do
8
5
  Puppet::Type.type(:group).new(:name => "testgroup", :provider => :pw)
9
6
  end
@@ -20,8 +17,8 @@ describe provider_class do
20
17
  end
21
18
 
22
19
  it "should run pw with no additional flags when no properties are given" do
23
- expect(provider.addcmd).to eq([provider_class.command(:pw), "groupadd", "testgroup"])
24
- provider.expects(:execute).with([provider_class.command(:pw), "groupadd", "testgroup"], kind_of(Hash))
20
+ expect(provider.addcmd).to eq([described_class.command(:pw), "groupadd", "testgroup"])
21
+ provider.expects(:execute).with([described_class.command(:pw), "groupadd", "testgroup"], kind_of(Hash))
25
22
  provider.create
26
23
  end
27
24
 
@@ -53,16 +50,16 @@ describe provider_class do
53
50
  describe "when deleting groups" do
54
51
  it "should run pw with no additional flags" do
55
52
  provider.expects(:exists?).returns true
56
- expect(provider.deletecmd).to eq([provider_class.command(:pw), "groupdel", "testgroup"])
57
- provider.expects(:execute).with([provider_class.command(:pw), "groupdel", "testgroup"], has_entry(:custom_environment, {}))
53
+ expect(provider.deletecmd).to eq([described_class.command(:pw), "groupdel", "testgroup"])
54
+ provider.expects(:execute).with([described_class.command(:pw), "groupdel", "testgroup"], has_entry(:custom_environment, {}))
58
55
  provider.delete
59
56
  end
60
57
  end
61
58
 
62
59
  describe "when modifying groups" do
63
60
  it "should run pw with the correct arguments" do
64
- expect(provider.modifycmd("gid", 12345)).to eq([provider_class.command(:pw), "groupmod", "testgroup", "-g", 12345])
65
- provider.expects(:execute).with([provider_class.command(:pw), "groupmod", "testgroup", "-g", 12345], has_entry(:custom_environment, {}))
61
+ expect(provider.modifycmd("gid", 12345)).to eq([described_class.command(:pw), "groupmod", "testgroup", "-g", 12345])
62
+ provider.expects(:execute).with([described_class.command(:pw), "groupmod", "testgroup", "-g", 12345], has_entry(:custom_environment, {}))
66
63
  provider.gid = 12345
67
64
  end
68
65
 
@@ -1,12 +1,9 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
- require 'shared_behaviours/all_parsedfile_providers'
4
2
 
3
+ require 'shared_behaviours/all_parsedfile_providers'
5
4
  require 'puppet_spec/files'
6
5
 
7
- provider_class = Puppet::Type.type(:host).provider(:parsed)
8
-
9
- describe provider_class do
6
+ describe Puppet::Type.type(:host).provider(:parsed) do
10
7
  include PuppetSpec::Files
11
8
 
12
9
  before do
@@ -46,7 +43,6 @@ describe provider_class do
46
43
  end
47
44
 
48
45
  describe "when parsing on incomplete line" do
49
-
50
46
  it "should work for only ip" do
51
47
  expect(@provider.parse_line("127.0.0.1")[:line]).to eq("127.0.0.1")
52
48
  end
@@ -78,11 +74,9 @@ describe provider_class do
78
74
  it "should work for crazy incomplete lines" do
79
75
  expect(@provider.parse_line("%th1s is a\t cr$zy !incompl1t line")[:line]).to eq("%th1s is a\t cr$zy !incompl1t line")
80
76
  end
81
-
82
77
  end
83
78
 
84
79
  describe "when parsing a line with ip and hostname" do
85
-
86
80
  it "should parse an ipv4 from the first field" do
87
81
  expect(@provider.parse_line("127.0.0.1 localhost")[:ip]).to eq("127.0.0.1")
88
82
  end
@@ -102,7 +96,6 @@ describe provider_class do
102
96
  it "should set host_aliases to :absent" do
103
97
  expect(@provider.parse_line("::1 localhost")[:host_aliases]).to eq(:absent)
104
98
  end
105
-
106
99
  end
107
100
 
108
101
  describe "when parsing a line with ip, hostname and comment" do
@@ -121,11 +114,9 @@ describe provider_class do
121
114
  it "should parse the comment after the first '#' character" do
122
115
  expect(@provider.parse_line(@testline)[:comment]).to eq('A comment with a #-char')
123
116
  end
124
-
125
117
  end
126
118
 
127
119
  describe "when parsing a line with ip, hostname and aliases" do
128
-
129
120
  it "should parse alias from the third field" do
130
121
  expect(@provider.parse_line("127.0.0.1 localhost localhost.localdomain")[:host_aliases]).to eq("localhost.localdomain")
131
122
  end
@@ -135,11 +126,9 @@ describe provider_class do
135
126
  expect(@provider.parse_line("127.0.0.1 host alias1\talias2")[:host_aliases]).to eq('alias1 alias2')
136
127
  expect(@provider.parse_line("127.0.0.1 host alias1\talias2 alias3")[:host_aliases]).to eq('alias1 alias2 alias3')
137
128
  end
138
-
139
129
  end
140
130
 
141
131
  describe "when parsing a line with ip, hostname, aliases and comment" do
142
-
143
132
  before do
144
133
  # Just playing with a few different delimiters
145
134
  @testline = "127.0.0.1\t host alias1\talias2 alias3 # A comment with a #-char"
@@ -160,12 +149,11 @@ describe provider_class do
160
149
  it "should parse the comment after the first '#' character" do
161
150
  expect(@provider.parse_line(@testline)[:comment]).to eq('A comment with a #-char')
162
151
  end
163
-
164
152
  end
165
153
 
166
154
  describe "when operating on /etc/hosts like files" do
167
155
  it_should_behave_like "all parsedfile providers",
168
- provider_class, my_fixtures('valid*')
156
+ described_class, my_fixtures('valid*')
169
157
 
170
158
  it "should be able to generate a simple hostfile entry" do
171
159
  host = mkhost(
@@ -227,7 +215,5 @@ describe provider_class do
227
215
  )
228
216
  expect(genhost(host)).to eq("192.0.0.1\thost\ta1 a2 a3 a4\t# Bazinga!\n")
229
217
  end
230
-
231
218
  end
232
-
233
219
  end