puppet 5.5.8-x64-mingw32 → 5.5.10-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.
- checksums.yaml +4 -4
- data/Gemfile.lock +14 -14
- data/Rakefile +3 -1
- data/ext/solaris/smf/svc-puppetd +8 -1
- data/ext/solaris/smf/svc-puppetmasterd +8 -1
- data/lib/puppet/application/device.rb +45 -29
- data/lib/puppet/face/config.rb +1 -1
- data/lib/puppet/forge.rb +4 -1
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
- data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
- data/lib/puppet/pops/types/string_converter.rb +11 -2
- data/lib/puppet/provider/cron/crontab.rb +1 -1
- data/lib/puppet/provider/package/windows/exe_package.rb +13 -0
- data/lib/puppet/provider/package/windows/msi_package.rb +8 -0
- data/lib/puppet/provider/package/windows/package.rb +9 -1
- data/lib/puppet/provider/parsedfile.rb +25 -4
- data/lib/puppet/provider/service/smf.rb +54 -0
- data/lib/puppet/transaction.rb +4 -1
- data/lib/puppet/transaction/event_manager.rb +13 -1
- data/lib/puppet/transaction/resource_harness.rb +3 -1
- data/lib/puppet/util/command_line.rb +2 -3
- data/lib/puppet/util/filetype.rb +36 -4
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/windows/api_types.rb +1 -1
- data/lib/puppet/util/windows/registry.rb +29 -5
- data/lib/puppet/util/windows/service.rb +106 -99
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +97 -69
- data/man/man5/puppet.conf.5 +2 -2
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-ca.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-cert.8 +1 -1
- data/man/man8/puppet-certificate.8 +1 -1
- data/man/man8/puppet-certificate_request.8 +1 -1
- data/man/man8/puppet-certificate_revocation_list.8 +1 -1
- data/man/man8/puppet-config.8 +2 -2
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +23 -19
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-master.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/provider/service/smf/svcs_fmri.out +6 -0
- data/spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out +13 -0
- data/spec/integration/ssl/key_spec.rb +0 -4
- data/spec/integration/transaction_spec.rb +1 -1
- data/spec/integration/util/windows/registry_spec.rb +39 -0
- data/spec/unit/application/device_spec.rb +4 -1
- data/spec/unit/application/lookup_spec.rb +10 -9
- data/spec/unit/forge/forge_spec.rb +4 -2
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/pops/loaders/loader_spec.rb +6 -7
- data/spec/unit/pops/types/p_timespan_type_spec.rb +22 -0
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +19 -0
- data/spec/unit/pops/types/string_converter_spec.rb +20 -0
- data/spec/unit/provider/cron/parsed_spec.rb +4 -3
- data/spec/unit/provider/group/ldap_spec.rb +22 -25
- data/spec/unit/provider/group/pw_spec.rb +7 -10
- data/spec/unit/provider/host/parsed_spec.rb +3 -17
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +97 -103
- data/spec/unit/provider/package/aix_spec.rb +5 -8
- data/spec/unit/provider/package/apt_spec.rb +3 -6
- data/spec/unit/provider/package/dnf_spec.rb +29 -31
- data/spec/unit/provider/package/dpkg_spec.rb +18 -21
- data/spec/unit/provider/package/freebsd_spec.rb +4 -7
- data/spec/unit/provider/package/gem_spec.rb +41 -41
- data/spec/unit/provider/package/hpux_spec.rb +7 -10
- data/spec/unit/provider/package/macports_spec.rb +13 -15
- data/spec/unit/provider/package/nim_spec.rb +3 -10
- data/spec/unit/provider/package/openbsd_spec.rb +14 -17
- data/spec/unit/provider/package/pip3_spec.rb +3 -6
- data/spec/unit/provider/package/pip_spec.rb +44 -72
- data/spec/unit/provider/package/pkgin_spec.rb +13 -18
- data/spec/unit/provider/package/pkgng_spec.rb +21 -24
- data/spec/unit/provider/package/puppet_gem_spec.rb +6 -9
- data/spec/unit/provider/package/tdnf_spec.rb +9 -12
- data/spec/unit/provider/package/yum_spec.rb +29 -15
- data/spec/unit/provider/package/zypper_spec.rb +17 -19
- data/spec/unit/provider/service/bsd_spec.rb +8 -12
- data/spec/unit/provider/service/daemontools_spec.rb +12 -20
- data/spec/unit/provider/service/debian_spec.rb +8 -16
- data/spec/unit/provider/service/freebsd_spec.rb +2 -5
- data/spec/unit/provider/service/openbsd_spec.rb +12 -18
- data/spec/unit/provider/service/rcng_spec.rb +3 -7
- data/spec/unit/provider/service/redhat_spec.rb +21 -23
- data/spec/unit/provider/service/runit_spec.rb +9 -19
- data/spec/unit/provider/service/smf_spec.rb +82 -21
- data/spec/unit/provider/service/src_spec.rb +14 -23
- data/spec/unit/provider/user/hpux_spec.rb +2 -5
- data/spec/unit/provider/user/ldap_spec.rb +29 -32
- data/spec/unit/provider/user/pw_spec.rb +10 -13
- data/spec/unit/ssl/key_spec.rb +2 -4
- data/spec/unit/transaction/event_manager_spec.rb +12 -1
- data/spec/unit/transaction/resource_harness_spec.rb +18 -0
- data/spec/unit/transaction_spec.rb +25 -0
- data/spec/unit/util/filetype_spec.rb +13 -5
- data/spec/unit/util/logging_spec.rb +0 -41
- data/spec/unit/util/monkey_patches_spec.rb +18 -5
- data/spec/unit/util/selinux_spec.rb +4 -0
- metadata +6 -2
@@ -1,14 +1,6 @@
|
|
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
|
-
|
9
|
-
|
10
|
-
describe provider_class do
|
11
|
-
|
3
|
+
describe Puppet::Type.type(:service).provider(:src) do
|
12
4
|
if Puppet.features.microsoft_windows?
|
13
5
|
# Get a pid for $CHILD_STATUS to latch on to
|
14
6
|
command = "cmd.exe /c \"exit 0\""
|
@@ -20,7 +12,7 @@ describe provider_class do
|
|
20
12
|
@resource.stubs(:[]).returns(nil)
|
21
13
|
@resource.stubs(:[]).with(:name).returns "myservice"
|
22
14
|
|
23
|
-
@provider =
|
15
|
+
@provider = subject()
|
24
16
|
@provider.resource = @resource
|
25
17
|
|
26
18
|
@provider.stubs(:command).with(:stopsrc).returns "/usr/bin/stopsrc"
|
@@ -42,9 +34,9 @@ describe provider_class do
|
|
42
34
|
@provider.stubs(:chitab)
|
43
35
|
end
|
44
36
|
|
45
|
-
|
37
|
+
context ".instances" do
|
46
38
|
it "should have a .instances method" do
|
47
|
-
expect(
|
39
|
+
expect(described_class).to respond_to :instances
|
48
40
|
end
|
49
41
|
|
50
42
|
it "should get a list of running services" do
|
@@ -55,8 +47,8 @@ myservice.2:::/usr/sbin/inetd:0:0:/dev/console:/dev/console:/dev/console:-O:-Q:-
|
|
55
47
|
myservice.3:::/usr/sbin/inetd:0:0:/dev/console:/dev/console:/dev/console:-O:-Q:-K:0:0:20:0:0:-d:20:tcpip:
|
56
48
|
myservice.4:::/usr/sbin/inetd:0:0:/dev/console:/dev/console:/dev/console:-O:-Q:-K:0:0:20:0:0:-d:20:tcpip:
|
57
49
|
_EOF_
|
58
|
-
|
59
|
-
expect(
|
50
|
+
described_class.stubs(:lssrc).returns sample_output
|
51
|
+
expect(described_class.instances.map(&:name)).to eq([
|
60
52
|
'myservice.1',
|
61
53
|
'myservice.2',
|
62
54
|
'myservice.3',
|
@@ -66,7 +58,7 @@ _EOF_
|
|
66
58
|
|
67
59
|
end
|
68
60
|
|
69
|
-
|
61
|
+
context "when starting a service" do
|
70
62
|
it "should execute the startsrc command" do
|
71
63
|
@provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
|
72
64
|
@provider.expects(:status).returns :running
|
@@ -80,7 +72,7 @@ _EOF_
|
|
80
72
|
end
|
81
73
|
end
|
82
74
|
|
83
|
-
|
75
|
+
context "when stopping a service" do
|
84
76
|
it "should execute the stopsrc command" do
|
85
77
|
@provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
|
86
78
|
@provider.expects(:status).returns :stopped
|
@@ -94,7 +86,7 @@ _EOF_
|
|
94
86
|
end
|
95
87
|
end
|
96
88
|
|
97
|
-
|
89
|
+
context "should have a set of methods" do
|
98
90
|
[:enabled?, :enable, :disable, :start, :stop, :status, :restart].each do |method|
|
99
91
|
it "should have a #{method} method" do
|
100
92
|
expect(@provider).to respond_to(method)
|
@@ -102,21 +94,21 @@ _EOF_
|
|
102
94
|
end
|
103
95
|
end
|
104
96
|
|
105
|
-
|
97
|
+
context "when enabling" do
|
106
98
|
it "should execute the mkitab command" do
|
107
99
|
@provider.expects(:mkitab).with("myservice:2:once:/usr/bin/startsrc -s myservice").once
|
108
100
|
@provider.enable
|
109
101
|
end
|
110
102
|
end
|
111
103
|
|
112
|
-
|
104
|
+
context "when disabling" do
|
113
105
|
it "should execute the rmitab command" do
|
114
106
|
@provider.expects(:rmitab).with("myservice")
|
115
107
|
@provider.disable
|
116
108
|
end
|
117
109
|
end
|
118
110
|
|
119
|
-
|
111
|
+
context "when checking if it is enabled" do
|
120
112
|
it "should execute the lsitab command" do
|
121
113
|
@provider.expects(:execute).with(['/usr/sbin/lsitab', 'myservice'], {:combine => true, :failonfail => false})
|
122
114
|
$CHILD_STATUS.stubs(:exitstatus).returns(0)
|
@@ -136,8 +128,7 @@ _EOF_
|
|
136
128
|
end
|
137
129
|
end
|
138
130
|
|
139
|
-
|
140
|
-
describe "when checking a subsystem's status" do
|
131
|
+
context "when checking a subsystem's status" do
|
141
132
|
it "should execute status and return running if the subsystem is active" do
|
142
133
|
sample_output = <<_EOF_
|
143
134
|
Subsystem Group PID Status
|
@@ -174,7 +165,7 @@ _EOF_
|
|
174
165
|
end
|
175
166
|
end
|
176
167
|
|
177
|
-
|
168
|
+
context "when restarting a service" do
|
178
169
|
it "should execute restart which runs refresh" do
|
179
170
|
sample_output = <<_EOF_
|
180
171
|
#subsysname:synonym:cmdargs:path:uid:auditid:standin:standout:standerr:action:multi:contact:svrkey:svrmtype:priority:signorm:sigforce:display:waittime:grpname:
|
@@ -1,10 +1,7 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
require 'spec_helper'
|
3
2
|
require 'etc'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
4
|
+
describe Puppet::Type.type(:user).provider(:hpuxuseradd), :unless => Puppet.features.microsoft_windows? do
|
8
5
|
let :resource do
|
9
6
|
Puppet::Type.type(:user).new(
|
10
7
|
:title => 'testuser',
|
@@ -38,7 +35,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
38
35
|
end
|
39
36
|
|
40
37
|
it "should have feature manages_passwords" do
|
41
|
-
expect(
|
38
|
+
expect(described_class).to be_manages_passwords
|
42
39
|
end
|
43
40
|
|
44
41
|
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
|
-
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
33
|
+
expect(described_class.manager.ldap_name(puppet)).to eq(ldap)
|
37
34
|
end
|
38
35
|
end
|
39
36
|
|
40
|
-
|
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
|
-
|
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 =
|
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 =
|
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
|
-
|
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
|
-
|
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 =
|
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
|
-
|
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 =
|
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
|
-
|
114
|
+
context "when flushing" do
|
118
115
|
before do
|
119
|
-
|
116
|
+
described_class.stubs(:suitable?).returns true
|
120
117
|
|
121
|
-
@instance =
|
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
|
-
|
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
|
-
|
148
|
+
described_class.stubs(:suitable?).returns true
|
152
149
|
|
153
|
-
@instance =
|
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
|
-
|
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
|
-
|
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 =
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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([
|
20
|
-
provider.expects(:execute).with([
|
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
|
-
|
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([
|
112
|
-
provider.expects(:execute).with([
|
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
|
-
|
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([
|
143
|
-
provider.expects(:execute).with([
|
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
|
|
data/spec/unit/ssl/key_spec.rb
CHANGED
@@ -129,8 +129,8 @@ describe Puppet::SSL::Key do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should create the private key with the keylength specified in the settings" do
|
132
|
-
Puppet[:keylength] =
|
133
|
-
OpenSSL::PKey::RSA.expects(:new).with(
|
132
|
+
Puppet[:keylength] = 513
|
133
|
+
OpenSSL::PKey::RSA.expects(:new).with(513).returns(@key)
|
134
134
|
|
135
135
|
@instance.generate
|
136
136
|
end
|
@@ -172,8 +172,6 @@ describe Puppet::SSL::Key do
|
|
172
172
|
end
|
173
173
|
|
174
174
|
it "should export the private key to text using the password" do
|
175
|
-
Puppet[:keylength] = "50"
|
176
|
-
|
177
175
|
@instance.password_file = "/path/to/pass"
|
178
176
|
@instance.stubs(:password).returns "my password"
|
179
177
|
|
@@ -174,11 +174,22 @@ describe Puppet::Transaction::EventManager do
|
|
174
174
|
expect(@transaction.resource_status(@resource)).to be_restarted
|
175
175
|
end
|
176
176
|
|
177
|
+
it "should have an event on the resource status" do
|
178
|
+
@manager.expects(:queued_events).with(@resource).yields(:callback1, [@event])
|
179
|
+
|
180
|
+
@resource.stubs(:callback1)
|
181
|
+
|
182
|
+
@manager.process_events(@resource) #x
|
183
|
+
|
184
|
+
expect(@transaction.resource_status(@resource).events.length).to eq(1)
|
185
|
+
end
|
186
|
+
|
177
187
|
it "should queue a 'restarted' event generated by the resource" do
|
178
188
|
@manager.expects(:queued_events).with(@resource).yields(:callback1, [@event])
|
179
189
|
|
180
190
|
@resource.stubs(:callback1)
|
181
191
|
|
192
|
+
@resource.expects(:event).with(:message => "Triggered 'callback1' from 1 event", :status => 'success', :name => 'callback1')
|
182
193
|
@resource.expects(:event).with(:name => :restarted, :status => "success").returns "myevent"
|
183
194
|
@manager.expects(:queue_events).with(@resource, ["myevent"])
|
184
195
|
|
@@ -295,7 +306,7 @@ describe Puppet::Transaction::EventManager do
|
|
295
306
|
it "should record a failed event on the resource status" do
|
296
307
|
@manager.process_events(@resource)
|
297
308
|
|
298
|
-
expect(@transaction.resource_status(@resource).events.length).to eq(
|
309
|
+
expect(@transaction.resource_status(@resource).events.length).to eq(2)
|
299
310
|
expect(@transaction.resource_status(@resource).events[0].status).to eq('failure')
|
300
311
|
end
|
301
312
|
|
@@ -173,6 +173,10 @@ describe Puppet::Transaction::ResourceHarness do
|
|
173
173
|
def insync?(value)
|
174
174
|
@resource.behaviors[:ensure_insync?]
|
175
175
|
end
|
176
|
+
|
177
|
+
def should_to_s(value)
|
178
|
+
(@resource.behaviors[:on_should_to_s] || proc { "'#{value}'" }).call
|
179
|
+
end
|
176
180
|
end
|
177
181
|
|
178
182
|
newparam(:name) do
|
@@ -266,6 +270,20 @@ describe Puppet::Transaction::ResourceHarness do
|
|
266
270
|
|
267
271
|
expect(status.events).to be_empty
|
268
272
|
end
|
273
|
+
|
274
|
+
it "ensure errors in message still get a log entry" do
|
275
|
+
resource = an_ensurable_resource_reacting_as(:ensure_insync? => false, :on_ensure => proc { raise StandardError }, :on_should_to_s => proc { raise StandardError }, :present? => true)
|
276
|
+
|
277
|
+
status = @harness.evaluate(resource)
|
278
|
+
|
279
|
+
expect(status.events.length).to eq(2)
|
280
|
+
testing_errors = status.events.find_all { |x| x.name.to_s == "Testing_created" }
|
281
|
+
resource_errors = status.events.find_all { |x| x.name.to_s == "resource_error" }
|
282
|
+
expect(testing_errors.length).to eq(1)
|
283
|
+
expect(resource_errors.length).to eq(1)
|
284
|
+
expect(testing_errors[0].message).not_to be_nil
|
285
|
+
expect(resource_errors[0].message).not_to eq("Puppet::Util::Log requires a message")
|
286
|
+
end
|
269
287
|
end
|
270
288
|
|
271
289
|
describe "when a caught error occurs" do
|