puppet 6.0.9-x86-mingw32 → 6.0.10-x86-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 +16 -16
- data/lib/hiera/scope.rb +7 -0
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/device.rb +13 -3
- data/lib/puppet/application/ssl.rb +2 -0
- data/lib/puppet/configurer.rb +1 -1
- data/lib/puppet/network/http/connection.rb +2 -0
- data/lib/puppet/network/http/factory.rb +5 -0
- data/lib/puppet/pops/types/types.rb +5 -3
- data/lib/puppet/provider.rb +1 -2
- data/lib/puppet/provider/package.rb +2 -0
- data/lib/puppet/provider/package/dpkg.rb +15 -2
- data/lib/puppet/provider/package/gem.rb +65 -29
- data/lib/puppet/provider/package/pip.rb +135 -111
- data/lib/puppet/provider/package/pip3.rb +1 -1
- data/lib/puppet/provider/package/puppet_gem.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +27 -16
- data/lib/puppet/provider/package/yum.rb +2 -1
- data/lib/puppet/provider/package_targetable.rb +68 -0
- data/lib/puppet/provider/service/upstart.rb +5 -3
- data/lib/puppet/provider/user/useradd.rb +16 -13
- data/lib/puppet/settings/server_list_setting.rb +9 -0
- data/lib/puppet/ssl/host.rb +0 -11
- data/lib/puppet/ssl/validator/default_validator.rb +31 -0
- data/lib/puppet/type/package.rb +46 -9
- data/lib/puppet/util/pidlock.rb +3 -2
- data/lib/puppet/util/windows/process.rb +8 -8
- data/lib/puppet/util/windows/registry.rb +7 -1
- data/lib/puppet/util/windows/user.rb +14 -4
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +83 -79
- 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-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/integration/network/http_pool_spec.rb +120 -0
- data/spec/integration/type/package_spec.rb +1 -1
- data/spec/integration/util/windows/registry_spec.rb +52 -0
- data/spec/integration/util/windows/user_spec.rb +19 -0
- data/spec/lib/puppet_spec/https.rb +166 -0
- data/spec/unit/application/ssl_spec.rb +5 -0
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/functions/new_spec.rb +15 -0
- data/spec/unit/hiera/scope_spec.rb +7 -0
- data/spec/unit/indirector/resource/ral_spec.rb +1 -0
- data/spec/unit/network/http/connection_spec.rb +0 -96
- data/spec/unit/network/http/factory_spec.rb +6 -0
- data/spec/unit/provider/package/dpkg_spec.rb +18 -1
- data/spec/unit/provider/package/gem_spec.rb +101 -48
- data/spec/unit/provider/package/pip3_spec.rb +17 -0
- data/spec/unit/provider/package/pip_spec.rb +57 -67
- data/spec/unit/provider/package/puppet_gem_spec.rb +22 -6
- data/spec/unit/provider/package/rpm_spec.rb +116 -27
- data/spec/unit/provider/service/upstart_spec.rb +3 -22
- data/spec/unit/settings/server_list_setting_spec.rb +21 -0
- data/spec/unit/ssl/validator_spec.rb +2 -0
- data/spec/unit/util/pidlock_spec.rb +26 -0
- metadata +9 -5
- data/lib/puppet/rest/client.rb +0 -83
- data/spec/unit/rest/client_spec.rb +0 -166
@@ -7,6 +7,7 @@ describe Puppet::Type.type(:package).provider(:pip3) do
|
|
7
7
|
it { is_expected.to be_upgradeable }
|
8
8
|
it { is_expected.to be_versionable }
|
9
9
|
it { is_expected.to be_install_options }
|
10
|
+
it { is_expected.to be_targetable }
|
10
11
|
|
11
12
|
it "should inherit most things from pip provider" do
|
12
13
|
expect(described_class < Puppet::Type.type(:package).provider(:pip))
|
@@ -16,4 +17,20 @@ describe Puppet::Type.type(:package).provider(:pip3) do
|
|
16
17
|
expect(described_class.cmd).to eq(["pip3"])
|
17
18
|
end
|
18
19
|
|
20
|
+
context 'calculated specificity' do
|
21
|
+
context 'when is not defaultfor' do
|
22
|
+
subject { described_class.specificity }
|
23
|
+
it { is_expected.to eql 1 }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when is defaultfor' do
|
27
|
+
let(:os) { Facter.value(:operatingsystem) }
|
28
|
+
subject do
|
29
|
+
described_class.defaultfor(operatingsystem: os)
|
30
|
+
described_class.specificity
|
31
|
+
end
|
32
|
+
it { is_expected.to be > 100 }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
19
36
|
end
|
@@ -3,8 +3,17 @@ require 'spec_helper'
|
|
3
3
|
osfamilies = { 'windows' => ['pip.exe'], 'other' => ['pip', 'pip-python'] }
|
4
4
|
|
5
5
|
describe Puppet::Type.type(:package).provider(:pip) do
|
6
|
+
|
7
|
+
it { is_expected.to be_installable }
|
8
|
+
it { is_expected.to be_uninstallable }
|
9
|
+
it { is_expected.to be_upgradeable }
|
10
|
+
it { is_expected.to be_versionable }
|
11
|
+
it { is_expected.to be_install_options }
|
12
|
+
it { is_expected.to be_targetable }
|
13
|
+
|
6
14
|
before do
|
7
15
|
@resource = Puppet::Resource.new(:package, "fake_package")
|
16
|
+
allow(@resource).to receive(:original_parameters).and_return({})
|
8
17
|
@provider = described_class.new(@resource)
|
9
18
|
@client = double('client')
|
10
19
|
allow(@client).to receive(:call).with('package_releases', 'real_package').and_return(["1.3", "1.2.5", "1.2.4"])
|
@@ -52,11 +61,11 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
52
61
|
expect(described_class).to receive(:which).with(cmd).and_return(nil)
|
53
62
|
end
|
54
63
|
end
|
55
|
-
allow(described_class).to receive(:pip_version).and_return('8.0.1')
|
56
|
-
expect(described_class).to receive(:which).with(pip_cmd).and_return(
|
64
|
+
allow(described_class).to receive(:pip_version).with(pip_cmd).and_return('8.0.1')
|
65
|
+
expect(described_class).to receive(:which).with(pip_cmd).and_return(pip_cmd)
|
57
66
|
p = double("process")
|
58
67
|
expect(p).to receive(:collect).and_yield("real_package==1.2.5")
|
59
|
-
expect(described_class).to receive(:execpipe).with([
|
68
|
+
expect(described_class).to receive(:execpipe).with([pip_cmd, ["freeze"]]).and_yield(p)
|
60
69
|
described_class.instances
|
61
70
|
end
|
62
71
|
end
|
@@ -66,11 +75,11 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
66
75
|
versions.each do |version|
|
67
76
|
it "should use the --all option when version is '#{version}'" do
|
68
77
|
allow(Puppet::Util::Platform).to receive(:windows?).and_return(osfamily == 'windows')
|
69
|
-
allow(described_class).to receive(:
|
70
|
-
allow(described_class).to receive(:pip_version).and_return(version)
|
78
|
+
allow(described_class).to receive(:provider_command).and_return('/fake/bin/pip')
|
79
|
+
allow(described_class).to receive(:pip_version).with('/fake/bin/pip').and_return(version)
|
71
80
|
p = double("process")
|
72
81
|
expect(p).to receive(:collect).and_yield("real_package==1.2.5")
|
73
|
-
expect(described_class).to receive(:execpipe).with(["/fake/bin/pip", "freeze", "--all"]).and_yield(p)
|
82
|
+
expect(described_class).to receive(:execpipe).with(["/fake/bin/pip", ["freeze", "--all"]]).and_yield(p)
|
74
83
|
described_class.instances
|
75
84
|
end
|
76
85
|
end
|
@@ -89,6 +98,8 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
89
98
|
context "query" do
|
90
99
|
before do
|
91
100
|
@resource[:name] = "real_package"
|
101
|
+
allow(described_class).to receive(:provider_command).and_return('/fake/bin/pip')
|
102
|
+
allow(described_class).to receive(:validate_command).with('/fake/bin/pip')
|
92
103
|
end
|
93
104
|
|
94
105
|
it "should return a hash when pip and the package are present" do
|
@@ -96,12 +107,14 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
96
107
|
:ensure => "1.2.5",
|
97
108
|
:name => "real_package",
|
98
109
|
:provider => :pip,
|
110
|
+
:command => '/fake/bin/pip',
|
99
111
|
})])
|
100
112
|
|
101
113
|
expect(@provider.query).to eq({
|
102
114
|
:ensure => "1.2.5",
|
103
115
|
:name => "real_package",
|
104
116
|
:provider => :pip,
|
117
|
+
:command => '/fake/bin/pip',
|
105
118
|
})
|
106
119
|
end
|
107
120
|
|
@@ -117,12 +130,14 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
117
130
|
:ensure => "1.2.5",
|
118
131
|
:name => "real_package",
|
119
132
|
:provider => :pip,
|
133
|
+
:command => '/fake/bin/pip',
|
120
134
|
})])
|
121
135
|
|
122
136
|
expect(@provider.query).to eq({
|
123
137
|
:ensure => "1.2.5",
|
124
138
|
:name => "real_package",
|
125
139
|
:provider => :pip,
|
140
|
+
:command => '/fake/bin/pip',
|
126
141
|
})
|
127
142
|
end
|
128
143
|
end
|
@@ -130,10 +145,12 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
130
145
|
context "latest" do
|
131
146
|
context "with pip version < 1.5.4" do
|
132
147
|
before :each do
|
133
|
-
allow(described_class).to receive(:pip_version).and_return('1.0.1')
|
148
|
+
allow(described_class).to receive(:pip_version).with("/fake/bin/pip").and_return('1.0.1')
|
134
149
|
allow(described_class).to receive(:which).with('pip').and_return("/fake/bin/pip")
|
135
150
|
allow(described_class).to receive(:which).with('pip-python').and_return("/fake/bin/pip")
|
136
151
|
allow(described_class).to receive(:which).with('pip.exe').and_return("/fake/bin/pip")
|
152
|
+
allow(described_class).to receive(:provider_command).and_return('/fake/bin/pip')
|
153
|
+
allow(described_class).to receive(:validate_command).with('/fake/bin/pip')
|
137
154
|
end
|
138
155
|
|
139
156
|
it "should find a version number for new_pip_package" do
|
@@ -186,10 +203,12 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
186
203
|
# For Pip 1.5.4 and above, you can get a version list from CLI - which allows for native pip behavior
|
187
204
|
# with regards to custom repositories, proxies and the like
|
188
205
|
before :each do
|
189
|
-
allow(described_class).to receive(:pip_version).and_return('1.5.4')
|
206
|
+
allow(described_class).to receive(:pip_version).with("/fake/bin/pip").and_return('1.5.4')
|
190
207
|
allow(described_class).to receive(:which).with('pip').and_return("/fake/bin/pip")
|
191
208
|
allow(described_class).to receive(:which).with('pip-python').and_return("/fake/bin/pip")
|
192
209
|
allow(described_class).to receive(:which).with('pip.exe').and_return("/fake/bin/pip")
|
210
|
+
allow(described_class).to receive(:provider_command).and_return('/fake/bin/pip')
|
211
|
+
allow(described_class).to receive(:validate_command).with('/fake/bin/pip')
|
193
212
|
end
|
194
213
|
|
195
214
|
it "should find a version number for real_package" do
|
@@ -239,12 +258,14 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
239
258
|
before do
|
240
259
|
@resource[:name] = "fake_package"
|
241
260
|
@url = "git+https://example.com/fake_package.git"
|
261
|
+
allow(described_class).to receive(:provider_command).and_return('/fake/bin/pip')
|
262
|
+
allow(described_class).to receive(:validate_command).with('/fake/bin/pip')
|
242
263
|
end
|
243
264
|
|
244
265
|
it "should install" do
|
245
266
|
@resource[:ensure] = :installed
|
246
267
|
@resource[:source] = nil
|
247
|
-
expect(@provider).to receive(:
|
268
|
+
expect(@provider).to receive(:execute).with(["/fake/bin/pip", ["install", "-q", "fake_package"]])
|
248
269
|
@provider.install
|
249
270
|
end
|
250
271
|
|
@@ -252,7 +273,8 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
252
273
|
# The -e flag makes the provider non-idempotent
|
253
274
|
@resource[:ensure] = :installed
|
254
275
|
@resource[:source] = @url
|
255
|
-
|
276
|
+
# TJK
|
277
|
+
expect(@provider).to receive(:execute) do |*args|
|
256
278
|
expect(args).not_to include("-e")
|
257
279
|
end
|
258
280
|
@provider.install
|
@@ -261,28 +283,31 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
261
283
|
it "should install from SCM" do
|
262
284
|
@resource[:ensure] = :installed
|
263
285
|
@resource[:source] = @url
|
264
|
-
expect(@provider).to receive(:
|
286
|
+
expect(@provider).to receive(:execute).with(["/fake/bin/pip", ["install", "-q", "#{@url}#egg=fake_package"]])
|
265
287
|
@provider.install
|
266
288
|
end
|
267
289
|
|
268
290
|
it "should install a particular SCM revision" do
|
269
291
|
@resource[:ensure] = "0123456"
|
270
292
|
@resource[:source] = @url
|
271
|
-
|
293
|
+
# TJK
|
294
|
+
expect(@provider).to receive(:execute).with(["/fake/bin/pip", ["install", "-q", "#{@url}@0123456#egg=fake_package"]])
|
272
295
|
@provider.install
|
273
296
|
end
|
274
297
|
|
275
298
|
it "should install a particular version" do
|
276
299
|
@resource[:ensure] = "0.0.0"
|
277
300
|
@resource[:source] = nil
|
278
|
-
|
301
|
+
# TJK
|
302
|
+
expect(@provider).to receive(:execute).with(["/fake/bin/pip", ["install", "-q", "fake_package==0.0.0"]])
|
279
303
|
@provider.install
|
280
304
|
end
|
281
305
|
|
282
306
|
it "should upgrade" do
|
283
307
|
@resource[:ensure] = :latest
|
284
308
|
@resource[:source] = nil
|
285
|
-
|
309
|
+
# TJK
|
310
|
+
expect(@provider).to receive(:execute).with(["/fake/bin/pip", ["install", "-q", "--upgrade", "fake_package"]])
|
286
311
|
@provider.install
|
287
312
|
end
|
288
313
|
|
@@ -290,15 +315,20 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
290
315
|
@resource[:ensure] = :installed
|
291
316
|
@resource[:source] = nil
|
292
317
|
@resource[:install_options] = [{"--timeout" => "10"}, "--no-index"]
|
293
|
-
expect(@provider).to receive(:
|
318
|
+
expect(@provider).to receive(:execute).with(["/fake/bin/pip", ["install", "-q", "--timeout=10", "--no-index", "fake_package"]])
|
294
319
|
@provider.install
|
295
320
|
end
|
296
321
|
end
|
297
322
|
|
298
323
|
context "uninstall" do
|
324
|
+
before do
|
325
|
+
allow(described_class).to receive(:provider_command).and_return('/fake/bin/pip')
|
326
|
+
allow(described_class).to receive(:validate_command).with('/fake/bin/pip')
|
327
|
+
end
|
328
|
+
|
299
329
|
it "should uninstall" do
|
300
330
|
@resource[:name] = "fake_package"
|
301
|
-
expect(@provider).to receive(:
|
331
|
+
expect(@provider).to receive(:execute).with(["/fake/bin/pip", ["uninstall", "-y", "-q", "fake_package"]])
|
302
332
|
@provider.uninstall
|
303
333
|
end
|
304
334
|
end
|
@@ -311,68 +341,28 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
311
341
|
end
|
312
342
|
|
313
343
|
context "pip_version" do
|
314
|
-
it "should return nil on missing pip" do
|
315
|
-
allow(described_class).to receive(:pip_cmd).and_return(nil)
|
316
|
-
expect(described_class.pip_version).to eq(nil)
|
317
|
-
end
|
318
|
-
|
319
344
|
it "should look up version if pip is present" do
|
320
345
|
allow(described_class).to receive(:pip_cmd).and_return('/fake/bin/pip')
|
321
346
|
p = double("process")
|
322
347
|
expect(p).to receive(:collect).and_yield('pip 8.0.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)')
|
323
348
|
expect(described_class).to receive(:execpipe).with(['/fake/bin/pip', '--version']).and_yield(p)
|
324
|
-
expect(described_class.pip_version).to eq('8.0.2')
|
349
|
+
expect(described_class.pip_version('/fake/bin/pip')).to eq('8.0.2')
|
325
350
|
end
|
326
351
|
end
|
327
352
|
|
328
|
-
context
|
329
|
-
|
330
|
-
|
353
|
+
context 'calculated specificity' do
|
354
|
+
context 'when is not defaultfor' do
|
355
|
+
subject { described_class.specificity }
|
356
|
+
it { is_expected.to eql 1 }
|
331
357
|
end
|
332
358
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
osfamilies.each do |osfamily, pip_cmds|
|
339
|
-
pip_cmds.each do |pip_cmd|
|
340
|
-
it "should retry on #{osfamily} systems if #{pip_cmd} has not yet been found" do
|
341
|
-
allow(Puppet::Util::Platform).to receive(:windows?).and_return(osfamily == 'windows')
|
342
|
-
times_called = 0
|
343
|
-
expect(@provider).to receive(:pip).twice.with('freeze') do
|
344
|
-
times_called += 1
|
345
|
-
raise NoMethodError if times_called == 1
|
346
|
-
nil
|
347
|
-
end
|
348
|
-
pip_cmds.each do |cmd|
|
349
|
-
unless cmd == pip_cmd
|
350
|
-
expect(@provider).to receive(:which).with(cmd).and_return(nil)
|
351
|
-
end
|
352
|
-
end
|
353
|
-
expect(@provider).to receive(:which).with(pip_cmd).and_return("/fake/bin/#{pip_cmd}")
|
354
|
-
@provider.method(:lazy_pip).call "freeze"
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
|
-
it "should fail on #{osfamily} systems if #{pip_cmds.join(' and ')} are missing" do
|
359
|
-
allow(Puppet::Util::Platform).to receive(:windows?).and_return(osfamily == 'windows')
|
360
|
-
expect(@provider).to receive(:pip).with('freeze').and_raise(NoMethodError)
|
361
|
-
pip_cmds.each do |pip_cmd|
|
362
|
-
expect(@provider).to receive(:which).with(pip_cmd).and_return(nil)
|
363
|
-
end
|
364
|
-
expect { @provider.method(:lazy_pip).call("freeze") }.to raise_error(NoMethodError)
|
365
|
-
end
|
366
|
-
|
367
|
-
it "should output a useful error message on #{osfamily} systems if #{pip_cmds.join(' and ')} are missing" do
|
368
|
-
allow(Puppet::Util::Platform).to receive(:windows?).and_return(osfamily == 'windows')
|
369
|
-
expect(@provider).to receive(:pip).with('freeze').and_raise(NoMethodError)
|
370
|
-
pip_cmds.each do |pip_cmd|
|
371
|
-
expect(@provider).to receive(:which).with(pip_cmd).and_return(nil)
|
372
|
-
end
|
373
|
-
expect { @provider.method(:lazy_pip).call("freeze") }.
|
374
|
-
to raise_error(NoMethodError, "Could not locate command #{pip_cmds.join(' and ')}.")
|
359
|
+
context 'when is defaultfor' do
|
360
|
+
let(:os) { Facter.value(:operatingsystem) }
|
361
|
+
subject do
|
362
|
+
described_class.defaultfor(operatingsystem: os)
|
363
|
+
described_class.specificity
|
375
364
|
end
|
365
|
+
it { is_expected.to be > 100 }
|
376
366
|
end
|
377
367
|
end
|
378
368
|
end
|
@@ -33,40 +33,56 @@ describe Puppet::Type.type(:package).provider(:puppet_gem) do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should use the path to the gem command" do
|
36
|
-
allow(described_class).to receive(:
|
36
|
+
allow(described_class).to receive(:validate_command).with(provider_gem_cmd)
|
37
37
|
expect(described_class).to receive(:execute).with(be_a(Array), execute_options) { |args| expect(args[0]).to eq(provider_gem_cmd) }.and_return('')
|
38
38
|
provider.install
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should not append install_options by default" do
|
42
|
-
expect(described_class).to receive(:execute_gem_command).with(%w{install --no-rdoc --no-ri myresource}).and_return('')
|
42
|
+
expect(described_class).to receive(:execute_gem_command).with(provider_gem_cmd, %w{install --no-rdoc --no-ri myresource}).and_return('')
|
43
43
|
provider.install
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should allow setting an install_options parameter" do
|
47
47
|
resource[:install_options] = [ '--force', {'--bindir' => '/usr/bin' } ]
|
48
|
-
expect(described_class).to receive(:execute_gem_command).with(%w{install --force --bindir=/usr/bin --no-rdoc --no-ri myresource}).and_return('')
|
48
|
+
expect(described_class).to receive(:execute_gem_command).with(provider_gem_cmd, %w{install --force --bindir=/usr/bin --no-rdoc --no-ri myresource}).and_return('')
|
49
49
|
provider.install
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
context "when uninstalling" do
|
54
54
|
it "should use the path to the gem command" do
|
55
|
-
allow(described_class).to receive(:
|
55
|
+
allow(described_class).to receive(:validate_command).with(provider_gem_cmd)
|
56
56
|
expect(described_class).to receive(:execute).with(be_a(Array), execute_options) { |args| expect(args[0]).to eq(provider_gem_cmd) }.and_return('')
|
57
57
|
provider.uninstall
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should not append uninstall_options by default" do
|
61
|
-
expect(described_class).to receive(:execute_gem_command).with(%w{uninstall --executables --all myresource}).and_return('')
|
61
|
+
expect(described_class).to receive(:execute_gem_command).with(provider_gem_cmd, %w{uninstall --executables --all myresource}).and_return('')
|
62
62
|
provider.uninstall
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should allow setting an uninstall_options parameter" do
|
66
66
|
resource[:uninstall_options] = [ '--force', {'--bindir' => '/usr/bin' } ]
|
67
|
-
expect(described_class).to receive(:execute_gem_command).with(%w{uninstall --executables --all myresource --force --bindir=/usr/bin}).and_return('')
|
67
|
+
expect(described_class).to receive(:execute_gem_command).with(provider_gem_cmd, %w{uninstall --executables --all myresource --force --bindir=/usr/bin}).and_return('')
|
68
68
|
provider.uninstall
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
context 'calculated specificity' do
|
73
|
+
context 'when is not defaultfor' do
|
74
|
+
subject { described_class.specificity }
|
75
|
+
it { is_expected.to eql 1 }
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when is defaultfor' do
|
79
|
+
let(:os) { Facter.value(:operatingsystem) }
|
80
|
+
subject do
|
81
|
+
described_class.defaultfor(operatingsystem: os)
|
82
|
+
described_class.specificity
|
83
|
+
end
|
84
|
+
it { is_expected.to be > 100 }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
72
88
|
end
|
@@ -56,7 +56,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
56
56
|
describe "self.instances" do
|
57
57
|
describe "with a modern version of RPM" do
|
58
58
|
it "includes all the modern flags" do
|
59
|
-
expect(Puppet::Util::Execution).to receive(:execpipe)
|
59
|
+
expect(Puppet::Util::Execution).to receive(:execpipe)
|
60
|
+
.with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}'")
|
61
|
+
.and_yield(packages)
|
60
62
|
|
61
63
|
described_class.instances
|
62
64
|
end
|
@@ -66,7 +68,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
66
68
|
let(:rpm_version) { "RPM version 4.0.2\n" }
|
67
69
|
|
68
70
|
it "excludes the --nosignature flag" do
|
69
|
-
expect(Puppet::Util::Execution).to receive(:execpipe)
|
71
|
+
expect(Puppet::Util::Execution).to receive(:execpipe)
|
72
|
+
.with("/bin/rpm -qa --nodigest --qf '#{nevra_format}'")
|
73
|
+
.and_yield(packages)
|
70
74
|
|
71
75
|
described_class.instances
|
72
76
|
end
|
@@ -76,14 +80,18 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
76
80
|
let(:rpm_version) { "RPM version 3.0.5\n" }
|
77
81
|
|
78
82
|
it "excludes the --nodigest flag" do
|
79
|
-
expect(Puppet::Util::Execution).to receive(:execpipe)
|
83
|
+
expect(Puppet::Util::Execution).to receive(:execpipe)
|
84
|
+
.with("/bin/rpm -qa --qf '#{nevra_format}'")
|
85
|
+
.and_yield(packages)
|
80
86
|
|
81
87
|
described_class.instances
|
82
88
|
end
|
83
89
|
end
|
84
90
|
|
85
91
|
it "returns an array of packages" do
|
86
|
-
expect(Puppet::Util::Execution).to receive(:execpipe)
|
92
|
+
expect(Puppet::Util::Execution).to receive(:execpipe)
|
93
|
+
.with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}'")
|
94
|
+
.and_yield(packages)
|
87
95
|
|
88
96
|
installed_packages = described_class.instances
|
89
97
|
|
@@ -167,7 +175,8 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
167
175
|
|
168
176
|
describe "when not already installed" do
|
169
177
|
it "only includes the '-i' flag" do
|
170
|
-
expect(Puppet::Util::Execution).to receive(:execute)
|
178
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
179
|
+
.with(["/bin/rpm", ["-i"], '/path/to/package'], execute_options)
|
171
180
|
provider.install
|
172
181
|
end
|
173
182
|
end
|
@@ -184,7 +193,8 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
184
193
|
end
|
185
194
|
|
186
195
|
it "includes the options" do
|
187
|
-
expect(Puppet::Util::Execution).to receive(:execute)
|
196
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
197
|
+
.with(["/bin/rpm", ["-i", "-D", "--test=value", "-Q"], '/path/to/package'], execute_options)
|
188
198
|
provider.install
|
189
199
|
end
|
190
200
|
end
|
@@ -197,7 +207,8 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
197
207
|
end
|
198
208
|
|
199
209
|
it "includes the '-U --oldpackage' flags" do
|
200
|
-
expect(Puppet::Util::Execution).to receive(:execute)
|
210
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
211
|
+
.with(["/bin/rpm", ["-U", "--oldpackage"], '/path/to/package'], execute_options)
|
201
212
|
provider.install
|
202
213
|
end
|
203
214
|
end
|
@@ -214,7 +225,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
214
225
|
|
215
226
|
it "raises an error if the rpm command fails" do
|
216
227
|
expect(resource).to receive(:[]).with(:source).and_return('source-string')
|
217
|
-
expect(Puppet::Util::Execution).to receive(:execute)
|
228
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
229
|
+
.with(["/bin/rpm", "-q", "--qf", "'#{nevra_format}'", "-p", "source-string"])
|
230
|
+
.and_raise(Puppet::ExecutionFailure, 'rpm command failed')
|
218
231
|
|
219
232
|
expect {
|
220
233
|
provider.latest
|
@@ -225,52 +238,115 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
225
238
|
describe "#uninstall" do
|
226
239
|
let(:resource) do
|
227
240
|
Puppet::Type.type(:package).new(
|
228
|
-
:name
|
229
|
-
:ensure
|
241
|
+
:name => resource_name,
|
242
|
+
:ensure => :installed
|
230
243
|
)
|
231
244
|
end
|
232
245
|
|
246
|
+
describe "on an ancient RPM" do
|
247
|
+
let(:rpm_version) { "RPM version 3.0.6\n" }
|
248
|
+
|
249
|
+
before(:each) do
|
250
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
251
|
+
.with(["/bin/rpm", "-q", resource_name, '', '', '--qf', "'#{nevra_format}'"], execute_options)
|
252
|
+
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
253
|
+
end
|
254
|
+
|
255
|
+
it "excludes the architecture from the package name" do
|
256
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
257
|
+
.with(["/bin/rpm", ["-e"], resource_name], execute_options)
|
258
|
+
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most(:once)
|
259
|
+
provider.uninstall
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
233
263
|
describe "on a modern RPM" do
|
264
|
+
let(:rpm_version) { "RPM version 4.10.0\n" }
|
265
|
+
|
266
|
+
|
234
267
|
before(:each) do
|
235
268
|
expect(Puppet::Util::Execution).to receive(:execute)
|
236
|
-
.with(["/bin/rpm", "-q",
|
237
|
-
.and_return(Puppet::Util::Execution::ProcessOutput.new("
|
269
|
+
.with(["/bin/rpm", "-q", resource_name, '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
|
270
|
+
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
238
271
|
end
|
239
272
|
|
273
|
+
it "excludes the architecture from the package name" do
|
274
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
275
|
+
.with(["/bin/rpm", ["-e"], resource_name], execute_options)
|
276
|
+
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most(:once)
|
277
|
+
provider.uninstall
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
describe "on a modern RPM when architecture is specified" do
|
240
282
|
let(:rpm_version) { "RPM version 4.10.0\n" }
|
241
283
|
|
284
|
+
let(:resource) do
|
285
|
+
Puppet::Type.type(:package).new(
|
286
|
+
:name => "#{resource_name}.noarch",
|
287
|
+
:ensure => :absent,
|
288
|
+
)
|
289
|
+
end
|
290
|
+
|
291
|
+
before(:each) do
|
292
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
293
|
+
.with(["/bin/rpm", "-q", "#{resource_name}.noarch", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
|
294
|
+
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
295
|
+
end
|
296
|
+
|
242
297
|
it "includes the architecture in the package name" do
|
243
298
|
expect(Puppet::Util::Execution).to receive(:execute)
|
244
|
-
.with(["/bin/rpm", ["-e"],
|
299
|
+
.with(["/bin/rpm", ["-e"], "#{resource_name}.noarch"], execute_options)
|
245
300
|
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most(:once)
|
246
301
|
provider.uninstall
|
247
302
|
end
|
248
303
|
end
|
249
304
|
|
250
|
-
describe "
|
305
|
+
describe "when version and release are specified" do
|
306
|
+
let(:resource) do
|
307
|
+
Puppet::Type.type(:package).new(
|
308
|
+
:name => "#{resource_name}-1.2.3.4-5.el4",
|
309
|
+
:ensure => :absent,
|
310
|
+
)
|
311
|
+
end
|
312
|
+
|
251
313
|
before(:each) do
|
252
314
|
expect(Puppet::Util::Execution).to receive(:execute)
|
253
|
-
.with(["/bin/rpm", "-q", "
|
254
|
-
.and_return(Puppet::Util::Execution::ProcessOutput.new("
|
315
|
+
.with(["/bin/rpm", "-q", "#{resource_name}-1.2.3.4-5.el4", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
|
316
|
+
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
255
317
|
end
|
256
318
|
|
257
|
-
|
258
|
-
|
259
|
-
it "excludes the architecture from the package name" do
|
319
|
+
it "includes the version and release in the package name" do
|
260
320
|
expect(Puppet::Util::Execution).to receive(:execute)
|
261
|
-
.with(["/bin/rpm", ["-e"],
|
321
|
+
.with(["/bin/rpm", ["-e"], "#{resource_name}-1.2.3.4-5.el4"], execute_options)
|
262
322
|
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most(:once)
|
263
323
|
provider.uninstall
|
264
324
|
end
|
265
325
|
end
|
266
326
|
|
267
|
-
describe "when
|
327
|
+
describe "when only version is specified" do
|
328
|
+
let(:resource) do
|
329
|
+
Puppet::Type.type(:package).new(
|
330
|
+
:name => "#{resource_name}-1.2.3.4",
|
331
|
+
:ensure => :absent,
|
332
|
+
)
|
333
|
+
end
|
334
|
+
|
268
335
|
before(:each) do
|
269
336
|
expect(Puppet::Util::Execution).to receive(:execute)
|
270
|
-
.with(["/bin/rpm", "-q", "
|
271
|
-
.and_return(Puppet::Util::Execution::ProcessOutput.new("
|
337
|
+
.with(["/bin/rpm", "-q", "#{resource_name}-1.2.3.4", '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
|
338
|
+
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
272
339
|
end
|
273
340
|
|
341
|
+
it "includes the version in the package name" do
|
342
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
343
|
+
.with(["/bin/rpm", ["-e"], "#{resource_name}-1.2.3.4"], execute_options)
|
344
|
+
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0)).at_most(:once)
|
345
|
+
provider.uninstall
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
describe "when uninstalled with options" do
|
274
350
|
let(:resource) do
|
275
351
|
Puppet::Type.type(:package).new(
|
276
352
|
:name => resource_name,
|
@@ -280,8 +356,15 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
280
356
|
)
|
281
357
|
end
|
282
358
|
|
359
|
+
before(:each) do
|
360
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
361
|
+
.with(["/bin/rpm", "-q", resource_name, '--nosignature', '--nodigest', "--qf", "'#{nevra_format}'"], execute_options)
|
362
|
+
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
363
|
+
end
|
364
|
+
|
283
365
|
it "includes the options" do
|
284
|
-
expect(Puppet::Util::Execution).to receive(:execute)
|
366
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
367
|
+
.with(["/bin/rpm", ["-e", "--nodeps"], resource_name], execute_options)
|
285
368
|
provider.uninstall
|
286
369
|
end
|
287
370
|
end
|
@@ -331,7 +414,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
331
414
|
before do
|
332
415
|
expect(Puppet).not_to receive(:debug)
|
333
416
|
expected_args = ["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "'#{nevra_format}'"]
|
334
|
-
expect(Puppet::Util::Execution).to receive(:execute)
|
417
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
418
|
+
.with(expected_args, execute_options)
|
419
|
+
.and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not installed"))
|
335
420
|
end
|
336
421
|
|
337
422
|
it "does not log or fail if allow_virtual is false" do
|
@@ -342,7 +427,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
342
427
|
it "does not log or fail if allow_virtual is true" do
|
343
428
|
resource[:allow_virtual] = true
|
344
429
|
expected_args = ['/bin/rpm', '-q', resource_name, '--nosignature', '--nodigest', '--qf', "'#{nevra_format}'", '--whatprovides']
|
345
|
-
expect(Puppet::Util::Execution).to receive(:execute)
|
430
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
431
|
+
.with(expected_args, execute_options)
|
432
|
+
.and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not provided"))
|
346
433
|
expect(provider.query).to be_nil
|
347
434
|
end
|
348
435
|
end
|
@@ -350,7 +437,9 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
350
437
|
it "parses virtual package" do
|
351
438
|
provider.resource[:allow_virtual] = true
|
352
439
|
expected_args = ["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "'#{nevra_format}'"]
|
353
|
-
expect(Puppet::Util::Execution).to receive(:execute)
|
440
|
+
expect(Puppet::Util::Execution).to receive(:execute)
|
441
|
+
.with(expected_args, execute_options)
|
442
|
+
.and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not installed"))
|
354
443
|
expect(Puppet::Util::Execution).to receive(:execute)
|
355
444
|
.with(expected_args + ["--whatprovides"], execute_options)
|
356
445
|
.and_return(Puppet::Util::Execution::ProcessOutput.new("myresource 0 1.2.3.4 5.el4 noarch\n", 0))
|