puppet 5.5.18-x64-mingw32 → 5.5.19-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 +12 -11
- data/lib/puppet.rb +5 -2
- data/lib/puppet/application/filebucket.rb +13 -0
- data/lib/puppet/defaults.rb +60 -33
- data/lib/puppet/indirector/catalog/compiler.rb +8 -0
- data/lib/puppet/network/http/connection.rb +4 -0
- data/lib/puppet/network/http/pool.rb +5 -1
- data/lib/puppet/pops/evaluator/access_operator.rb +2 -2
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +1 -1
- data/lib/puppet/pops/types/type_calculator.rb +24 -0
- data/lib/puppet/provider/group/groupadd.rb +19 -19
- data/lib/puppet/provider/mailalias/aliases.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +14 -3
- data/lib/puppet/provider/package/dnfmodule.rb +9 -2
- data/lib/puppet/provider/package/dpkg.rb +13 -6
- data/lib/puppet/provider/package/fink.rb +20 -3
- data/lib/puppet/provider/package/openbsd.rb +13 -1
- data/lib/puppet/provider/package/pkg.rb +18 -5
- data/lib/puppet/provider/package/yum.rb +9 -5
- data/lib/puppet/provider/user/directoryservice.rb +30 -5
- data/lib/puppet/provider/user/useradd.rb +5 -6
- data/lib/puppet/ssl/certificate.rb +2 -1
- data/lib/puppet/ssl/certificate_authority.rb +6 -5
- data/lib/puppet/test/test_helper.rb +7 -0
- data/lib/puppet/transaction/resource_harness.rb +1 -1
- data/lib/puppet/type/file.rb +13 -0
- data/lib/puppet/type/package.rb +63 -9
- data/lib/puppet/util/plist.rb +6 -0
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +100 -92
- data/man/man5/puppet.conf.5 +12 -6
- 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 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- 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 +16 -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/integration/provider/mailalias/aliases/test1 +1 -0
- data/spec/integration/indirector/facts/facter_spec.rb +4 -0
- data/spec/unit/application/apply_spec.rb +2 -12
- data/spec/unit/configurer/fact_handler_spec.rb +0 -4
- data/spec/unit/configurer_spec.rb +0 -3
- data/spec/unit/indirector/catalog/compiler_spec.rb +45 -26
- data/spec/unit/network/http/connection_spec.rb +17 -1
- data/spec/unit/network/http/pool_spec.rb +32 -0
- data/spec/unit/node_spec.rb +7 -4
- data/spec/unit/provider/group/groupadd_spec.rb +30 -1
- data/spec/unit/provider/package/apt_spec.rb +13 -2
- data/spec/unit/provider/package/aptitude_spec.rb +1 -0
- data/spec/unit/provider/package/dnfmodule_spec.rb +22 -0
- data/spec/unit/provider/package/dpkg_spec.rb +20 -4
- data/spec/unit/provider/package/openbsd_spec.rb +17 -0
- data/spec/unit/provider/package/pkg_spec.rb +13 -1
- data/spec/unit/provider/package/yum_spec.rb +50 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +41 -0
- data/spec/unit/provider/user/useradd_spec.rb +7 -2
- data/spec/unit/puppet_pal_2pec.rb +3 -0
- data/spec/unit/ssl/certificate_authority_spec.rb +2 -3
- data/spec/unit/ssl/certificate_spec.rb +7 -0
- data/spec/unit/type/package_spec.rb +8 -0
- data/spec/unit/util/plist_spec.rb +20 -0
- metadata +2 -2
@@ -9,19 +9,9 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
9
9
|
let(:node_name) { "foo" }
|
10
10
|
let(:node) { Puppet::Node.new(node_name)}
|
11
11
|
|
12
|
-
before do
|
13
|
-
allow(Facter).to receive(:to_hash).and_return({})
|
14
|
-
end
|
15
|
-
|
16
12
|
describe "when initializing" do
|
17
13
|
before do
|
18
|
-
|
19
|
-
expect(Facter).to receive(:value).with('fqdn').and_return("my.server.com")
|
20
|
-
expect(Facter).to receive(:value).with('ipaddress').and_return("my.ip.address")
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should gather data about itself" do
|
24
|
-
Puppet::Resource::Catalog::Compiler.new
|
14
|
+
allow(Puppet).to receive(:version).and_return(1)
|
25
15
|
end
|
26
16
|
|
27
17
|
it "should cache the server metadata and reuse it" do
|
@@ -38,8 +28,6 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
38
28
|
|
39
29
|
describe "when finding catalogs" do
|
40
30
|
before do
|
41
|
-
allow(Facter).to receive(:value).and_return("whatever")
|
42
|
-
|
43
31
|
allow(node).to receive(:merge)
|
44
32
|
allow(Puppet::Node.indirection).to receive(:find).and_return(node)
|
45
33
|
@request = Puppet::Indirector::Request.new(:catalog, :find, node_name, nil, :node => node_name)
|
@@ -246,10 +234,10 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
246
234
|
|
247
235
|
describe "when handling a request with facts" do
|
248
236
|
before do
|
249
|
-
Puppet::Node::Facts.indirection.terminus_class = :memory
|
250
237
|
allow(Facter).to receive(:value).and_return("something")
|
251
238
|
|
252
|
-
|
239
|
+
facts = Puppet::Node::Facts.new('hostname', "fact" => "value", "architecture" => "i386")
|
240
|
+
Puppet::Node::Facts.indirection.save(facts)
|
253
241
|
end
|
254
242
|
|
255
243
|
def a_legacy_request_that_contains(facts, format = :pson)
|
@@ -267,6 +255,8 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
267
255
|
end
|
268
256
|
|
269
257
|
context "when extracting facts from the request" do
|
258
|
+
let(:facts) { Puppet::Node::Facts.new("hostname") }
|
259
|
+
|
270
260
|
it "should do nothing if no facts are provided" do
|
271
261
|
request = Puppet::Indirector::Request.new(:catalog, :find, "hostname", nil)
|
272
262
|
request.options[:facts] = nil
|
@@ -276,21 +266,21 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
276
266
|
|
277
267
|
it "should deserialize the facts without changing the timestamp" do
|
278
268
|
time = Time.now
|
279
|
-
|
280
|
-
request = a_request_that_contains(
|
269
|
+
facts.timestamp = time
|
270
|
+
request = a_request_that_contains(facts)
|
281
271
|
facts = compiler.extract_facts_from_request(request)
|
282
272
|
expect(facts.timestamp).to eq(time)
|
283
273
|
end
|
284
274
|
|
285
275
|
it "accepts PSON facts from older agents" do
|
286
|
-
request = a_legacy_request_that_contains(
|
276
|
+
request = a_legacy_request_that_contains(facts)
|
287
277
|
|
288
278
|
facts = compiler.extract_facts_from_request(request)
|
289
|
-
expect(facts).to eq(
|
279
|
+
expect(facts).to eq(facts)
|
290
280
|
end
|
291
281
|
|
292
282
|
it "rejects YAML facts" do
|
293
|
-
request = a_legacy_request_that_contains(
|
283
|
+
request = a_legacy_request_that_contains(facts, :yaml)
|
294
284
|
|
295
285
|
expect {
|
296
286
|
compiler.extract_facts_from_request(request)
|
@@ -298,7 +288,7 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
298
288
|
end
|
299
289
|
|
300
290
|
it "rejects unknown fact formats" do
|
301
|
-
request = a_request_that_contains(
|
291
|
+
request = a_request_that_contains(facts)
|
302
292
|
request.options[:facts_format] = 'unknown-format'
|
303
293
|
|
304
294
|
expect {
|
@@ -308,15 +298,17 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
308
298
|
end
|
309
299
|
|
310
300
|
context "when saving facts from the request" do
|
301
|
+
let(:facts) { Puppet::Node::Facts.new("hostname") }
|
302
|
+
|
311
303
|
it "should save facts if they were issued by the request" do
|
312
|
-
request = a_request_that_contains(
|
304
|
+
request = a_request_that_contains(facts)
|
313
305
|
|
314
306
|
options = {
|
315
307
|
:environment => request.environment,
|
316
308
|
:transaction_uuid => request.options[:transaction_uuid],
|
317
309
|
}
|
318
310
|
|
319
|
-
expect(Puppet::Node::Facts.indirection).to receive(:save).with(
|
311
|
+
expect(Puppet::Node::Facts.indirection).to receive(:save).with(facts, nil, options)
|
320
312
|
compiler.find(request)
|
321
313
|
end
|
322
314
|
|
@@ -328,7 +320,7 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
328
320
|
:transaction_uuid => request.options[:transaction_uuid],
|
329
321
|
}
|
330
322
|
|
331
|
-
expect(Puppet::Node::Facts.indirection).not_to receive(:save).with(
|
323
|
+
expect(Puppet::Node::Facts.indirection).not_to receive(:save).with(facts, nil, options)
|
332
324
|
compiler.find(request)
|
333
325
|
end
|
334
326
|
end
|
@@ -336,7 +328,6 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
336
328
|
|
337
329
|
describe "when finding nodes" do
|
338
330
|
it "should look node information up via the Node class with the provided key" do
|
339
|
-
allow(Facter).to receive(:value).and_return("whatever")
|
340
331
|
request = Puppet::Indirector::Request.new(:catalog, :find, node_name, nil)
|
341
332
|
allow(compiler).to receive(:compile)
|
342
333
|
|
@@ -414,9 +405,37 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
414
405
|
end
|
415
406
|
end
|
416
407
|
|
408
|
+
describe "after finding nodes when checking for a PE version" do
|
409
|
+
include PuppetSpec::Compiler
|
410
|
+
|
411
|
+
let(:pe_version_file) { '/opt/puppetlabs/server/pe_version' }
|
412
|
+
let(:request) { Puppet::Indirector::Request.new(:catalog, :find, node_name, nil) }
|
413
|
+
|
414
|
+
before :each do
|
415
|
+
Puppet[:code] = 'notify { "PE Version: $pe_serverversion": }'
|
416
|
+
end
|
417
|
+
|
418
|
+
it "should not add 'pe_serverversion' when FOSS" do
|
419
|
+
allow(Puppet::Node.indirection).to receive(:find).with(node_name, anything).and_return(node)
|
420
|
+
catalog = compiler.find(request)
|
421
|
+
|
422
|
+
expect(catalog.resource('notify', 'PE Version: 2019.2.0')).to be_nil
|
423
|
+
end
|
424
|
+
|
425
|
+
it "should add 'pe_serverversion' when PE" do
|
426
|
+
allow(File).to receive(:readable?).with(pe_version_file).and_return(true)
|
427
|
+
allow(File).to receive(:zero?).with(pe_version_file).and_return(false)
|
428
|
+
allow(File).to receive(:read).with(pe_version_file).and_return('2019.2.0')
|
429
|
+
|
430
|
+
allow(Puppet::Node.indirection).to receive(:find).with(node_name, anything).and_return(node)
|
431
|
+
catalog = compiler.find(request)
|
432
|
+
|
433
|
+
expect(catalog.resource('notify', 'PE Version: 2019.2.0')).to be
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
417
437
|
describe "when filtering resources" do
|
418
438
|
before :each do
|
419
|
-
allow(Facter).to receive(:value)
|
420
439
|
@catalog = double('catalog')
|
421
440
|
allow(@catalog).to receive(:respond_to?).with(:filter).and_return(true)
|
422
441
|
end
|
@@ -135,7 +135,7 @@ describe Puppet::Network::HTTP::Connection do
|
|
135
135
|
end
|
136
136
|
|
137
137
|
context "when response indicates an overloaded server" do
|
138
|
-
let(:http) { double('http') }
|
138
|
+
let(:http) { double('http', :started? => true) }
|
139
139
|
let(:site) { Puppet::Network::HTTP::Site.new('http', 'my_server', 8140) }
|
140
140
|
let(:verify) { Puppet::SSL::Validator.no_validator }
|
141
141
|
let(:httpunavailable) { Net::HTTPServiceUnavailable.new('1.1', 503, 'Service Unavailable') }
|
@@ -158,6 +158,7 @@ describe Puppet::Network::HTTP::Connection do
|
|
158
158
|
|
159
159
|
pool = Puppet.lookup(:http_pool)
|
160
160
|
expect(pool).to receive(:with_connection).with(site, anything).and_yield(http)
|
161
|
+
allow(http).to receive(:finish)
|
161
162
|
|
162
163
|
result = subject.get('/foo')
|
163
164
|
|
@@ -167,6 +168,7 @@ describe Puppet::Network::HTTP::Connection do
|
|
167
168
|
it "should return a 503 response if Retry-After is not convertible to an Integer or RFC 2822 Date" do
|
168
169
|
httpunavailable['Retry-After'] = 'foo'
|
169
170
|
allow(http).to receive(:request).and_return(httpunavailable)
|
171
|
+
allow(http).to receive(:finish)
|
170
172
|
|
171
173
|
pool = Puppet.lookup(:http_pool)
|
172
174
|
expect(pool).to receive(:with_connection).with(site, anything).and_yield(http)
|
@@ -176,9 +178,21 @@ describe Puppet::Network::HTTP::Connection do
|
|
176
178
|
expect(result.code).to eq(503)
|
177
179
|
end
|
178
180
|
|
181
|
+
it "should close the connection before sleeping" do
|
182
|
+
allow(http).to receive(:request).and_return(httpunavailable, httpok)
|
183
|
+
|
184
|
+
pool = Puppet.lookup(:http_pool)
|
185
|
+
expect(pool).to receive(:with_connection).with(site, anything).and_yield(http)
|
186
|
+
|
187
|
+
expect(http).to receive(:finish)
|
188
|
+
|
189
|
+
subject.get('/foo')
|
190
|
+
end
|
191
|
+
|
179
192
|
it "should sleep and retry if Retry-After is an Integer" do
|
180
193
|
httpunavailable['Retry-After'] = '42'
|
181
194
|
allow(http).to receive(:request).and_return(httpunavailable, httpok)
|
195
|
+
allow(http).to receive(:finish)
|
182
196
|
|
183
197
|
pool = Puppet.lookup(:http_pool)
|
184
198
|
expect(pool).to receive(:with_connection).with(site, anything).twice.and_yield(http)
|
@@ -193,6 +207,7 @@ describe Puppet::Network::HTTP::Connection do
|
|
193
207
|
it "should sleep and retry if Retry-After is an RFC 2822 Date" do
|
194
208
|
httpunavailable['Retry-After'] = 'Wed, 13 Apr 2005 15:18:05 GMT'
|
195
209
|
allow(http).to receive(:request).and_return(httpunavailable, httpok)
|
210
|
+
allow(http).to receive(:finish)
|
196
211
|
|
197
212
|
now = DateTime.new(2005, 4, 13, 8, 17, 5, '-07:00')
|
198
213
|
allow(DateTime).to receive(:now).and_return(now)
|
@@ -210,6 +225,7 @@ describe Puppet::Network::HTTP::Connection do
|
|
210
225
|
it "should sleep for no more than the Puppet runinterval" do
|
211
226
|
httpunavailable['Retry-After'] = '60'
|
212
227
|
allow(http).to receive(:request).and_return(httpunavailable, httpok)
|
228
|
+
allow(http).to receive(:finish)
|
213
229
|
Puppet[:runinterval] = 30
|
214
230
|
|
215
231
|
pool = Puppet.lookup(:http_pool)
|
@@ -60,6 +60,8 @@ describe Puppet::Network::HTTP::Pool do
|
|
60
60
|
|
61
61
|
it 'returns the connection to the pool' do
|
62
62
|
conn = create_connection(site)
|
63
|
+
expect(conn).to receive(:started?).and_return(true)
|
64
|
+
|
63
65
|
pool = create_pool
|
64
66
|
pool.release(site, conn)
|
65
67
|
|
@@ -137,6 +139,7 @@ describe Puppet::Network::HTTP::Pool do
|
|
137
139
|
it 'releases HTTP connections' do
|
138
140
|
conn = create_connection(site)
|
139
141
|
expect(conn).to receive(:use_ssl?).and_return(false)
|
142
|
+
expect(conn).to receive(:started?).and_return(true)
|
140
143
|
|
141
144
|
pool = create_pool_with_connections(site, conn)
|
142
145
|
expect(pool).to receive(:release).with(site, conn)
|
@@ -148,6 +151,7 @@ describe Puppet::Network::HTTP::Pool do
|
|
148
151
|
conn = create_connection(site)
|
149
152
|
expect(conn).to receive(:use_ssl?).and_return(true)
|
150
153
|
expect(conn).to receive(:verify_mode).and_return(OpenSSL::SSL::VERIFY_PEER)
|
154
|
+
expect(conn).to receive(:started?).and_return(true)
|
151
155
|
|
152
156
|
pool = create_pool_with_connections(site, conn)
|
153
157
|
expect(pool).to receive(:release).with(site, conn)
|
@@ -166,6 +170,19 @@ describe Puppet::Network::HTTP::Pool do
|
|
166
170
|
|
167
171
|
pool.with_connection(site, verify) {|c| }
|
168
172
|
end
|
173
|
+
|
174
|
+
it "doesn't add a closed connection back to the pool" do
|
175
|
+
http = Net::HTTP.new(site.addr)
|
176
|
+
http.use_ssl = true
|
177
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
178
|
+
http.start
|
179
|
+
|
180
|
+
pool = create_pool_with_connections(site, http)
|
181
|
+
|
182
|
+
pool.with_connection(site, verify) {|c| c.finish}
|
183
|
+
|
184
|
+
expect(pool.pool[site]).to be_empty
|
185
|
+
end
|
169
186
|
end
|
170
187
|
end
|
171
188
|
|
@@ -228,6 +245,7 @@ describe Puppet::Network::HTTP::Pool do
|
|
228
245
|
|
229
246
|
it 'finishes expired connections' do
|
230
247
|
conn = create_connection(site)
|
248
|
+
allow(conn).to receive(:started?).and_return(true)
|
231
249
|
expect(conn).to receive(:finish)
|
232
250
|
|
233
251
|
pool = create_pool_with_expired_connections(site, conn)
|
@@ -241,6 +259,7 @@ describe Puppet::Network::HTTP::Pool do
|
|
241
259
|
expect(Puppet).to receive(:log_exception).with(be_a(IOError), "Failed to close connection for #{site}: read timeout")
|
242
260
|
|
243
261
|
conn = create_connection(site)
|
262
|
+
expect(conn).to receive(:started?).and_return(true)
|
244
263
|
expect(conn).to receive(:finish).and_raise(IOError, 'read timeout')
|
245
264
|
|
246
265
|
pool = create_pool_with_expired_connections(site, conn)
|
@@ -289,10 +308,23 @@ describe Puppet::Network::HTTP::Pool do
|
|
289
308
|
|
290
309
|
it 'closes all cached connections' do
|
291
310
|
conn = create_connection(site)
|
311
|
+
allow(conn).to receive(:started?).and_return(true)
|
292
312
|
expect(conn).to receive(:finish)
|
293
313
|
|
294
314
|
pool = create_pool_with_connections(site, conn)
|
295
315
|
pool.close
|
296
316
|
end
|
317
|
+
|
318
|
+
it 'allows a connection to be closed multiple times safely' do
|
319
|
+
http = Net::HTTP.new(site.addr)
|
320
|
+
http.use_ssl = true
|
321
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
322
|
+
http.start
|
323
|
+
|
324
|
+
pool = create_pool
|
325
|
+
|
326
|
+
expect(pool.close_connection(site, http)).to eq(true)
|
327
|
+
expect(pool.close_connection(site, http)).to eq(false)
|
328
|
+
end
|
297
329
|
end
|
298
330
|
end
|
data/spec/unit/node_spec.rb
CHANGED
@@ -414,7 +414,9 @@ end
|
|
414
414
|
|
415
415
|
describe Puppet::Node, "when generating the list of names to search through" do
|
416
416
|
before do
|
417
|
-
|
417
|
+
Puppet[:strict_hostname_checking] = false
|
418
|
+
@node = Puppet::Node.new("foo.domain.com",
|
419
|
+
:parameters => {"hostname" => "yay", "domain" => "domain.com"})
|
418
420
|
end
|
419
421
|
|
420
422
|
it "returns an array of names" do
|
@@ -445,7 +447,6 @@ describe Puppet::Node, "when generating the list of names to search through" do
|
|
445
447
|
|
446
448
|
describe "and :node_name is set to 'cert'" do
|
447
449
|
before do
|
448
|
-
Puppet[:strict_hostname_checking] = false
|
449
450
|
Puppet[:node_name] = "cert"
|
450
451
|
end
|
451
452
|
|
@@ -454,8 +455,11 @@ describe Puppet::Node, "when generating the list of names to search through" do
|
|
454
455
|
end
|
455
456
|
|
456
457
|
describe "and strict hostname checking is enabled" do
|
457
|
-
|
458
|
+
before do
|
458
459
|
Puppet[:strict_hostname_checking] = true
|
460
|
+
end
|
461
|
+
|
462
|
+
it "only uses the passed-in key" do
|
459
463
|
expect(@node.names).to eq(["foo.domain.com"])
|
460
464
|
end
|
461
465
|
end
|
@@ -463,7 +467,6 @@ describe Puppet::Node, "when generating the list of names to search through" do
|
|
463
467
|
|
464
468
|
describe "and :node_name is set to 'facter'" do
|
465
469
|
before do
|
466
|
-
Puppet[:strict_hostname_checking] = false
|
467
470
|
Puppet[:node_name] = "facter"
|
468
471
|
end
|
469
472
|
|
@@ -47,7 +47,7 @@ describe Puppet::Type.type(:group).provider(:groupadd) do
|
|
47
47
|
described_class.has_feature(:libuser)
|
48
48
|
resource[:forcelocal] = :true
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "should use lgroupadd instead of groupadd" do
|
52
52
|
expect(provider).to receive(:execute).with(including('/usr/sbin/lgroupadd'), hash_including(:custom_environment => hash_including('LIBUSER_CONF')))
|
53
53
|
provider.create
|
@@ -124,6 +124,35 @@ describe Puppet::Type.type(:group).provider(:groupadd) do
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
+
describe "#findgroup" do
|
128
|
+
before { allow(File).to receive(:read).with('/etc/group').and_return(content) }
|
129
|
+
|
130
|
+
let(:content) { "sample_group_name:sample_password:sample_gid:sample_user_list" }
|
131
|
+
let(:output) do
|
132
|
+
{
|
133
|
+
group_name: 'sample_group_name',
|
134
|
+
password: 'sample_password',
|
135
|
+
gid: 'sample_gid',
|
136
|
+
user_list: 'sample_user_list',
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
[:group_name, :password, :gid, :user_list].each do |key|
|
141
|
+
it "finds a group by #{key} when asked" do
|
142
|
+
expect(provider.send(:findgroup, key, "sample_#{key}")).to eq(output)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
it "returns false when specified key/value pair is not found" do
|
147
|
+
expect(provider.send(:findgroup, :group_name, 'invalid_group_name')).to eq(false)
|
148
|
+
end
|
149
|
+
|
150
|
+
it "reads the group file only once per resource" do
|
151
|
+
expect(File).to receive(:read).with('/etc/group').once
|
152
|
+
5.times { provider.send(:findgroup, :group_name, 'sample_group_name') }
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
127
156
|
describe "#delete" do
|
128
157
|
before do
|
129
158
|
allow(provider).to receive(:exists?).and_return(true)
|
@@ -32,12 +32,14 @@ describe Puppet::Type.type(:package).provider(:apt) do
|
|
32
32
|
|
33
33
|
it "should use 'apt-get remove' to uninstall" do
|
34
34
|
expect(provider).to receive(:aptget).with("-y", "-q", :remove, name)
|
35
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
35
36
|
provider.uninstall
|
36
37
|
end
|
37
38
|
|
38
39
|
it "should use 'apt-get purge' and 'dpkg purge' to purge" do
|
39
40
|
expect(provider).to receive(:aptget).with("-y", "-q", :remove, "--purge", name)
|
40
41
|
expect(provider).to receive(:dpkg).with("--purge", name)
|
42
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
41
43
|
provider.purge
|
42
44
|
end
|
43
45
|
|
@@ -88,14 +90,14 @@ Version table:
|
|
88
90
|
it "should preseed if a responsefile is provided" do
|
89
91
|
resource[:responsefile] = "/my/file"
|
90
92
|
expect(provider).to receive(:run_preseed)
|
91
|
-
|
93
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
92
94
|
allow(provider).to receive(:aptget)
|
93
95
|
provider.install
|
94
96
|
end
|
95
97
|
|
96
98
|
it "should check for a cdrom" do
|
97
99
|
expect(provider).to receive(:checkforcdrom)
|
98
|
-
|
100
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
99
101
|
allow(provider).to receive(:aptget)
|
100
102
|
provider.install
|
101
103
|
end
|
@@ -106,6 +108,7 @@ Version table:
|
|
106
108
|
expect(command[-1]).to eq(name)
|
107
109
|
expect(command[-2]).to eq(:install)
|
108
110
|
end
|
111
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
109
112
|
|
110
113
|
provider.install
|
111
114
|
end
|
@@ -115,6 +118,7 @@ Version table:
|
|
115
118
|
expect(provider).to receive(:aptget) do |*command|
|
116
119
|
expect(command[-1]).to eq("#{name}=1.0")
|
117
120
|
end
|
121
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
118
122
|
|
119
123
|
provider.install
|
120
124
|
end
|
@@ -124,6 +128,7 @@ Version table:
|
|
124
128
|
expect(provider).to receive(:aptget) do |*command|
|
125
129
|
expect(command).to include("--force-yes")
|
126
130
|
end
|
131
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
127
132
|
|
128
133
|
provider.install
|
129
134
|
end
|
@@ -132,6 +137,7 @@ Version table:
|
|
132
137
|
expect(provider).to receive(:aptget) do |*command|
|
133
138
|
expect(command).to include("-q")
|
134
139
|
end
|
140
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
135
141
|
|
136
142
|
provider.install
|
137
143
|
end
|
@@ -140,6 +146,7 @@ Version table:
|
|
140
146
|
expect(provider).to receive(:aptget) do |*command|
|
141
147
|
expect(command).to include("-y")
|
142
148
|
end
|
149
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
143
150
|
|
144
151
|
provider.install
|
145
152
|
end
|
@@ -149,6 +156,7 @@ Version table:
|
|
149
156
|
expect(provider).to receive(:aptget) do |*command|
|
150
157
|
expect(command).to include("DPkg::Options::=--force-confold")
|
151
158
|
end
|
159
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
152
160
|
|
153
161
|
provider.install
|
154
162
|
end
|
@@ -158,6 +166,7 @@ Version table:
|
|
158
166
|
expect(provider).to receive(:aptget) do |*command|
|
159
167
|
expect(command).to include("DPkg::Options::=--force-confnew")
|
160
168
|
end
|
169
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
161
170
|
|
162
171
|
provider.install
|
163
172
|
end
|
@@ -165,6 +174,7 @@ Version table:
|
|
165
174
|
it 'should support string install options' do
|
166
175
|
resource[:install_options] = ['--foo', '--bar']
|
167
176
|
expect(provider).to receive(:aptget).with('-q', '-y', '-o', 'DPkg::Options::=--force-confold', '--foo', '--bar', :install, name)
|
177
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
168
178
|
|
169
179
|
provider.install
|
170
180
|
end
|
@@ -172,6 +182,7 @@ Version table:
|
|
172
182
|
it 'should support hash install options' do
|
173
183
|
resource[:install_options] = ['--foo', { '--bar' => 'baz', '--baz' => 'foo' }]
|
174
184
|
expect(provider).to receive(:aptget).with('-q', '-y', '-o', 'DPkg::Options::=--force-confold', '--foo', '--bar=baz', '--baz=foo', :install, name)
|
185
|
+
expect(provider).to receive(:properties).and_return({:mark => :none})
|
175
186
|
|
176
187
|
provider.install
|
177
188
|
end
|