puppet 6.0.4-universal-darwin → 6.0.5-universal-darwin

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
@@ -1,11 +1,7 @@
1
- #! /usr/bin/env ruby
2
- #
3
- # Unit testing for the AIX System Resource Controller (src) provider
4
- #
5
-
6
1
  require 'spec_helper'
7
2
 
8
- describe 'Puppet::Type::Service::Provider::Src', unless: Puppet::Util::Platform.jruby? do
3
+ describe 'Puppet::Type::Service::Provider::Src',
4
+ unless: Puppet::Util::Platform.jruby? do
9
5
  let(:provider_class) { Puppet::Type.type(:service).provider(:src) }
10
6
 
11
7
  if Puppet::Util::Platform.windows?
@@ -41,7 +37,7 @@ describe 'Puppet::Type::Service::Provider::Src', unless: Puppet::Util::Platform.
41
37
  @provider.stubs(:chitab)
42
38
  end
43
39
 
44
- describe ".instances" do
40
+ context ".instances" do
45
41
  it "should have a .instances method" do
46
42
  expect(provider_class).to respond_to :instances
47
43
  end
@@ -65,7 +61,7 @@ _EOF_
65
61
 
66
62
  end
67
63
 
68
- describe "when starting a service" do
64
+ context "when starting a service" do
69
65
  it "should execute the startsrc command" do
70
66
  @provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
71
67
  @provider.expects(:status).returns :running
@@ -79,7 +75,7 @@ _EOF_
79
75
  end
80
76
  end
81
77
 
82
- describe "when stopping a service" do
78
+ context "when stopping a service" do
83
79
  it "should execute the stopsrc command" do
84
80
  @provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
85
81
  @provider.expects(:status).returns :stopped
@@ -93,7 +89,7 @@ _EOF_
93
89
  end
94
90
  end
95
91
 
96
- describe "should have a set of methods" do
92
+ context "should have a set of methods" do
97
93
  [:enabled?, :enable, :disable, :start, :stop, :status, :restart].each do |method|
98
94
  it "should have a #{method} method" do
99
95
  expect(@provider).to respond_to(method)
@@ -101,21 +97,21 @@ _EOF_
101
97
  end
102
98
  end
103
99
 
104
- describe "when enabling" do
100
+ context "when enabling" do
105
101
  it "should execute the mkitab command" do
106
102
  @provider.expects(:mkitab).with("myservice:2:once:/usr/bin/startsrc -s myservice").once
107
103
  @provider.enable
108
104
  end
109
105
  end
110
106
 
111
- describe "when disabling" do
107
+ context "when disabling" do
112
108
  it "should execute the rmitab command" do
113
109
  @provider.expects(:rmitab).with("myservice")
114
110
  @provider.disable
115
111
  end
116
112
  end
117
113
 
118
- describe "when checking if it is enabled" do
114
+ context "when checking if it is enabled" do
119
115
  it "should execute the lsitab command" do
120
116
  @provider.expects(:execute).with(['/usr/sbin/lsitab', 'myservice'], {:combine => true, :failonfail => false})
121
117
  $CHILD_STATUS.stubs(:exitstatus).returns(0)
@@ -135,8 +131,7 @@ _EOF_
135
131
  end
136
132
  end
137
133
 
138
-
139
- describe "when checking a subsystem's status" do
134
+ context "when checking a subsystem's status" do
140
135
  it "should execute status and return running if the subsystem is active" do
141
136
  sample_output = <<_EOF_
142
137
  Subsystem Group PID Status
@@ -173,7 +168,7 @@ _EOF_
173
168
  end
174
169
  end
175
170
 
176
- describe "when restarting a service" do
171
+ context "when restarting a service" do
177
172
  it "should execute restart which runs refresh" do
178
173
  sample_output = <<_EOF_
179
174
  #subsysname:synonym:cmdargs:path:uid:auditid:standin:standout:standerr:action:multi:contact:svrkey:svrmtype:priority:signorm:sigforce:display:waittime:grpname:
@@ -143,6 +143,24 @@ describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platf
143
143
  end
144
144
  end
145
145
 
146
+ [ '10', '11', '12', '13', '14', '15', '16', '17' ].each do |ver|
147
+ it "should not be the default provider on LinuxMint#{ver}" do
148
+ Facter.stubs(:value).with(:osfamily).returns(:debian)
149
+ Facter.stubs(:value).with(:operatingsystem).returns(:LinuxMint)
150
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("#{ver}")
151
+ expect(provider_class).not_to be_default
152
+ end
153
+ end
154
+
155
+ [ '18', '19' ].each do |ver|
156
+ it "should be the default provider on LinuxMint#{ver}" do
157
+ Facter.stubs(:value).with(:osfamily).returns(:debian)
158
+ Facter.stubs(:value).with(:operatingsystem).returns(:LinuxMint)
159
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("#{ver}")
160
+ expect(provider_class).to be_default
161
+ end
162
+ end
163
+
146
164
  [:enabled?, :enable, :disable, :start, :stop, :status, :restart].each do |method|
147
165
  it "should have a #{method} method" do
148
166
  expect(provider).to respond_to(method)
@@ -1,10 +1,8 @@
1
- #!/usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
  require 'etc'
4
3
 
5
- provider_class = Puppet::Type.type(:user).provider(:hpuxuseradd)
6
-
7
- describe provider_class, :unless => Puppet::Util::Platform.windows? do
4
+ describe Puppet::Type.type(:user).provider(:hpuxuseradd),
5
+ unless: Puppet::Util::Platform.windows? do
8
6
  let :resource do
9
7
  Puppet::Type.type(:user).new(
10
8
  :title => 'testuser',
@@ -39,7 +37,7 @@ describe provider_class, :unless => Puppet::Util::Platform.windows? do
39
37
  end
40
38
 
41
39
  it "should have feature manages_passwords" do
42
- expect(provider_class).to be_manages_passwords
40
+ expect(described_class).to be_manages_passwords
43
41
  end
44
42
 
45
43
  it "should return nil if user does not exist" do
@@ -1,27 +1,24 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
 
4
- provider_class = Puppet::Type.type(:user).provider(:ldap)
5
-
6
- describe provider_class do
3
+ describe Puppet::Type.type(:user).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 :posixAccount and :person objectclasses" do
12
- expect(provider_class.manager.objectclasses).to eq([:posixAccount, :person])
9
+ expect(described_class.manager.objectclasses).to eq([:posixAccount, :person])
13
10
  end
14
11
 
15
12
  it "should use 'ou=People' as its relative base" do
16
- expect(provider_class.manager.location).to eq("ou=People")
13
+ expect(described_class.manager.location).to eq("ou=People")
17
14
  end
18
15
 
19
16
  it "should use :uid as its rdn" do
20
- expect(provider_class.manager.rdn).to eq(:uid)
17
+ expect(described_class.manager.rdn).to eq(:uid)
21
18
  end
22
19
 
23
20
  it "should be able to manage passwords" do
24
- expect(provider_class).to be_manages_passwords
21
+ expect(described_class).to be_manages_passwords
25
22
  end
26
23
 
27
24
  {:name => "uid",
@@ -33,15 +30,15 @@ describe provider_class do
33
30
  :shell => "loginShell"
34
31
  }.each do |puppet, ldap|
35
32
  it "should map :#{puppet.to_s} to '#{ldap}'" do
36
- expect(provider_class.manager.ldap_name(puppet)).to eq(ldap)
33
+ expect(described_class.manager.ldap_name(puppet)).to eq(ldap)
37
34
  end
38
35
  end
39
36
 
40
- describe "when being created" do
37
+ context "when being created" do
41
38
  before do
42
39
  # So we don't try to actually talk to ldap
43
40
  @connection = mock 'connection'
44
- provider_class.manager.stubs(:connect).yields @connection
41
+ described_class.manager.stubs(:connect).yields @connection
45
42
  end
46
43
 
47
44
  it "should generate the sn as the last field of the cn" do
@@ -50,7 +47,7 @@ describe provider_class do
50
47
  resource = stub 'resource', :should => %w{whatever}
51
48
  resource.stubs(:should).with(:comment).returns ["Luke Kanies"]
52
49
  resource.stubs(:should).with(:ensure).returns :present
53
- instance = provider_class.new(:name => "luke", :ensure => :absent)
50
+ instance = described_class.new(:name => "luke", :ensure => :absent)
54
51
 
55
52
  instance.stubs(:resource).returns resource
56
53
 
@@ -66,7 +63,7 @@ describe provider_class do
66
63
  resource = stub 'resource', :should => %w{whatever}
67
64
  resource.stubs(:should).with(:gid).returns 'bar'
68
65
  resource.stubs(:should).with(:ensure).returns :present
69
- instance = provider_class.new(:name => "luke", :ensure => :absent)
66
+ instance = described_class.new(:name => "luke", :ensure => :absent)
70
67
  instance.stubs(:resource).returns resource
71
68
 
72
69
  @connection.expects(:add).with { |dn, attrs| attrs["gidNumber"] == ["101"] }
@@ -75,18 +72,18 @@ describe provider_class do
75
72
  instance.flush
76
73
  end
77
74
 
78
- describe "with no uid specified" do
75
+ context "with no uid specified" do
79
76
  it "should pick the first available UID after the largest existing UID" do
80
77
  Puppet::Type.type(:group).provider(:ldap).expects(:name2id).with(["whatever"]).returns [123]
81
78
 
82
79
  low = {:name=>["luke"], :shell=>:absent, :uid=>["600"], :home=>["/h"], :gid=>["1000"], :password=>["blah"], :comment=>["l k"]}
83
80
  high = {:name=>["testing"], :shell=>:absent, :uid=>["640"], :home=>["/h"], :gid=>["1000"], :password=>["blah"], :comment=>["t u"]}
84
- provider_class.manager.expects(:search).returns([low, high])
81
+ described_class.manager.expects(:search).returns([low, high])
85
82
 
86
83
  resource = stub 'resource', :should => %w{whatever}
87
84
  resource.stubs(:should).with(:uid).returns nil
88
85
  resource.stubs(:should).with(:ensure).returns :present
89
- instance = provider_class.new(:name => "luke", :ensure => :absent)
86
+ instance = described_class.new(:name => "luke", :ensure => :absent)
90
87
  instance.stubs(:resource).returns resource
91
88
 
92
89
  @connection.expects(:add).with { |dn, attrs| attrs["uidNumber"] == ["641"] }
@@ -98,12 +95,12 @@ describe provider_class do
98
95
  it "should pick 501 of no users exist" do
99
96
  Puppet::Type.type(:group).provider(:ldap).expects(:name2id).with(["whatever"]).returns [123]
100
97
 
101
- provider_class.manager.expects(:search).returns nil
98
+ described_class.manager.expects(:search).returns nil
102
99
 
103
100
  resource = stub 'resource', :should => %w{whatever}
104
101
  resource.stubs(:should).with(:uid).returns nil
105
102
  resource.stubs(:should).with(:ensure).returns :present
106
- instance = provider_class.new(:name => "luke", :ensure => :absent)
103
+ instance = described_class.new(:name => "luke", :ensure => :absent)
107
104
  instance.stubs(:resource).returns resource
108
105
 
109
106
  @connection.expects(:add).with { |dn, attrs| attrs["uidNumber"] == ["501"] }
@@ -114,11 +111,11 @@ describe provider_class do
114
111
  end
115
112
  end
116
113
 
117
- describe "when flushing" do
114
+ context "when flushing" do
118
115
  before do
119
- provider_class.stubs(:suitable?).returns true
116
+ described_class.stubs(:suitable?).returns true
120
117
 
121
- @instance = provider_class.new(:name => "myname", :groups => %w{whatever}, :uid => "400")
118
+ @instance = described_class.new(:name => "myname", :groups => %w{whatever}, :uid => "400")
122
119
  end
123
120
 
124
121
  it "should remove the :groups value before updating" do
@@ -144,13 +141,13 @@ describe provider_class do
144
141
  end
145
142
  end
146
143
 
147
- describe "when checking group membership" do
144
+ context "when checking group membership" do
148
145
  before do
149
146
  @groups = Puppet::Type.type(:group).provider(:ldap)
150
147
  @group_manager = @groups.manager
151
- provider_class.stubs(:suitable?).returns true
148
+ described_class.stubs(:suitable?).returns true
152
149
 
153
- @instance = provider_class.new(:name => "myname")
150
+ @instance = described_class.new(:name => "myname")
154
151
  end
155
152
 
156
153
  it "should show its group membership as the sorted list of all groups returned by an ldap query of group memberships" do
@@ -175,11 +172,11 @@ describe provider_class do
175
172
  end
176
173
  end
177
174
 
178
- describe "when modifying group membership" do
175
+ context "when modifying group membership" do
179
176
  before do
180
177
  @groups = Puppet::Type.type(:group).provider(:ldap)
181
178
  @group_manager = @groups.manager
182
- provider_class.stubs(:suitable?).returns true
179
+ described_class.stubs(:suitable?).returns true
183
180
 
184
181
  @one = {:name => "one", :gid => "500"}
185
182
  @group_manager.stubs(:find).with("one").returns(@one)
@@ -187,7 +184,7 @@ describe provider_class do
187
184
  @two = {:name => "one", :gid => "600"}
188
185
  @group_manager.stubs(:find).with("two").returns(@two)
189
186
 
190
- @instance = provider_class.new(:name => "myname")
187
+ @instance = described_class.new(:name => "myname")
191
188
 
192
189
  @instance.stubs(:groups).returns :absent
193
190
  end
@@ -231,7 +228,7 @@ describe provider_class do
231
228
  @instance.groups = "one"
232
229
  end
233
230
 
234
- describe "for groups that have no members" do
231
+ context "for groups that have no members" do
235
232
  it "should create a new members attribute with its value being the user's name" do
236
233
  @group_manager.expects(:update).with { |name, is, should| should[:members] == %w{myname} }
237
234
 
@@ -239,7 +236,7 @@ describe provider_class do
239
236
  end
240
237
  end
241
238
 
242
- describe "for groups it is being removed from" do
239
+ context "for groups it is being removed from" do
243
240
  it "should replace the group's member list with one missing the user's name" do
244
241
  @one[:members] = %w{myname a}
245
242
  @two[:members] = %w{myname b}
@@ -261,7 +258,7 @@ describe provider_class do
261
258
  end
262
259
  end
263
260
 
264
- describe "for groups that already have members" do
261
+ context "for groups that already have members" do
265
262
  it "should replace each group's member list with a new list including the user's name" do
266
263
  @one[:members] = %w{a b}
267
264
  @group_manager.expects(:update).with { |name, is, should| should[:members] == %w{a b myname} }
@@ -272,7 +269,7 @@ describe provider_class do
272
269
  end
273
270
  end
274
271
 
275
- describe "for groups of which it is a member" do
272
+ context "for groups of which it is a member" do
276
273
  it "should do nothing" do
277
274
  @one[:members] = %w{a b}
278
275
  @group_manager.expects(:update).with { |name, is, should| should[:members] == %w{a b myname} }
@@ -1,14 +1,11 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
 
4
- provider_class = Puppet::Type.type(:user).provider(:pw)
5
-
6
- describe provider_class do
3
+ describe Puppet::Type.type(:user).provider(:pw) do
7
4
  let :resource do
8
5
  Puppet::Type.type(:user).new(:name => "testuser", :provider => :pw)
9
6
  end
10
7
 
11
- describe "when creating users" do
8
+ context "when creating users" do
12
9
  let :provider do
13
10
  prov = resource.provider
14
11
  prov.expects(:exists?).returns nil
@@ -16,8 +13,8 @@ describe provider_class do
16
13
  end
17
14
 
18
15
  it "should run pw with no additional flags when no properties are given" do
19
- expect(provider.addcmd).to eq([provider_class.command(:pw), "useradd", "testuser"])
20
- provider.expects(:execute).with([provider_class.command(:pw), "useradd", "testuser"], kind_of(Hash))
16
+ expect(provider.addcmd).to eq([described_class.command(:pw), "useradd", "testuser"])
17
+ provider.expects(:execute).with([described_class.command(:pw), "useradd", "testuser"], kind_of(Hash))
21
18
  provider.create
22
19
  end
23
20
 
@@ -104,12 +101,12 @@ describe provider_class do
104
101
  end
105
102
  end
106
103
 
107
- describe "when deleting users" do
104
+ context "when deleting users" do
108
105
  it "should run pw with no additional flags" do
109
106
  provider = resource.provider
110
107
  provider.expects(:exists?).returns true
111
- expect(provider.deletecmd).to eq([provider_class.command(:pw), "userdel", "testuser"])
112
- provider.expects(:execute).with([provider_class.command(:pw), "userdel", "testuser"], has_entry(:custom_environment, {}))
108
+ expect(provider.deletecmd).to eq([described_class.command(:pw), "userdel", "testuser"])
109
+ provider.expects(:execute).with([described_class.command(:pw), "userdel", "testuser"], has_entry(:custom_environment, {}))
113
110
  provider.delete
114
111
  end
115
112
 
@@ -133,14 +130,14 @@ describe provider_class do
133
130
  end
134
131
  end
135
132
 
136
- describe "when modifying users" do
133
+ context "when modifying users" do
137
134
  let :provider do
138
135
  resource.provider
139
136
  end
140
137
 
141
138
  it "should run pw with the correct arguments" do
142
- expect(provider.modifycmd("uid", 12345)).to eq([provider_class.command(:pw), "usermod", "testuser", "-u", 12345])
143
- provider.expects(:execute).with([provider_class.command(:pw), "usermod", "testuser", "-u", 12345], has_entry(:custom_environment, {}))
139
+ expect(provider.modifycmd("uid", 12345)).to eq([described_class.command(:pw), "usermod", "testuser", "-u", 12345])
140
+ provider.expects(:execute).with([described_class.command(:pw), "usermod", "testuser", "-u", 12345], has_entry(:custom_environment, {}))
144
141
  provider.uid = 12345
145
142
  end
146
143
 
@@ -91,7 +91,7 @@ describe Puppet::Rest::Route do
91
91
  @srv_records = [record]
92
92
 
93
93
  @dns_mock.expects(:getresources).
94
- with("_x-puppet._tcp.test_service", Resolv::DNS::Resource::IN::SRV).
94
+ with("_x-puppet-test_service._tcp.example.com", Resolv::DNS::Resource::IN::SRV).
95
95
  returns(@srv_records)
96
96
  end
97
97
 
@@ -155,6 +155,27 @@ describe Puppet::SSL::Host, if: !Puppet::Util::Platform.jruby? do
155
155
  expect{ host.validate_certificate_with_key(certificate) }.not_to raise_error
156
156
  end
157
157
 
158
+ it "should output agent-specific commands when validation fails" do
159
+ host = Puppet::SSL::Host.new("foo")
160
+ key = mock 'key', :content => "private_key"
161
+ sslcert = mock 'sslcert'
162
+ certificate = mock 'cert', {:content => sslcert, :fingerprint => 'DEADBEEF'}
163
+ host.stubs(:key).returns key
164
+ sslcert.expects(:check_private_key).with("private_key").returns false
165
+ expect { host.validate_certificate_with_key(certificate) }.to raise_error(Puppet::Error, /puppet ssl clean \n/)
166
+ end
167
+
168
+ it "should output device-specific commands when validation fails" do
169
+ Puppet[:certname] = "device.example.com"
170
+ host = Puppet::SSL::Host.new("device.example.com", true)
171
+ key = mock 'key', :content => "private_key"
172
+ sslcert = mock 'sslcert'
173
+ certificate = mock 'cert', {:content => sslcert, :fingerprint => 'DEADBEEF'}
174
+ host.stubs(:key).returns key
175
+ sslcert.expects(:check_private_key).with("private_key").returns false
176
+ expect { host.validate_certificate_with_key(certificate) }.to raise_error(Puppet::Error, /puppet ssl clean --target device.example.com/)
177
+ end
178
+
158
179
  describe "when initializing" do
159
180
  it "should default its name to the :certname setting" do
160
181
  Puppet[:certname] = "myname"
@@ -114,8 +114,8 @@ describe Puppet::SSL::Key do
114
114
  end
115
115
 
116
116
  it "should create the private key with the keylength specified in the settings" do
117
- Puppet[:keylength] = "50"
118
- OpenSSL::PKey::RSA.expects(:new).with(50).returns(@key)
117
+ Puppet[:keylength] = 513
118
+ OpenSSL::PKey::RSA.expects(:new).with(513).returns(@key)
119
119
 
120
120
  @instance.generate
121
121
  end
@@ -157,8 +157,6 @@ describe Puppet::SSL::Key do
157
157
  end
158
158
 
159
159
  it "should export the private key to text using the password" do
160
- Puppet[:keylength] = "50"
161
-
162
160
  @instance.password_file = "/path/to/pass"
163
161
  @instance.stubs(:password).returns "my password"
164
162