puppet 6.14.0 → 6.15.0
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 +15 -15
- data/ext/windows/service/daemon.rb +3 -3
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +2 -10
- data/lib/puppet/application/agent.rb +2 -1
- data/lib/puppet/application/filebucket.rb +5 -14
- data/lib/puppet/application/ssl.rb +2 -2
- data/lib/puppet/configurer.rb +7 -3
- data/lib/puppet/configurer/plugin_handler.rb +1 -1
- data/lib/puppet/defaults.rb +22 -2
- data/lib/puppet/environments.rb +4 -5
- data/lib/puppet/face/plugin.rb +1 -1
- data/lib/puppet/file_system/file_impl.rb +13 -9
- data/lib/puppet/forge/repository.rb +1 -1
- data/lib/puppet/functions/call.rb +1 -1
- data/lib/puppet/functions/reduce.rb +2 -4
- data/lib/puppet/http.rb +2 -0
- data/lib/puppet/http/client.rb +191 -52
- data/lib/puppet/http/external_client.rb +96 -0
- data/lib/puppet/http/redirector.rb +34 -0
- data/lib/puppet/http/resolver.rb +46 -3
- data/lib/puppet/http/resolver/server_list.rb +75 -15
- data/lib/puppet/http/resolver/settings.rb +22 -2
- data/lib/puppet/http/resolver/srv.rb +28 -2
- data/lib/puppet/http/response.rb +63 -1
- data/lib/puppet/http/retry_after_handler.rb +39 -0
- data/lib/puppet/http/service.rb +67 -1
- data/lib/puppet/http/service/ca.rb +71 -9
- data/lib/puppet/http/service/compiler.rb +213 -11
- data/lib/puppet/http/service/file_server.rb +105 -4
- data/lib/puppet/http/service/report.rb +36 -3
- data/lib/puppet/http/session.rb +59 -8
- data/lib/puppet/indirector/catalog/rest.rb +2 -1
- data/lib/puppet/indirector/facts/rest.rb +2 -1
- data/lib/puppet/indirector/file_bucket_file/rest.rb +48 -0
- data/lib/puppet/indirector/file_metadata/rest.rb +4 -2
- data/lib/puppet/indirector/node/rest.rb +2 -1
- data/lib/puppet/indirector/report/yaml.rb +23 -0
- data/lib/puppet/indirector/status/rest.rb +2 -1
- data/lib/puppet/metatype/manager.rb +80 -80
- data/lib/puppet/network/http/base_pool.rb +6 -1
- data/lib/puppet/network/http/pool.rb +2 -4
- data/lib/puppet/network/http_pool.rb +1 -0
- data/lib/puppet/node/environment.rb +11 -1
- data/lib/puppet/pal/pal_impl.rb +1 -29
- data/lib/puppet/parser/compiler.rb +14 -7
- data/lib/puppet/parser/functions.rb +18 -13
- data/lib/puppet/pops/loaders.rb +7 -5
- data/lib/puppet/provider/group/windows_adsi.rb +3 -3
- data/lib/puppet/provider/package/apt.rb +61 -1
- data/lib/puppet/provider/package/dnfmodule.rb +39 -12
- data/lib/puppet/provider/package/gem.rb +41 -7
- data/lib/puppet/provider/package/pacman.rb +2 -5
- data/lib/puppet/provider/package/pip.rb +105 -33
- data/lib/puppet/provider/package/pip3.rb +0 -2
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgng.rb +16 -4
- data/lib/puppet/provider/package/puppet_gem.rb +6 -2
- data/lib/puppet/provider/package/rpm.rb +6 -213
- data/lib/puppet/provider/package/yum.rb +92 -19
- data/lib/puppet/provider/service/systemd.rb +2 -1
- data/lib/puppet/reports/http.rb +13 -11
- data/lib/puppet/resource/type_collection.rb +20 -16
- data/lib/puppet/ssl.rb +1 -0
- data/lib/puppet/ssl/host.rb +4 -4
- data/lib/puppet/ssl/oids.rb +1 -0
- data/lib/puppet/ssl/state_machine.rb +50 -33
- data/lib/puppet/transaction/report.rb +2 -2
- data/lib/puppet/type.rb +6 -1
- data/lib/puppet/type/file/source.rb +4 -2
- data/lib/puppet/type/package.rb +25 -2
- data/lib/puppet/type/user.rb +0 -19
- data/lib/puppet/util/at_fork.rb +1 -1
- data/lib/puppet/util/autoload.rb +3 -0
- data/lib/puppet/util/instance_loader.rb +14 -10
- data/lib/puppet/util/package/version/debian.rb +175 -0
- data/lib/puppet/util/package/version/gem.rb +15 -0
- data/lib/puppet/util/package/version/pip.rb +167 -0
- data/lib/puppet/util/package/version/range.rb +50 -0
- data/lib/puppet/util/package/version/range/gt.rb +14 -0
- data/lib/puppet/util/package/version/range/gt_eq.rb +14 -0
- data/lib/puppet/util/package/version/range/lt.rb +14 -0
- data/lib/puppet/util/package/version/range/lt_eq.rb +14 -0
- data/lib/puppet/util/package/version/range/min_max.rb +21 -0
- data/lib/puppet/util/package/version/range/simple.rb +11 -0
- data/lib/puppet/util/package/version/rpm.rb +73 -0
- data/lib/puppet/util/pidlock.rb +13 -7
- data/lib/puppet/util/platform.rb +5 -0
- data/lib/puppet/util/rpm_compare.rb +193 -0
- data/lib/puppet/util/windows/adsi.rb +2 -2
- data/lib/puppet/util/windows/process.rb +15 -14
- data/lib/puppet/util/windows/security.rb +1 -0
- data/lib/puppet/util/windows/sid.rb +3 -3
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +207 -201
- data/man/man5/puppet.conf.5 +11 -3
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.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 +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-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-ssl.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/ssl/unknown-127.0.0.1-key.pem +67 -0
- data/spec/fixtures/ssl/unknown-127.0.0.1.pem +48 -0
- data/spec/fixtures/ssl/unknown-ca-key.pem +67 -0
- data/spec/fixtures/ssl/unknown-ca.pem +59 -0
- data/spec/fixtures/unit/provider/package/dnfmodule/{dnf-module-list-installed.txt → dnf-module-list-enabled.txt} +2 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.version +2 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-subscription-manager.txt +9 -0
- data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +9 -0
- data/spec/integration/application/agent_spec.rb +329 -0
- data/spec/integration/application/apply_spec.rb +132 -3
- data/spec/integration/application/filebucket_spec.rb +190 -0
- data/spec/integration/application/plugin_spec.rb +50 -0
- data/spec/integration/http/client_spec.rb +34 -40
- data/spec/integration/indirector/report/yaml.rb +83 -0
- data/spec/integration/module_tool/forge_spec.rb +2 -15
- data/spec/integration/network/http_pool_spec.rb +11 -19
- data/spec/integration/node/environment_spec.rb +15 -0
- data/spec/integration/util/windows/adsi_spec.rb +1 -1
- data/spec/lib/puppet/test_ca.rb +2 -2
- data/spec/lib/puppet_spec/https.rb +10 -7
- data/spec/lib/puppet_spec/puppetserver.rb +119 -0
- data/spec/shared_contexts/https.rb +29 -0
- data/spec/unit/agent_spec.rb +33 -25
- data/spec/unit/application/agent_spec.rb +5 -1
- data/spec/unit/application/device_spec.rb +2 -2
- data/spec/unit/application/filebucket_spec.rb +22 -2
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/defaults_spec.rb +24 -1
- data/spec/unit/environments_spec.rb +8 -0
- data/spec/unit/file_system_spec.rb +10 -0
- data/spec/unit/http/client_spec.rb +105 -46
- data/spec/unit/http/external_client_spec.rb +201 -0
- data/spec/unit/http/resolver_spec.rb +20 -0
- data/spec/unit/http/service/ca_spec.rb +25 -2
- data/spec/unit/http/service/compiler_spec.rb +184 -6
- data/spec/unit/http/service/file_server_spec.rb +35 -3
- data/spec/unit/http/service/report_spec.rb +3 -1
- data/spec/unit/http/service_spec.rb +3 -3
- data/spec/unit/http/session_spec.rb +56 -7
- data/spec/unit/indirector/file_bucket_file/rest_spec.rb +82 -2
- data/spec/unit/network/http/pool_spec.rb +3 -3
- data/spec/unit/node/environment_spec.rb +16 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +43 -10
- data/spec/unit/provider/package/apt_spec.rb +30 -0
- data/spec/unit/provider/package/dnfmodule_spec.rb +33 -14
- data/spec/unit/provider/package/gem_spec.rb +40 -0
- data/spec/unit/provider/package/pacman_spec.rb +6 -21
- data/spec/unit/provider/package/pip_spec.rb +26 -3
- data/spec/unit/provider/package/pkgdmg_spec.rb +1 -1
- data/spec/unit/provider/package/pkgng_spec.rb +38 -0
- data/spec/unit/provider/package/puppet_gem_spec.rb +8 -0
- data/spec/unit/provider/package/rpm_spec.rb +0 -212
- data/spec/unit/provider/package/yum_spec.rb +235 -1
- data/spec/unit/provider/service/systemd_spec.rb +10 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +3 -3
- data/spec/unit/puppet_pal_2pec.rb +0 -29
- data/spec/unit/reports/http_spec.rb +70 -52
- data/spec/unit/ssl/host_spec.rb +4 -2
- data/spec/unit/ssl/oids_spec.rb +1 -0
- data/spec/unit/ssl/state_machine_spec.rb +38 -6
- data/spec/unit/transaction/report_spec.rb +4 -0
- data/spec/unit/util/at_fork_spec.rb +2 -2
- data/spec/unit/util/package/version/debian_spec.rb +83 -0
- data/spec/unit/util/package/version/pip_spec.rb +464 -0
- data/spec/unit/util/package/version/range_spec.rb +154 -0
- data/spec/unit/util/package/version/rpm_spec.rb +121 -0
- data/spec/unit/util/pidlock_spec.rb +83 -47
- data/spec/unit/util/rpm_compare_spec.rb +196 -0
- data/spec/unit/util/windows/adsi_spec.rb +4 -4
- data/spec/unit/util/windows/sid_spec.rb +2 -2
- data/tasks/generate_cert_fixtures.rake +15 -1
- metadata +51 -6
- data/spec/integration/faces/plugin_spec.rb +0 -63
@@ -3,6 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe Puppet::Type.type(:package).provider(:yum) do
|
4
4
|
include PuppetSpec::Fixtures
|
5
5
|
|
6
|
+
let(:resource_name) { 'myresource' }
|
7
|
+
let(:resource) do
|
8
|
+
Puppet::Type.type(:package).new(
|
9
|
+
:name => resource_name,
|
10
|
+
:ensure => :installed,
|
11
|
+
:provider => 'yum'
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:provider) { Puppet::Type.type(:package).provider(:yum).new(resource) }
|
16
|
+
|
6
17
|
it_behaves_like 'RHEL package provider', described_class, 'yum'
|
7
18
|
|
8
19
|
it "should have lower specificity" do
|
@@ -96,7 +107,7 @@ describe Puppet::Type.type(:package).provider(:yum) do
|
|
96
107
|
end
|
97
108
|
end
|
98
109
|
|
99
|
-
describe 'with install_options' do
|
110
|
+
describe 'with install_options' do
|
100
111
|
it 'can parse disable-repo with array of strings' do
|
101
112
|
resource[:install_options] = ['--disable-repo=dev*', '--disable-repo=prod*']
|
102
113
|
expect(provider).to receive(:execute) do | arr|
|
@@ -235,5 +246,228 @@ describe Puppet::Type.type(:package).provider(:yum) do
|
|
235
246
|
expect(output).not_to include("Random plugin")
|
236
247
|
end
|
237
248
|
end
|
249
|
+
|
250
|
+
context "with subscription manager enabled " do
|
251
|
+
let(:check_update) { File.read(my_fixture("yum-check-update-subscription-manager.txt")) }
|
252
|
+
let(:output) { described_class.parse_updates(check_update) }
|
253
|
+
|
254
|
+
it "parses correctly formatted entries" do
|
255
|
+
expect(output['curl.x86_64']).to eq([{:name => 'curl', :epoch => '0', :version => '7.32.0', :release => '10.fc20', :arch => 'x86_64'}])
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
describe 'insync?' do
|
261
|
+
context 'when version is not a valid RPM version' do
|
262
|
+
let(:is) { 'a:123' }
|
263
|
+
|
264
|
+
before do
|
265
|
+
resource[:ensure] = is
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'logs a debug message' do
|
269
|
+
expect(Puppet).to receive(:debug).with("Cannot parse #{is} as a RPM version range")
|
270
|
+
provider.insync?(is)
|
271
|
+
end
|
272
|
+
|
273
|
+
context 'when requested version equals installed version' do
|
274
|
+
it { expect(provider).to be_insync(is) }
|
275
|
+
end
|
276
|
+
|
277
|
+
context 'when requested version is different than installed versions' do
|
278
|
+
it { expect(provider).not_to be_insync('999') }
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
context 'with valid semantic versions' do
|
283
|
+
let(:is) { '1:1.2.3.4-5.el4' }
|
284
|
+
|
285
|
+
it 'returns true if current version matches the greater or equal semantic version in ensure' do
|
286
|
+
resource[:ensure] = '<=1:1.2.3.4-5.el4'
|
287
|
+
expect(provider).to be_insync(is)
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'returns true if current version matches the lesser semantic version in ensure' do
|
291
|
+
resource[:ensure] = '>1:1.0.0'
|
292
|
+
expect(provider).to be_insync(is)
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'returns true if current version matches two semantic conditions' do
|
296
|
+
resource[:ensure] = '>1:1.1.3.4-5.el4 <1:1.3.3.6-5.el4'
|
297
|
+
expect(provider).to be_insync(is)
|
298
|
+
end
|
299
|
+
|
300
|
+
it 'returns false if current version does not match matches two semantic conditions' do
|
301
|
+
resource[:ensure] = '<1:1.1.3.4-5.el4 <1:1.3.3.6-5.el4'
|
302
|
+
expect(provider).not_to be_insync(is)
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe 'install' do
|
308
|
+
before do
|
309
|
+
resource[:ensure] = ensure_value
|
310
|
+
allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return('7')
|
311
|
+
allow(described_class).to receive(:command).with(:cmd).and_return('/usr/bin/yum')
|
312
|
+
allow(provider).to receive(:query).twice.and_return(nil, ensure: '18.3.2')
|
313
|
+
allow(provider).to receive(:insync?).with('18.3.2').and_return(true)
|
314
|
+
end
|
315
|
+
|
316
|
+
context 'with version range' do
|
317
|
+
before do
|
318
|
+
allow(provider).to receive(:available_versions).and_return(available_versions)
|
319
|
+
end
|
320
|
+
|
321
|
+
context 'without epoch' do
|
322
|
+
let(:ensure_value) { '>18.1 <19' }
|
323
|
+
let(:available_versions) { ['17.5.2', '18.0', 'a:23', '18.3', '18.3.2', '19.0', '3:18.4'] }
|
324
|
+
|
325
|
+
it 'selects best_version' do
|
326
|
+
expect(provider).to receive(:execute).with(
|
327
|
+
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, 'myresource-18.3.2']
|
328
|
+
)
|
329
|
+
provider.install
|
330
|
+
end
|
331
|
+
|
332
|
+
context 'when comparing with available packages that do not have epoch' do
|
333
|
+
let(:ensure_value) { '>18' }
|
334
|
+
let(:available_versions) { ['18.3.3', '3:18.3.2'] }
|
335
|
+
|
336
|
+
it 'treats no epoch as zero' do
|
337
|
+
expect(provider).to receive(:execute).with(
|
338
|
+
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, 'myresource-18.3.2']
|
339
|
+
)
|
340
|
+
provider.install
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
context 'with epoch' do
|
346
|
+
let(:ensure_value) { '>18.1 <3:19' }
|
347
|
+
let(:available_versions) { ['3:17.5.2', '3:18.0', 'a:23', '18.3.3', '3:18.3.2', '3:19.0', '19.1'] }
|
348
|
+
|
349
|
+
it 'selects best_version and removes epoch' do
|
350
|
+
expect(provider).to receive(:execute).with(
|
351
|
+
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, 'myresource-18.3.2']
|
352
|
+
)
|
353
|
+
provider.install
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
context 'when no suitable version in range' do
|
358
|
+
let(:ensure_value) { '>18.1 <19' }
|
359
|
+
let(:available_versions) { ['3:17.5.2', '3:18.0', 'a:23' '18.3', '3:18.3.2', '3:19.0', '19.1'] }
|
360
|
+
|
361
|
+
it 'uses requested version' do
|
362
|
+
expect(provider).to receive(:execute).with(
|
363
|
+
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource->18.1 <19"]
|
364
|
+
)
|
365
|
+
provider.install
|
366
|
+
end
|
367
|
+
|
368
|
+
it 'logs a debug message' do
|
369
|
+
allow(provider).to receive(:execute).with(
|
370
|
+
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource->18.1 <19"]
|
371
|
+
)
|
372
|
+
|
373
|
+
expect(Puppet).to receive(:debug).with(
|
374
|
+
"No available version for package myresource is included in range >18.1 <19"
|
375
|
+
)
|
376
|
+
provider.install
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
context 'with fix version' do
|
382
|
+
let(:ensure_value) { '1:18.12' }
|
383
|
+
|
384
|
+
it 'passes the version to yum command' do
|
385
|
+
expect(provider).to receive(:execute).with(
|
386
|
+
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource-1:18.12"]
|
387
|
+
)
|
388
|
+
provider.install
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
context 'when upgrading' do
|
393
|
+
let(:ensure_value) { '>18.1 <19' }
|
394
|
+
let(:available_versions) { ['17.5.2', '18.0', 'a:23' '18.3', '18.3.2', '19.0', '3:18.4'] }
|
395
|
+
|
396
|
+
before do
|
397
|
+
allow(provider).to receive(:available_versions).and_return(available_versions)
|
398
|
+
allow(provider).to receive(:query).twice
|
399
|
+
.and_return({ ensure: '17.0' }, { ensure: '18.3.2' })
|
400
|
+
end
|
401
|
+
|
402
|
+
it 'adds update flag to install command' do
|
403
|
+
expect(provider).to receive(:execute).with(
|
404
|
+
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', 'update', 'myresource-18.3.2']
|
405
|
+
)
|
406
|
+
provider.install
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
context 'when dowgrading' do
|
411
|
+
let(:ensure_value) { '>18.1 <19' }
|
412
|
+
let(:available_versions) { ['17.5.2', '18.0', 'a:23' '18.3', '18.3.2', '19.0', '3:18.4'] }
|
413
|
+
|
414
|
+
before do
|
415
|
+
allow(provider).to receive(:available_versions).and_return(available_versions)
|
416
|
+
allow(provider).to receive(:query).twice
|
417
|
+
.and_return({ ensure: '19.0' }, { ensure: '18.3.2' })
|
418
|
+
end
|
419
|
+
|
420
|
+
it 'adds downgrade flag to install command' do
|
421
|
+
expect(provider).to receive(:execute).with(
|
422
|
+
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :downgrade, 'myresource-18.3.2']
|
423
|
+
)
|
424
|
+
provider.install
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
context 'on failure' do
|
429
|
+
let(:ensure_value) { '20' }
|
430
|
+
|
431
|
+
context 'when execute command fails' do
|
432
|
+
before do
|
433
|
+
allow(provider).to receive(:execute).with(
|
434
|
+
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource-20"]
|
435
|
+
).and_return('No package myresource-20 available.')
|
436
|
+
end
|
437
|
+
|
438
|
+
it 'raises Puppet::Error' do
|
439
|
+
expect { provider.install }.to \
|
440
|
+
raise_error(Puppet::Error, 'Could not find package myresource-20')
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
context 'when package is not found' do
|
445
|
+
before do
|
446
|
+
allow(provider).to receive(:query)
|
447
|
+
allow(provider).to receive(:execute).with(
|
448
|
+
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource-20"]
|
449
|
+
)
|
450
|
+
end
|
451
|
+
|
452
|
+
it 'raises Puppet::Error' do
|
453
|
+
expect { provider.install }.to \
|
454
|
+
raise_error(Puppet::Error, 'Could not find package myresource')
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
458
|
+
context 'when package is not installed' do
|
459
|
+
before do
|
460
|
+
allow(provider).to receive(:execute).with(
|
461
|
+
['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "myresource-20"]
|
462
|
+
)
|
463
|
+
allow(provider).to receive(:insync?).and_return(false)
|
464
|
+
end
|
465
|
+
|
466
|
+
it 'raises Puppet::Error' do
|
467
|
+
expect { provider.install }.to \
|
468
|
+
raise_error(Puppet::Error, 'Failed to update to version 20, got version 18.3.2 instead')
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|
238
472
|
end
|
239
473
|
end
|
@@ -187,9 +187,18 @@ describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platf
|
|
187
187
|
autovt@.service
|
188
188
|
avahi-daemon.service
|
189
189
|
blk-availability.service
|
190
|
+
apparmor.service
|
191
|
+
umountnfs.service
|
192
|
+
urandom.service
|
190
193
|
})
|
191
194
|
end
|
192
|
-
|
195
|
+
|
196
|
+
it "should print a debug message when a service with the state `bad` is found" do
|
197
|
+
expect(provider_class).to receive(:systemctl).with('list-unit-files', '--type', 'service', '--full', '--all', '--no-pager').and_return(File.read(my_fixture('list_unit_files_services')))
|
198
|
+
expect(Puppet).to receive(:debug).with("apparmor.service marked as bad by `systemctl`. It is recommended to be further checked.")
|
199
|
+
provider_class.instances
|
200
|
+
end
|
201
|
+
end
|
193
202
|
|
194
203
|
describe "#start" do
|
195
204
|
it "should use the supplied start command if specified" do
|
@@ -78,9 +78,9 @@ describe Puppet::Type.type(:user).provider(:windows_adsi), :if => Puppet::Util::
|
|
78
78
|
let(:group3) { double(:account => 'group3', :domain => '.', :sid => 'group3sid') }
|
79
79
|
|
80
80
|
before :each do
|
81
|
-
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('group1').and_return(group1)
|
82
|
-
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('group2').and_return(group2)
|
83
|
-
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('group3').and_return(group3)
|
81
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('group1', any_args).and_return(group1)
|
82
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('group2', any_args).and_return(group2)
|
83
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('group3', any_args).and_return(group3)
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should return true for same lists of members" do
|
@@ -708,35 +708,6 @@ describe 'Puppet Pal' do
|
|
708
708
|
end
|
709
709
|
end
|
710
710
|
|
711
|
-
context 'facts are supported such that' do
|
712
|
-
it 'they are obtained if they are not given' do
|
713
|
-
facts = Puppet::Node::Facts.new(Puppet[:certname], 'puppetversion' => Puppet.version)
|
714
|
-
Puppet::Node::Facts.indirection.save(facts)
|
715
|
-
|
716
|
-
testing_env_dir # creates the structure
|
717
|
-
result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath ) do |ctx|
|
718
|
-
ctx.with_script_compiler {|c| c.evaluate_string("$facts =~ Hash and $facts[puppetversion] == '#{Puppet.version}'") }
|
719
|
-
end
|
720
|
-
expect(result).to eq(true)
|
721
|
-
end
|
722
|
-
|
723
|
-
it 'can be given as a hash when creating the environment' do
|
724
|
-
testing_env_dir # creates the structure
|
725
|
-
result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: { 'myfact' => 42 }) do |ctx|
|
726
|
-
ctx.with_script_compiler {|c| c.evaluate_string("$facts =~ Hash and $facts[myfact] == 42") }
|
727
|
-
end
|
728
|
-
expect(result).to eq(true)
|
729
|
-
end
|
730
|
-
|
731
|
-
it 'can be overridden with a hash when creating a script compiler' do
|
732
|
-
testing_env_dir # creates the structure
|
733
|
-
result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: { 'myfact' => 42 }) do |ctx|
|
734
|
-
ctx.with_script_compiler(facts: { 'myfact' => 43 }) {|c| c.evaluate_string("$facts =~ Hash and $facts[myfact] == 43") }
|
735
|
-
end
|
736
|
-
expect(result).to eq(true)
|
737
|
-
end
|
738
|
-
end
|
739
|
-
|
740
711
|
context 'supports tasks such that' do
|
741
712
|
it '"task_signature" returns the signatures of a generic task' do
|
742
713
|
result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: node_facts) do |ctx|
|
@@ -1,101 +1,119 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'puppet/reports'
|
3
3
|
|
4
|
-
|
4
|
+
describe Puppet::Reports.report(:http) do
|
5
|
+
subject { Puppet::Transaction::Report.new.extend(described_class) }
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
let(:url) { "https://puppet.example.com/report/upload" }
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
Puppet[:reporturl] = url
|
11
|
+
end
|
8
12
|
|
9
13
|
describe "when setting up the connection" do
|
10
|
-
|
11
|
-
|
14
|
+
it "raises if the connection fails" do
|
15
|
+
stub_request(:post, url).to_raise(Errno::ECONNREFUSED.new('Connection refused - connect(2)'))
|
12
16
|
|
13
|
-
|
14
|
-
|
17
|
+
expect {
|
18
|
+
subject.process
|
19
|
+
}.to raise_error(Puppet::HTTP::HTTPError, /Request to #{url} failed after .* seconds: .*Connection refused/)
|
15
20
|
end
|
16
21
|
|
17
22
|
it "configures the connection for ssl when using https" do
|
18
|
-
|
23
|
+
stub_request(:post, url)
|
19
24
|
|
20
|
-
|
21
|
-
|
22
|
-
|
25
|
+
expect_any_instance_of(Net::HTTP).to receive(:start) do |http|
|
26
|
+
expect(http).to be_use_ssl
|
27
|
+
expect(http.verify_mode).to eq(OpenSSL::SSL::VERIFY_PEER)
|
28
|
+
end
|
23
29
|
|
24
30
|
subject.process
|
25
31
|
end
|
26
32
|
|
27
33
|
it "does not configure the connection for ssl when using http" do
|
28
|
-
Puppet[:reporturl] = 'http://
|
34
|
+
Puppet[:reporturl] = 'http://puppet.example.com:8080/the/path'
|
35
|
+
stub_request(:post, Puppet[:reporturl])
|
29
36
|
|
30
|
-
|
31
|
-
|
32
|
-
|
37
|
+
expect_any_instance_of(Net::HTTP).to receive(:start) do |http|
|
38
|
+
expect(http).to_not be_use_ssl
|
39
|
+
end
|
33
40
|
|
34
41
|
subject.process
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|
38
45
|
describe "when making a request" do
|
39
|
-
|
40
|
-
|
41
|
-
|
46
|
+
it "uses the path specified by the 'reporturl' setting" do
|
47
|
+
req = stub_request(:post, url)
|
48
|
+
|
49
|
+
subject.process
|
42
50
|
|
43
|
-
|
44
|
-
expect(Puppet::Network::HttpPool).to receive(:connection).and_return(connection)
|
51
|
+
expect(req).to have_been_requested
|
45
52
|
end
|
46
53
|
|
47
|
-
it "
|
48
|
-
|
49
|
-
|
54
|
+
it "uses the username and password specified by the 'reporturl' setting" do
|
55
|
+
Puppet[:reporturl] = "https://user:pass@puppet.example.com/report/upload"
|
56
|
+
|
57
|
+
req = stub_request(:post, %r{/report/upload}).with(basic_auth: ['user', 'pass'])
|
50
58
|
|
51
59
|
subject.process
|
60
|
+
|
61
|
+
expect(req).to have_been_requested
|
52
62
|
end
|
53
63
|
|
54
|
-
it "
|
55
|
-
|
64
|
+
it "passes metric_id options" do
|
65
|
+
stub_request(:post, url)
|
56
66
|
|
57
|
-
expect(
|
58
|
-
{:metric_id => [:puppet, :report, :http],
|
59
|
-
:basic_auth => {
|
60
|
-
:user => 'user',
|
61
|
-
:password => 'pass'
|
62
|
-
}}).and_return(httpok)
|
67
|
+
expect(Puppet.runtime['http']).to receive(:post).with(anything, anything, hash_including(options: hash_including(metric_id: [:puppet, :report, :http]))).and_call_original
|
63
68
|
|
64
69
|
subject.process
|
65
70
|
end
|
66
71
|
|
67
|
-
it "
|
68
|
-
|
72
|
+
it "passes the report as YAML" do
|
73
|
+
req = stub_request(:post, url).with(body: subject.to_yaml)
|
69
74
|
|
70
75
|
subject.process
|
76
|
+
|
77
|
+
expect(req).to have_been_requested
|
71
78
|
end
|
72
79
|
|
73
|
-
it "
|
74
|
-
|
80
|
+
it "sets content-type to 'application/x-yaml'" do
|
81
|
+
req = stub_request(:post, url).with(headers: {'Content-Type' => 'application/x-yaml'})
|
75
82
|
|
76
83
|
subject.process
|
84
|
+
|
85
|
+
expect(req).to have_been_requested
|
77
86
|
end
|
78
87
|
|
79
|
-
|
80
|
-
|
81
|
-
it "should succeed on http code #{code}" do
|
82
|
-
response = klass.new('1.1', code, '')
|
83
|
-
expect(connection).to receive(:post).and_return(response)
|
88
|
+
it "doesn't log anything if the request succeeds" do
|
89
|
+
req = stub_request(:post, url).to_return(status: [200, "OK"])
|
84
90
|
|
85
|
-
|
86
|
-
subject.process
|
87
|
-
end
|
88
|
-
end
|
91
|
+
subject.process
|
89
92
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
expect(connection).to receive(:post).and_return(response)
|
93
|
+
expect(req).to have_been_requested
|
94
|
+
expect(@logs).to eq([])
|
95
|
+
end
|
94
96
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
97
|
+
it "follows redirects" do
|
98
|
+
location = {headers: {'Location' => url}}
|
99
|
+
|
100
|
+
req = stub_request(:post, url)
|
101
|
+
.to_return(**location, status: [301, "Moved Permanently"]).then
|
102
|
+
.to_return(**location, status: [302, "Found"]).then
|
103
|
+
.to_return(**location, status: [307, "Temporary Redirect"]).then
|
104
|
+
.to_return(status: [200, "OK"])
|
105
|
+
|
106
|
+
subject.process
|
107
|
+
|
108
|
+
expect(req).to have_been_requested.times(4)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "logs an error if the request fails" do
|
112
|
+
stub_request(:post, url).to_return(status: [500, "Internal Server Error"])
|
113
|
+
|
114
|
+
subject.process
|
115
|
+
|
116
|
+
expect(@logs).to include(having_attributes(level: :err, message: "Unable to submit report to #{url} [500] Internal Server Error"))
|
99
117
|
end
|
100
118
|
end
|
101
119
|
end
|