puppet 6.0.4-universal-darwin → 6.0.5-universal-darwin
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/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 +48 -32
- data/lib/puppet/application/ssl.rb +31 -17
- data/lib/puppet/defaults.rb +2 -1
- 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/model/pn_transformer.rb +5 -0
- 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/package/dnf.rb +2 -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/package/yum.rb +1 -1
- data/lib/puppet/provider/parsedfile.rb +25 -4
- data/lib/puppet/provider/service/smf.rb +54 -0
- data/lib/puppet/provider/service/systemd.rb +2 -0
- data/lib/puppet/provider/service/upstart.rb +1 -0
- data/lib/puppet/rest/route.rb +1 -1
- data/lib/puppet/ssl/host.rb +23 -11
- 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/ja/puppet.po +232 -183
- data/locales/puppet.pot +145 -117
- data/man/man5/puppet.conf.5 +3 -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 +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-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 +6 -3
- 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 +559 -0
- data/spec/integration/util/windows/registry_spec.rb +39 -0
- data/spec/unit/application/device_spec.rb +10 -7
- data/spec/unit/application/lookup_spec.rb +2 -1
- data/spec/unit/application/ssl_spec.rb +21 -2
- data/spec/unit/forge/forge_spec.rb +4 -2
- data/spec/unit/functions/logging_spec.rb +10 -3
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/pops/loaders/loader_spec.rb +6 -7
- data/spec/unit/pops/model/pn_transformer_spec.rb +4 -0
- 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/group/ldap_spec.rb +22 -25
- data/spec/unit/provider/group/pw_spec.rb +7 -10
- 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 +36 -37
- 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 +45 -49
- 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 +30 -16
- data/spec/unit/provider/package/zypper_spec.rb +17 -19
- data/spec/unit/provider/service/bsd_spec.rb +7 -9
- data/spec/unit/provider/service/daemontools_spec.rb +12 -16
- data/spec/unit/provider/service/debian_spec.rb +6 -10
- data/spec/unit/provider/service/freebsd_spec.rb +2 -2
- data/spec/unit/provider/service/openbsd_spec.rb +13 -17
- data/spec/unit/provider/service/rcng_spec.rb +2 -4
- data/spec/unit/provider/service/redhat_spec.rb +12 -11
- data/spec/unit/provider/service/runit_spec.rb +7 -14
- data/spec/unit/provider/service/smf_spec.rb +77 -13
- data/spec/unit/provider/service/src_spec.rb +11 -16
- data/spec/unit/provider/service/systemd_spec.rb +18 -0
- data/spec/unit/provider/user/hpux_spec.rb +3 -5
- data/spec/unit/provider/user/ldap_spec.rb +29 -32
- data/spec/unit/provider/user/pw_spec.rb +10 -13
- data/spec/unit/rest/route_spec.rb +1 -1
- data/spec/unit/ssl/host_spec.rb +21 -0
- 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 +8 -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,21 +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
|
-
before do
|
5
|
+
describe Puppet::Type.type(:package).provider(:pip) do
|
6
|
+
before do
|
9
7
|
@resource = Puppet::Resource.new(:package, "fake_package")
|
10
|
-
@provider =
|
8
|
+
@provider = described_class.new(@resource)
|
11
9
|
@client = stub_everything('client')
|
12
10
|
@client.stubs(:call).with('package_releases', 'real_package').returns(["1.3", "1.2.5", "1.2.4"])
|
13
11
|
@client.stubs(:call).with('package_releases', 'fake_package').returns([])
|
14
12
|
end
|
15
13
|
|
16
|
-
|
14
|
+
context "parse" do
|
17
15
|
it "should return a hash on valid input" do
|
18
|
-
expect(
|
16
|
+
expect(described_class.parse("real_package==1.2.5")).to eq({
|
19
17
|
:ensure => "1.2.5",
|
20
18
|
:name => "real_package",
|
21
19
|
:provider => :pip,
|
@@ -23,43 +21,43 @@ describe provider_class do
|
|
23
21
|
end
|
24
22
|
|
25
23
|
it "should return nil on invalid input" do
|
26
|
-
expect(
|
24
|
+
expect(described_class.parse("foo")).to eq(nil)
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
30
|
-
|
28
|
+
context "cmd" do
|
31
29
|
it "should return 'pip.exe' by default on Windows systems" do
|
32
30
|
Puppet::Util::Platform.stubs(:windows?).returns true
|
33
|
-
expect(
|
31
|
+
expect(described_class.cmd[0]).to eq('pip.exe')
|
34
32
|
end
|
35
33
|
|
36
34
|
it "could return pip-python on legacy redhat systems which rename pip" do
|
37
35
|
Puppet::Util::Platform.stubs(:windows?).returns false
|
38
|
-
expect(
|
36
|
+
expect(described_class.cmd[1]).to eq('pip-python')
|
39
37
|
end
|
40
38
|
|
41
39
|
it "should return pip by default on other systems" do
|
42
40
|
Puppet::Util::Platform.stubs(:windows?).returns false
|
43
|
-
expect(
|
41
|
+
expect(described_class.cmd[0]).to eq('pip')
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
47
|
-
|
45
|
+
context "instances" do
|
48
46
|
osfamilies.each do |osfamily, pip_cmds|
|
49
47
|
it "should return an array on #{osfamily} systems when #{pip_cmds.join(' or ')} is present" do
|
50
48
|
Puppet::Util::Platform.stubs(:windows?).returns (osfamily == 'windows')
|
51
49
|
pip_cmds.each do |pip_cmd|
|
52
50
|
pip_cmds.each do |cmd|
|
53
51
|
unless cmd == pip_cmd
|
54
|
-
|
52
|
+
described_class.expects(:which).with(cmd).returns(nil)
|
55
53
|
end
|
56
54
|
end
|
57
|
-
|
58
|
-
|
55
|
+
described_class.stubs(:pip_version).returns('8.0.1')
|
56
|
+
described_class.expects(:which).with(pip_cmd).returns("/fake/bin/#{pip_cmd}")
|
59
57
|
p = stub("process")
|
60
58
|
p.expects(:collect).yields("real_package==1.2.5")
|
61
|
-
|
62
|
-
|
59
|
+
described_class.expects(:execpipe).with(["/fake/bin/#{pip_cmd}", "freeze"]).yields(p)
|
60
|
+
described_class.instances
|
63
61
|
end
|
64
62
|
end
|
65
63
|
|
@@ -68,12 +66,12 @@ describe provider_class do
|
|
68
66
|
versions.each do |version|
|
69
67
|
it "should use the --all option when version is '#{version}'" do
|
70
68
|
Puppet::Util::Platform.stubs(:windows?).returns (osfamily == 'windows')
|
71
|
-
|
72
|
-
|
69
|
+
described_class.stubs(:pip_cmd).returns('/fake/bin/pip')
|
70
|
+
described_class.stubs(:pip_version).returns(version)
|
73
71
|
p = stub("process")
|
74
72
|
p.expects(:collect).yields("real_package==1.2.5")
|
75
|
-
|
76
|
-
|
73
|
+
described_class.expects(:execpipe).with(["/fake/bin/pip", "freeze", "--all"]).yields(p)
|
74
|
+
described_class.instances
|
77
75
|
end
|
78
76
|
end
|
79
77
|
end
|
@@ -81,20 +79,20 @@ describe provider_class do
|
|
81
79
|
it "should return an empty array on #{osfamily} systems when #{pip_cmds.join(' and ')} are missing" do
|
82
80
|
Puppet::Util::Platform.stubs(:windows?).returns (osfamily == 'windows')
|
83
81
|
pip_cmds.each do |cmd|
|
84
|
-
|
82
|
+
described_class.expects(:which).with(cmd).returns nil
|
85
83
|
end
|
86
|
-
expect(
|
84
|
+
expect(described_class.instances).to eq([])
|
87
85
|
end
|
88
86
|
end
|
89
87
|
end
|
90
88
|
|
91
|
-
|
89
|
+
context "query" do
|
92
90
|
before do
|
93
91
|
@resource[:name] = "real_package"
|
94
92
|
end
|
95
93
|
|
96
94
|
it "should return a hash when pip and the package are present" do
|
97
|
-
|
95
|
+
described_class.expects(:instances).returns [described_class.new({
|
98
96
|
:ensure => "1.2.5",
|
99
97
|
:name => "real_package",
|
100
98
|
:provider => :pip,
|
@@ -108,14 +106,14 @@ describe provider_class do
|
|
108
106
|
end
|
109
107
|
|
110
108
|
it "should return nil when the package is missing" do
|
111
|
-
|
109
|
+
described_class.expects(:instances).returns []
|
112
110
|
expect(@provider.query).to eq(nil)
|
113
111
|
end
|
114
112
|
|
115
113
|
it "should be case insensitive" do
|
116
114
|
@resource[:name] = "Real_Package"
|
117
115
|
|
118
|
-
|
116
|
+
described_class.expects(:instances).returns [described_class.new({
|
119
117
|
:ensure => "1.2.5",
|
120
118
|
:name => "real_package",
|
121
119
|
:provider => :pip,
|
@@ -127,16 +125,15 @@ describe provider_class do
|
|
127
125
|
:provider => :pip,
|
128
126
|
})
|
129
127
|
end
|
130
|
-
|
131
128
|
end
|
132
129
|
|
133
|
-
|
130
|
+
context "latest" do
|
134
131
|
context "with pip version < 1.5.4" do
|
135
132
|
before :each do
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
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")
|
140
137
|
end
|
141
138
|
|
142
139
|
it "should find a version number for new_pip_package" do
|
@@ -188,12 +185,11 @@ describe provider_class do
|
|
188
185
|
context "with pip version >= 1.5.4" do
|
189
186
|
# For Pip 1.5.4 and above, you can get a version list from CLI - which allows for native pip behavior
|
190
187
|
# with regards to custom repositories, proxies and the like
|
191
|
-
|
192
188
|
before :each do
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
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")
|
197
193
|
end
|
198
194
|
|
199
195
|
it "should find a version number for real_package" do
|
@@ -239,7 +235,7 @@ describe provider_class do
|
|
239
235
|
end
|
240
236
|
end
|
241
237
|
|
242
|
-
|
238
|
+
context "install" do
|
243
239
|
before do
|
244
240
|
@resource[:name] = "fake_package"
|
245
241
|
@url = "git+https://example.com/fake_package.git"
|
@@ -304,7 +300,7 @@ describe provider_class do
|
|
304
300
|
end
|
305
301
|
end
|
306
302
|
|
307
|
-
|
303
|
+
context "uninstall" do
|
308
304
|
it "should uninstall" do
|
309
305
|
@resource[:name] = "fake_package"
|
310
306
|
@provider.expects(:lazy_pip).
|
@@ -313,29 +309,29 @@ describe provider_class do
|
|
313
309
|
end
|
314
310
|
end
|
315
311
|
|
316
|
-
|
312
|
+
context "update" do
|
317
313
|
it "should just call install" do
|
318
314
|
@provider.expects(:install).returns(nil)
|
319
315
|
@provider.update
|
320
316
|
end
|
321
317
|
end
|
322
318
|
|
323
|
-
|
319
|
+
context "pip_version" do
|
324
320
|
it "should return nil on missing pip" do
|
325
|
-
|
326
|
-
expect(
|
321
|
+
described_class.stubs(:pip_cmd).returns(nil)
|
322
|
+
expect(described_class.pip_version).to eq(nil)
|
327
323
|
end
|
328
324
|
|
329
325
|
it "should look up version if pip is present" do
|
330
|
-
|
326
|
+
described_class.stubs(:pip_cmd).returns('/fake/bin/pip')
|
331
327
|
p = stub("process")
|
332
328
|
p.expects(:collect).yields('pip 8.0.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)')
|
333
|
-
|
334
|
-
expect(
|
329
|
+
described_class.expects(:execpipe).with(['/fake/bin/pip', '--version']).yields(p)
|
330
|
+
expect(described_class.pip_version).to eq('8.0.2')
|
335
331
|
end
|
336
332
|
end
|
337
333
|
|
338
|
-
|
334
|
+
context "lazy_pip" do
|
339
335
|
after(:each) do
|
340
336
|
Puppet::Type::Package::ProviderPip.instance_variable_set(:@confine_collection, nil)
|
341
337
|
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 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
|