puppet 5.5.8-x86-mingw32 → 5.5.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 +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,9 +1,6 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
describe provider_class do
|
3
|
+
describe Puppet::Type.type(:package).provider(:pip3) do
|
7
4
|
|
8
5
|
it { is_expected.to be_installable }
|
9
6
|
it { is_expected.to be_uninstallable }
|
@@ -12,11 +9,11 @@ describe provider_class do
|
|
12
9
|
it { is_expected.to be_install_options }
|
13
10
|
|
14
11
|
it "should inherit most things from pip provider" do
|
15
|
-
expect(
|
12
|
+
expect(described_class < Puppet::Type.type(:package).provider(:pip))
|
16
13
|
end
|
17
14
|
|
18
15
|
it "should use pip3 command" do
|
19
|
-
expect(
|
16
|
+
expect(described_class.cmd).to eq(["pip3"])
|
20
17
|
end
|
21
18
|
|
22
19
|
end
|
@@ -1,23 +1,19 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
|
-
provider_class = Puppet::Type.type(:package).provider(:pip)
|
5
3
|
osfamilies = { 'windows' => ['pip.exe'], 'other' => ['pip', 'pip-python'] }
|
6
4
|
|
7
|
-
describe
|
8
|
-
|
5
|
+
describe Puppet::Type.type(:package).provider(:pip) do
|
9
6
|
before do
|
10
7
|
@resource = Puppet::Resource.new(:package, "fake_package")
|
11
|
-
@provider =
|
8
|
+
@provider = described_class.new(@resource)
|
12
9
|
@client = stub_everything('client')
|
13
10
|
@client.stubs(:call).with('package_releases', 'real_package').returns(["1.3", "1.2.5", "1.2.4"])
|
14
11
|
@client.stubs(:call).with('package_releases', 'fake_package').returns([])
|
15
12
|
end
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
context "parse" do
|
19
15
|
it "should return a hash on valid input" do
|
20
|
-
expect(
|
16
|
+
expect(described_class.parse("real_package==1.2.5")).to eq({
|
21
17
|
:ensure => "1.2.5",
|
22
18
|
:name => "real_package",
|
23
19
|
:provider => :pip,
|
@@ -25,48 +21,43 @@ describe provider_class do
|
|
25
21
|
end
|
26
22
|
|
27
23
|
it "should return nil on invalid input" do
|
28
|
-
expect(
|
24
|
+
expect(described_class.parse("foo")).to eq(nil)
|
29
25
|
end
|
30
|
-
|
31
26
|
end
|
32
27
|
|
33
|
-
|
34
|
-
|
28
|
+
context "cmd" do
|
35
29
|
it "should return 'pip.exe' by default on Windows systems" do
|
36
30
|
Puppet.features.stubs(:microsoft_windows?).returns true
|
37
|
-
expect(
|
31
|
+
expect(described_class.cmd[0]).to eq('pip.exe')
|
38
32
|
end
|
39
33
|
|
40
34
|
it "could return pip-python on legacy redhat systems which rename pip" do
|
41
35
|
Puppet.features.stubs(:microsoft_windows?).returns false
|
42
|
-
expect(
|
36
|
+
expect(described_class.cmd[1]).to eq('pip-python')
|
43
37
|
end
|
44
38
|
|
45
39
|
it "should return pip by default on other systems" do
|
46
40
|
Puppet.features.stubs(:microsoft_windows?).returns false
|
47
|
-
expect(
|
41
|
+
expect(described_class.cmd[0]).to eq('pip')
|
48
42
|
end
|
49
|
-
|
50
43
|
end
|
51
44
|
|
52
|
-
|
53
|
-
|
45
|
+
context "instances" do
|
54
46
|
osfamilies.each do |osfamily, pip_cmds|
|
55
|
-
|
56
47
|
it "should return an array on #{osfamily} systems when #{pip_cmds.join(' or ')} is present" do
|
57
48
|
Puppet.features.stubs(:microsoft_windows?).returns (osfamily == 'windows')
|
58
49
|
pip_cmds.each do |pip_cmd|
|
59
50
|
pip_cmds.each do |cmd|
|
60
51
|
unless cmd == pip_cmd
|
61
|
-
|
52
|
+
described_class.expects(:which).with(cmd).returns(nil)
|
62
53
|
end
|
63
54
|
end
|
64
|
-
|
65
|
-
|
55
|
+
described_class.stubs(:pip_version).returns('8.0.1')
|
56
|
+
described_class.expects(:which).with(pip_cmd).returns("/fake/bin/#{pip_cmd}")
|
66
57
|
p = stub("process")
|
67
58
|
p.expects(:collect).yields("real_package==1.2.5")
|
68
|
-
|
69
|
-
|
59
|
+
described_class.expects(:execpipe).with(["/fake/bin/#{pip_cmd}", "freeze"]).yields(p)
|
60
|
+
described_class.instances
|
70
61
|
end
|
71
62
|
end
|
72
63
|
|
@@ -75,12 +66,12 @@ describe provider_class do
|
|
75
66
|
versions.each do |version|
|
76
67
|
it "should use the --all option when version is '#{version}'" do
|
77
68
|
Puppet.features.stubs(:microsoft_windows?).returns (osfamily == 'windows')
|
78
|
-
|
79
|
-
|
69
|
+
described_class.stubs(:pip_cmd).returns('/fake/bin/pip')
|
70
|
+
described_class.stubs(:pip_version).returns(version)
|
80
71
|
p = stub("process")
|
81
72
|
p.expects(:collect).yields("real_package==1.2.5")
|
82
|
-
|
83
|
-
|
73
|
+
described_class.expects(:execpipe).with(["/fake/bin/pip", "freeze", "--all"]).yields(p)
|
74
|
+
described_class.instances
|
84
75
|
end
|
85
76
|
end
|
86
77
|
end
|
@@ -88,23 +79,20 @@ describe provider_class do
|
|
88
79
|
it "should return an empty array on #{osfamily} systems when #{pip_cmds.join(' and ')} are missing" do
|
89
80
|
Puppet.features.stubs(:microsoft_windows?).returns (osfamily == 'windows')
|
90
81
|
pip_cmds.each do |cmd|
|
91
|
-
|
82
|
+
described_class.expects(:which).with(cmd).returns nil
|
92
83
|
end
|
93
|
-
expect(
|
84
|
+
expect(described_class.instances).to eq([])
|
94
85
|
end
|
95
|
-
|
96
86
|
end
|
97
|
-
|
98
87
|
end
|
99
88
|
|
100
|
-
|
101
|
-
|
89
|
+
context "query" do
|
102
90
|
before do
|
103
91
|
@resource[:name] = "real_package"
|
104
92
|
end
|
105
93
|
|
106
94
|
it "should return a hash when pip and the package are present" do
|
107
|
-
|
95
|
+
described_class.expects(:instances).returns [described_class.new({
|
108
96
|
:ensure => "1.2.5",
|
109
97
|
:name => "real_package",
|
110
98
|
:provider => :pip,
|
@@ -118,14 +106,14 @@ describe provider_class do
|
|
118
106
|
end
|
119
107
|
|
120
108
|
it "should return nil when the package is missing" do
|
121
|
-
|
109
|
+
described_class.expects(:instances).returns []
|
122
110
|
expect(@provider.query).to eq(nil)
|
123
111
|
end
|
124
112
|
|
125
113
|
it "should be case insensitive" do
|
126
114
|
@resource[:name] = "Real_Package"
|
127
115
|
|
128
|
-
|
116
|
+
described_class.expects(:instances).returns [described_class.new({
|
129
117
|
:ensure => "1.2.5",
|
130
118
|
:name => "real_package",
|
131
119
|
:provider => :pip,
|
@@ -137,16 +125,15 @@ describe provider_class do
|
|
137
125
|
:provider => :pip,
|
138
126
|
})
|
139
127
|
end
|
140
|
-
|
141
128
|
end
|
142
129
|
|
143
|
-
|
130
|
+
context "latest" do
|
144
131
|
context "with pip version < 1.5.4" do
|
145
132
|
before :each do
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
133
|
+
described_class.stubs(:pip_version).returns('1.0.1')
|
134
|
+
described_class.stubs(:which).with('pip').returns("/fake/bin/pip")
|
135
|
+
described_class.stubs(:which).with('pip-python').returns("/fake/bin/pip")
|
136
|
+
described_class.stubs(:which).with('pip.exe').returns("/fake/bin/pip")
|
150
137
|
end
|
151
138
|
|
152
139
|
it "should find a version number for new_pip_package" do
|
@@ -198,12 +185,11 @@ describe provider_class do
|
|
198
185
|
context "with pip version >= 1.5.4" do
|
199
186
|
# For Pip 1.5.4 and above, you can get a version list from CLI - which allows for native pip behavior
|
200
187
|
# with regards to custom repositories, proxies and the like
|
201
|
-
|
202
188
|
before :each do
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
189
|
+
described_class.stubs(:pip_version).returns('1.5.4')
|
190
|
+
described_class.stubs(:which).with('pip').returns("/fake/bin/pip")
|
191
|
+
described_class.stubs(:which).with('pip-python').returns("/fake/bin/pip")
|
192
|
+
described_class.stubs(:which).with('pip.exe').returns("/fake/bin/pip")
|
207
193
|
end
|
208
194
|
|
209
195
|
it "should find a version number for real_package" do
|
@@ -247,11 +233,9 @@ describe provider_class do
|
|
247
233
|
expect(latest).to eq('15.0.2')
|
248
234
|
end
|
249
235
|
end
|
250
|
-
|
251
236
|
end
|
252
237
|
|
253
|
-
|
254
|
-
|
238
|
+
context "install" do
|
255
239
|
before do
|
256
240
|
@resource[:name] = "fake_package"
|
257
241
|
@url = "git+https://example.com/fake_package.git"
|
@@ -314,48 +298,40 @@ describe provider_class do
|
|
314
298
|
with("install", "-q", "--timeout=10", "--no-index", "fake_package")
|
315
299
|
@provider.install
|
316
300
|
end
|
317
|
-
|
318
301
|
end
|
319
302
|
|
320
|
-
|
321
|
-
|
303
|
+
context "uninstall" do
|
322
304
|
it "should uninstall" do
|
323
305
|
@resource[:name] = "fake_package"
|
324
306
|
@provider.expects(:lazy_pip).
|
325
307
|
with('uninstall', '-y', '-q', 'fake_package')
|
326
308
|
@provider.uninstall
|
327
309
|
end
|
328
|
-
|
329
310
|
end
|
330
311
|
|
331
|
-
|
332
|
-
|
312
|
+
context "update" do
|
333
313
|
it "should just call install" do
|
334
314
|
@provider.expects(:install).returns(nil)
|
335
315
|
@provider.update
|
336
316
|
end
|
337
|
-
|
338
317
|
end
|
339
318
|
|
340
|
-
|
341
|
-
|
319
|
+
context "pip_version" do
|
342
320
|
it "should return nil on missing pip" do
|
343
|
-
|
344
|
-
expect(
|
321
|
+
described_class.stubs(:pip_cmd).returns(nil)
|
322
|
+
expect(described_class.pip_version).to eq(nil)
|
345
323
|
end
|
346
324
|
|
347
325
|
it "should look up version if pip is present" do
|
348
|
-
|
326
|
+
described_class.stubs(:pip_cmd).returns('/fake/bin/pip')
|
349
327
|
p = stub("process")
|
350
328
|
p.expects(:collect).yields('pip 8.0.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)')
|
351
|
-
|
352
|
-
expect(
|
329
|
+
described_class.expects(:execpipe).with(['/fake/bin/pip', '--version']).yields(p)
|
330
|
+
expect(described_class.pip_version).to eq('8.0.2')
|
353
331
|
end
|
354
|
-
|
355
332
|
end
|
356
333
|
|
357
|
-
|
358
|
-
|
334
|
+
context "lazy_pip" do
|
359
335
|
after(:each) do
|
360
336
|
Puppet::Type::Package::ProviderPip.instance_variable_set(:@confine_collection, nil)
|
361
337
|
end
|
@@ -366,7 +342,6 @@ describe provider_class do
|
|
366
342
|
end
|
367
343
|
|
368
344
|
osfamilies.each do |osfamily, pip_cmds|
|
369
|
-
|
370
345
|
pip_cmds.each do |pip_cmd|
|
371
346
|
it "should retry on #{osfamily} systems if #{pip_cmd} has not yet been found" do
|
372
347
|
Puppet.features.stubs(:microsoft_windows?).returns (osfamily == 'windows')
|
@@ -399,9 +374,6 @@ describe provider_class do
|
|
399
374
|
expect { @provider.method(:lazy_pip).call("freeze") }.
|
400
375
|
to raise_error(NoMethodError, "Could not locate command #{pip_cmds.join(' and ')}.")
|
401
376
|
end
|
402
|
-
|
403
377
|
end
|
404
|
-
|
405
378
|
end
|
406
|
-
|
407
379
|
end
|
@@ -1,19 +1,16 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
describe provider_class do
|
3
|
+
describe Puppet::Type.type(:package).provider(:pkgin) do
|
6
4
|
let(:resource) { Puppet::Type.type(:package).new(:name => "vim", :provider => :pkgin) }
|
7
5
|
subject { resource.provider }
|
8
6
|
|
9
7
|
describe "Puppet provider interface" do
|
10
8
|
it "can return the list of all packages" do
|
11
|
-
expect(
|
9
|
+
expect(described_class).to respond_to(:instances)
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
15
13
|
describe "#install" do
|
16
|
-
|
17
14
|
describe "a package not installed" do
|
18
15
|
before { resource[:ensure] = :absent }
|
19
16
|
it "uses pkgin install to install" do
|
@@ -29,7 +26,6 @@ describe provider_class do
|
|
29
26
|
subject.install
|
30
27
|
end
|
31
28
|
end
|
32
|
-
|
33
29
|
end
|
34
30
|
|
35
31
|
describe "#uninstall" do
|
@@ -45,19 +41,19 @@ describe provider_class do
|
|
45
41
|
end
|
46
42
|
|
47
43
|
before do
|
48
|
-
|
44
|
+
described_class.stubs(:pkgin).with(:list).returns(pkgin_ls_output)
|
49
45
|
end
|
50
46
|
|
51
47
|
it "returns an array of providers for each package" do
|
52
|
-
instances =
|
48
|
+
instances = described_class.instances
|
53
49
|
expect(instances).to have(2).items
|
54
50
|
instances.each do |instance|
|
55
|
-
expect(instance).to be_a(
|
51
|
+
expect(instance).to be_a(described_class)
|
56
52
|
end
|
57
53
|
end
|
58
54
|
|
59
55
|
it "populates each provider with an installed package" do
|
60
|
-
zlib_provider, zziplib_provider =
|
56
|
+
zlib_provider, zziplib_provider = described_class.instances
|
61
57
|
expect(zlib_provider.get(:name)).to eq("zlib")
|
62
58
|
expect(zlib_provider.get(:ensure)).to eq("1.2.3")
|
63
59
|
expect(zziplib_provider.get(:name)).to eq("zziplib")
|
@@ -67,7 +63,7 @@ describe provider_class do
|
|
67
63
|
|
68
64
|
describe "#latest" do
|
69
65
|
before do
|
70
|
-
|
66
|
+
described_class.stubs(:pkgin).with(:search, "vim").returns(pkgin_search_output)
|
71
67
|
end
|
72
68
|
|
73
69
|
context "when the package is installed" do
|
@@ -119,7 +115,7 @@ SEARCH
|
|
119
115
|
end
|
120
116
|
|
121
117
|
it "returns the newest available version" do
|
122
|
-
|
118
|
+
described_class.stubs(:pkgin).with(:search, "vim").returns(pkgin_search_output)
|
123
119
|
expect(subject.latest).to eq("7.3")
|
124
120
|
end
|
125
121
|
end
|
@@ -140,7 +136,7 @@ SEARCH
|
|
140
136
|
let(:package) { "vim-7.2.446;=;Vim editor (vi clone) without GUI" }
|
141
137
|
|
142
138
|
it "extracts the name and status" do
|
143
|
-
expect(
|
139
|
+
expect(described_class.parse_pkgin_line(package)).to eq({ :name => "vim" ,
|
144
140
|
:status => "=" ,
|
145
141
|
:ensure => "7.2.446" })
|
146
142
|
end
|
@@ -150,7 +146,7 @@ SEARCH
|
|
150
146
|
let(:package) { "ruby18-puppet-0.25.5nb1;>;Configuration management framework written in Ruby" }
|
151
147
|
|
152
148
|
it "extracts the name and status" do
|
153
|
-
expect(
|
149
|
+
expect(described_class.parse_pkgin_line(package)).to eq({ :name => "ruby18-puppet",
|
154
150
|
:status => ">" ,
|
155
151
|
:ensure => "0.25.5nb1" })
|
156
152
|
end
|
@@ -160,7 +156,7 @@ SEARCH
|
|
160
156
|
let(:package) { "ruby200-facter-2.4.3nb1;=;Cross-platform Ruby library for retrieving facts from OS" }
|
161
157
|
|
162
158
|
it "extracts the name and status" do
|
163
|
-
expect(
|
159
|
+
expect(described_class.parse_pkgin_line(package)).to eq({ :name => "ruby200-facter",
|
164
160
|
:status => "=" ,
|
165
161
|
:ensure => "2.4.3nb1" })
|
166
162
|
end
|
@@ -170,18 +166,17 @@ SEARCH
|
|
170
166
|
let(:package) { "vim-7.2.446;Vim editor (vi clone) without GUI" }
|
171
167
|
|
172
168
|
it "extracts the name and status" do
|
173
|
-
expect(
|
169
|
+
expect(described_class.parse_pkgin_line(package)).to eq({ :name => "vim" ,
|
174
170
|
:status => nil ,
|
175
171
|
:ensure => "7.2.446" })
|
176
172
|
end
|
177
|
-
|
178
173
|
end
|
179
174
|
|
180
175
|
context "with an invalid package" do
|
181
176
|
let(:package) { "" }
|
182
177
|
|
183
178
|
it "returns nil" do
|
184
|
-
expect(
|
179
|
+
expect(described_class.parse_pkgin_line(package)).to be_nil
|
185
180
|
end
|
186
181
|
end
|
187
182
|
end
|
@@ -1,10 +1,7 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
1
|
require 'spec_helper'
|
3
2
|
require 'puppet/provider/package/pkgng'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
describe provider_class do
|
4
|
+
describe Puppet::Type.type(:package).provider(:pkgng) do
|
8
5
|
let(:name) { 'bash' }
|
9
6
|
let(:installed_name) { 'zsh' }
|
10
7
|
let(:pkgng) { 'pkgng' }
|
@@ -38,41 +35,41 @@ describe provider_class do
|
|
38
35
|
end
|
39
36
|
|
40
37
|
before do
|
41
|
-
|
38
|
+
described_class.stubs(:command).with(:pkg) { '/usr/local/sbin/pkg' }
|
42
39
|
|
43
40
|
info = File.read(my_fixture('pkg.info'))
|
44
|
-
|
41
|
+
described_class.stubs(:get_query).returns(info)
|
45
42
|
|
46
43
|
version_list = File.read(my_fixture('pkg.version'))
|
47
|
-
|
44
|
+
described_class.stubs(:get_version_list).returns(version_list)
|
48
45
|
end
|
49
46
|
|
50
47
|
context "#instances" do
|
51
48
|
it "should return the empty set if no packages are listed" do
|
52
|
-
|
53
|
-
|
54
|
-
expect(
|
49
|
+
described_class.stubs(:get_query).returns('')
|
50
|
+
described_class.stubs(:get_version_list).returns('')
|
51
|
+
expect(described_class.instances).to be_empty
|
55
52
|
end
|
56
53
|
|
57
54
|
it "should return all packages when invoked" do
|
58
|
-
expect(
|
55
|
+
expect(described_class.instances.map(&:name).sort).to eq(
|
59
56
|
%w{ca_root_nss curl nmap pkg gnupg mcollective zsh tac_plus}.sort)
|
60
57
|
end
|
61
58
|
|
62
59
|
it "should set latest to current version when no upgrade available" do
|
63
|
-
nmap =
|
60
|
+
nmap = described_class.instances.find {|i| i.properties[:origin] == 'security/nmap' }
|
64
61
|
|
65
62
|
expect(nmap.properties[:version]).to eq(nmap.properties[:latest])
|
66
63
|
end
|
67
64
|
|
68
65
|
it "should return an empty array when pkg calls raise an exception" do
|
69
|
-
|
70
|
-
expect(
|
66
|
+
described_class.stubs(:get_query).raises(Puppet::ExecutionFailure, 'An error occurred.')
|
67
|
+
expect(described_class.instances).to eq([])
|
71
68
|
end
|
72
69
|
|
73
70
|
describe "version" do
|
74
71
|
it "should retrieve the correct version of the current package" do
|
75
|
-
zsh =
|
72
|
+
zsh = described_class.instances.find {|i| i.properties[:origin] == 'shells/zsh' }
|
76
73
|
expect( zsh.properties[:version]).to eq('5.0.2_1')
|
77
74
|
end
|
78
75
|
end
|
@@ -118,32 +115,32 @@ describe provider_class do
|
|
118
115
|
|
119
116
|
context "#prefetch" do
|
120
117
|
it "should fail gracefully when " do
|
121
|
-
|
122
|
-
expect{
|
118
|
+
described_class.stubs(:instances).returns([])
|
119
|
+
expect{ described_class.prefetch({}) }.to_not raise_error
|
123
120
|
end
|
124
121
|
end
|
125
122
|
|
126
123
|
context "#query" do
|
127
124
|
it "should return the installed version if present" do
|
128
|
-
|
125
|
+
described_class.prefetch({installed_name => installed_resource})
|
129
126
|
expect(installed_provider.query).to eq({:version=>'5.0.2_1'})
|
130
127
|
end
|
131
128
|
|
132
129
|
it "should return nil if not present" do
|
133
130
|
fixture = File.read(my_fixture('pkg.query_absent'))
|
134
|
-
|
131
|
+
described_class.stubs(:get_resource_info).with('bash').returns(fixture)
|
135
132
|
expect(provider.query).to equal(nil)
|
136
133
|
end
|
137
134
|
end
|
138
135
|
|
139
136
|
describe "latest" do
|
140
137
|
it "should retrieve the correct version of the latest package" do
|
141
|
-
|
138
|
+
described_class.prefetch( { installed_name => installed_resource })
|
142
139
|
expect(installed_provider.latest).not_to be_nil
|
143
140
|
end
|
144
141
|
|
145
142
|
it "should set latest to newer package version when available" do
|
146
|
-
instances =
|
143
|
+
instances = described_class.instances
|
147
144
|
curl = instances.find {|i| i.properties[:origin] == 'ftp/curl' }
|
148
145
|
expect(curl.properties[:latest]).to eq('7.33.0_2')
|
149
146
|
end
|
@@ -164,13 +161,13 @@ describe provider_class do
|
|
164
161
|
describe "get_latest_version" do
|
165
162
|
it "should rereturn nil when the current package is the latest" do
|
166
163
|
version_list = File.read(my_fixture('pkg.version'))
|
167
|
-
nmap_latest_version =
|
164
|
+
nmap_latest_version = described_class.get_latest_version('security/nmap', version_list)
|
168
165
|
expect(nmap_latest_version).to be_nil
|
169
166
|
end
|
170
167
|
|
171
168
|
it "should match the package name exactly" do
|
172
169
|
version_list = File.read(my_fixture('pkg.version'))
|
173
|
-
bash_comp_latest_version =
|
170
|
+
bash_comp_latest_version = described_class.get_latest_version('shells/bash-completion', version_list)
|
174
171
|
expect(bash_comp_latest_version).to eq('2.1_3')
|
175
172
|
end
|
176
173
|
end
|
@@ -179,7 +176,7 @@ describe provider_class do
|
|
179
176
|
context "on FreeBSD" do
|
180
177
|
it "should be the default provider" do
|
181
178
|
Facter.expects(:value).with(:operatingsystem).at_least_once.returns :freebsd
|
182
|
-
expect(
|
179
|
+
expect(described_class).to be_default
|
183
180
|
end
|
184
181
|
end
|
185
182
|
end
|