puppet 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +20 -20
- data/Guardfile.example +76 -0
- data/LICENSE +189 -4
- data/README.md +3 -3
- data/Rakefile +5 -2
- data/ext/solaris/smf/svc-puppetd +8 -1
- data/ext/solaris/smf/svc-puppetmasterd +8 -1
- data/lib/puppet/application/apply.rb +100 -59
- data/lib/puppet/application/cert.rb +4 -114
- data/lib/puppet/application/device.rb +48 -32
- data/lib/puppet/application/script.rb +1 -1
- data/lib/puppet/application/ssl.rb +135 -51
- data/lib/puppet/application.rb +5 -0
- data/lib/puppet/configurer.rb +2 -3
- data/lib/puppet/defaults.rb +33 -49
- data/lib/puppet/etc.rb +20 -0
- data/lib/puppet/face/config.rb +3 -3
- data/lib/puppet/face/key.rb +1 -1
- data/lib/puppet/face/node/clean.rb +0 -1
- data/lib/puppet/feature/base.rb +1 -1
- data/lib/puppet/file_bucket/dipper.rb +1 -1
- data/lib/puppet/file_serving/fileset.rb +1 -1
- data/lib/puppet/functions/abs.rb +1 -1
- data/lib/puppet/functions/new.rb +1 -1
- data/lib/puppet/module/task.rb +29 -38
- data/lib/puppet/pal/catalog_compiler.rb +96 -0
- data/lib/puppet/pal/compiler.rb +221 -0
- data/lib/puppet/pal/function_signature.rb +52 -0
- data/lib/puppet/pal/json_catalog_encoder.rb +67 -0
- data/lib/puppet/pal/pal_api.rb +15 -0
- data/lib/puppet/pal/pal_impl.rb +523 -0
- data/lib/puppet/pal/plan_signature.rb +71 -0
- data/lib/puppet/pal/script_compiler.rb +71 -0
- data/lib/puppet/pal/task_signature.rb +58 -0
- data/lib/puppet/parser/catalog_compiler.rb +24 -0
- data/lib/puppet/parser/compiler.rb +3 -1
- data/lib/puppet/parser/functions/generate.rb +7 -6
- data/lib/puppet/plugins/configuration.rb +5 -1
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
- data/lib/puppet/pops/evaluator/deferred_resolver.rb +3 -0
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +5 -1
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -3
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +19 -10
- data/lib/puppet/pops/loader/task_instantiator.rb +13 -70
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
- data/lib/puppet/pops/parser/lexer2.rb +1 -1
- data/lib/puppet/pops/pcore.rb +10 -33
- data/lib/puppet/pops/serialization/to_data_converter.rb +9 -1
- data/lib/puppet/pops/serialization.rb +1 -0
- data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
- data/lib/puppet/pops/types/string_converter.rb +18 -4
- data/lib/puppet/pops/validation/checker4_0.rb +17 -2
- data/lib/puppet/provider/exec.rb +59 -57
- data/lib/puppet/provider/group/aix.rb +18 -2
- data/lib/puppet/provider/group/windows_adsi.rb +7 -3
- data/lib/puppet/provider/nameservice.rb +1 -25
- data/lib/puppet/provider/package/dnf.rb +2 -0
- data/lib/puppet/provider/package/pkgng.rb +37 -21
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/windows/exe_package.rb +16 -10
- 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/windows.rb +2 -2
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/parsedfile.rb +25 -4
- data/lib/puppet/provider/service/launchd.rb +19 -3
- data/lib/puppet/provider/service/smf.rb +54 -0
- data/lib/puppet/provider/service/systemd.rb +19 -0
- data/lib/puppet/provider/service/upstart.rb +1 -0
- data/lib/puppet/provider/service/windows.rb +22 -5
- data/lib/puppet/provider/user/aix.rb +48 -2
- data/lib/puppet/provider/user/useradd.rb +2 -10
- data/lib/puppet/provider/user/windows_adsi.rb +9 -1
- data/lib/puppet/resource/catalog.rb +1 -5
- data/lib/puppet/resource.rb +3 -1
- data/lib/puppet/ssl/host.rb +26 -16
- data/lib/puppet/syntax_checkers/epp.rb +34 -0
- data/lib/puppet/syntax_checkers/pp.rb +34 -0
- data/lib/puppet/transaction/event_manager.rb +13 -1
- data/lib/puppet/transaction/persistence.rb +1 -1
- data/lib/puppet/transaction/resource_harness.rb +3 -1
- data/lib/puppet/type/group.rb +29 -1
- data/lib/puppet/type/package.rb +5 -1
- data/lib/puppet/type/resources.rb +12 -2
- data/lib/puppet/type/schedule.rb +7 -0
- data/lib/puppet/type/service.rb +12 -0
- data/lib/puppet/type/user.rb +5 -2
- data/lib/puppet/type.rb +6 -0
- data/lib/puppet/util/command_line.rb +2 -3
- data/lib/puppet/util/execution.rb +15 -1
- data/lib/puppet/util/filetype.rb +56 -8
- data/lib/puppet/util/log/destinations.rb +3 -2
- data/lib/puppet/util/logging.rb +3 -2
- data/lib/puppet/util/posix.rb +15 -0
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/storage.rb +12 -0
- data/lib/puppet/util/windows/adsi.rb +79 -2
- data/lib/puppet/util/windows/api_types.rb +1 -1
- data/lib/puppet/util/windows/process.rb +23 -3
- data/lib/puppet/util/windows/registry.rb +29 -5
- data/lib/puppet/util/windows/security.rb +14 -0
- data/lib/puppet/util/windows/service.rb +294 -74
- data/lib/puppet/util/windows/user.rb +3 -5
- data/lib/puppet/util.rb +7 -3
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +1 -0
- data/lib/puppet_pal.rb +5 -1099
- data/locales/ja/puppet.po +952 -986
- data/locales/puppet.pot +592 -347
- data/man/man5/puppet.conf.5 +26 -31
- 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 +4 -4
- 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 +2 -2
- 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 +26 -3
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/bad_func_load.rb +11 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query +7 -1
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query.zsh +1 -0
- 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/application/apply_spec.rb +4 -1
- data/spec/integration/parser/collection_spec.rb +4 -8
- data/spec/integration/provider/service/windows_spec.rb +5 -5
- data/spec/integration/ssl/key_spec.rb +0 -4
- data/spec/integration/transaction_spec.rb +559 -0
- data/spec/integration/type/file_spec.rb +6 -6
- data/spec/integration/util/windows/registry_spec.rb +39 -0
- data/spec/integration/util/windows/security_spec.rb +10 -7
- data/spec/integration/util/windows/user_spec.rb +37 -17
- data/spec/lib/puppet/test_ca.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/agent_spec.rb +2 -2
- data/spec/unit/application/apply_spec.rb +55 -2
- data/spec/unit/application/device_spec.rb +10 -7
- data/spec/unit/application/face_base_spec.rb +1 -1
- data/spec/unit/application/lookup_spec.rb +2 -1
- data/spec/unit/application/ssl_spec.rb +178 -109
- data/spec/unit/application_spec.rb +29 -11
- data/spec/unit/configurer/downloader_spec.rb +1 -1
- data/spec/unit/configurer_spec.rb +16 -5
- data/spec/unit/etc_spec.rb +25 -0
- data/spec/unit/face/node_spec.rb +1 -3
- data/spec/unit/face/parser_spec.rb +15 -0
- data/spec/unit/file_serving/fileset_spec.rb +11 -11
- data/spec/unit/functions/logging_spec.rb +10 -3
- data/spec/unit/indirector/catalog/json_spec.rb +9 -3
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/network/http/connection_spec.rb +2 -2
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +36 -0
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +22 -4
- data/spec/unit/pops/loaders/loader_spec.rb +9 -17
- data/spec/unit/pops/loaders/loaders_spec.rb +48 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +7 -7
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +16 -0
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +9 -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 +25 -1
- data/spec/unit/pops/types/task_spec.rb +42 -116
- data/spec/unit/pops/validator/validator_spec.rb +24 -10
- data/spec/unit/provider/exec/posix_spec.rb +24 -0
- data/spec/unit/provider/group/aix_spec.rb +20 -6
- data/spec/unit/provider/group/ldap_spec.rb +22 -25
- data/spec/unit/provider/group/pw_spec.rb +7 -10
- data/spec/unit/provider/group/windows_adsi_spec.rb +42 -33
- 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 +38 -25
- 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 +32 -27
- 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/windows/exe_package_spec.rb +3 -3
- data/spec/unit/provider/package/windows_spec.rb +4 -4
- 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/launchd_spec.rb +19 -0
- 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 +39 -1
- data/spec/unit/provider/service/windows_spec.rb +39 -7
- data/spec/unit/provider/user/aix_spec.rb +43 -2
- 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/provider/user/useradd_spec.rb +2 -2
- data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
- data/spec/unit/puppet_pal_2pec.rb +6 -6
- data/spec/unit/puppet_pal_catalog_spec.rb +58 -0
- data/spec/unit/resource/catalog_spec.rb +2 -2
- data/spec/unit/resource_spec.rb +31 -0
- data/spec/unit/ssl/host_spec.rb +22 -1
- data/spec/unit/ssl/key_spec.rb +2 -4
- data/spec/unit/task_spec.rb +50 -5
- data/spec/unit/transaction/event_manager_spec.rb +12 -1
- data/spec/unit/transaction/persistence_spec.rb +4 -4
- data/spec/unit/transaction/resource_harness_spec.rb +18 -0
- data/spec/unit/type/group_spec.rb +11 -3
- data/spec/unit/type/resources_spec.rb +18 -0
- data/spec/unit/type/service_spec.rb +27 -1
- data/spec/unit/util/execution_spec.rb +77 -0
- data/spec/unit/util/filetype_spec.rb +13 -5
- data/spec/unit/util/log/destinations_spec.rb +10 -0
- data/spec/unit/util/logging_spec.rb +58 -41
- data/spec/unit/util/monkey_patches_spec.rb +18 -5
- data/spec/unit/util/posix_spec.rb +28 -0
- data/spec/unit/util/selinux_spec.rb +4 -0
- data/spec/unit/util/storage_spec.rb +107 -0
- data/spec/unit/util/suidmanager_spec.rb +1 -3
- data/spec/unit/util/windows/adsi_spec.rb +95 -0
- data/spec/unit/util/windows/service_spec.rb +377 -131
- metadata +24 -11
- data/ext/autotest/Rakefile +0 -8
- data/ext/autotest/config +0 -43
- data/ext/autotest/readme.rst +0 -16
- data/spec/fixtures/unit/provider/package/pkgng/pkg.info +0 -7
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +0 -1
- data/spec/watchr.rb +0 -137
|
@@ -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
|
-
info = File.read(my_fixture('pkg.
|
|
44
|
-
|
|
40
|
+
info = File.read(my_fixture('pkg.query'))
|
|
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,37 +115,41 @@ 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
|
-
|
|
129
|
-
|
|
125
|
+
pkg_query_zsh = File.read(my_fixture('pkg.query.zsh'))
|
|
126
|
+
described_class.stubs(:get_resource_info).with('zsh').returns(pkg_query_zsh)
|
|
127
|
+
described_class.prefetch({installed_name => installed_resource})
|
|
128
|
+
expect(installed_provider.query).to be >= {:version=>'5.0.2_1'}
|
|
130
129
|
end
|
|
131
130
|
|
|
132
131
|
it "should return nil if not present" do
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
described_class.stubs(:get_resource_info).with('bash').raises(Puppet::ExecutionFailure, 'An error occurred')
|
|
133
|
+
|
|
135
134
|
expect(provider.query).to equal(nil)
|
|
136
135
|
end
|
|
137
136
|
end
|
|
138
137
|
|
|
139
138
|
describe "latest" do
|
|
140
139
|
it "should retrieve the correct version of the latest package" do
|
|
141
|
-
|
|
140
|
+
described_class.prefetch( { installed_name => installed_resource })
|
|
142
141
|
expect(installed_provider.latest).not_to be_nil
|
|
143
142
|
end
|
|
144
143
|
|
|
145
144
|
it "should set latest to newer package version when available" do
|
|
146
|
-
instances =
|
|
145
|
+
instances = described_class.instances
|
|
147
146
|
curl = instances.find {|i| i.properties[:origin] == 'ftp/curl' }
|
|
148
147
|
expect(curl.properties[:latest]).to eq('7.33.0_2')
|
|
149
148
|
end
|
|
150
149
|
|
|
151
150
|
it "should call update to upgrade the version" do
|
|
151
|
+
described_class.stubs(:get_resource_info).with('ftp/curl').returns('curl 7.61.1 ftp/curl')
|
|
152
|
+
|
|
152
153
|
resource = Puppet::Type.type(:package).new(
|
|
153
154
|
:name => 'ftp/curl',
|
|
154
155
|
:provider => pkgng,
|
|
@@ -164,13 +165,17 @@ describe provider_class do
|
|
|
164
165
|
describe "get_latest_version" do
|
|
165
166
|
it "should rereturn nil when the current package is the latest" do
|
|
166
167
|
version_list = File.read(my_fixture('pkg.version'))
|
|
167
|
-
|
|
168
|
+
described_class.stubs(:get_version_list).returns(version_list)
|
|
169
|
+
nmap_latest_version = described_class.get_latest_version('security/nmap')
|
|
170
|
+
|
|
168
171
|
expect(nmap_latest_version).to be_nil
|
|
169
172
|
end
|
|
170
173
|
|
|
171
174
|
it "should match the package name exactly" do
|
|
172
175
|
version_list = File.read(my_fixture('pkg.version'))
|
|
173
|
-
|
|
176
|
+
described_class.stubs(:get_version_list).returns(version_list)
|
|
177
|
+
bash_comp_latest_version = described_class.get_latest_version('shells/bash-completion')
|
|
178
|
+
|
|
174
179
|
expect(bash_comp_latest_version).to eq('2.1_3')
|
|
175
180
|
end
|
|
176
181
|
end
|
|
@@ -179,7 +184,7 @@ describe provider_class do
|
|
|
179
184
|
context "on FreeBSD" do
|
|
180
185
|
it "should be the default provider" do
|
|
181
186
|
Facter.expects(:value).with(:operatingsystem).at_least_once.returns :freebsd
|
|
182
|
-
expect(
|
|
187
|
+
expect(described_class).to be_default
|
|
183
188
|
end
|
|
184
189
|
end
|
|
185
190
|
end
|
|
@@ -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(:puppet_gem) do
|
|
7
4
|
let(:resource) do
|
|
8
5
|
Puppet::Type.type(:package).new(
|
|
9
6
|
:name => 'myresource',
|
|
@@ -12,7 +9,7 @@ describe provider_class do
|
|
|
12
9
|
end
|
|
13
10
|
|
|
14
11
|
let(:provider) do
|
|
15
|
-
provider =
|
|
12
|
+
provider = described_class.new
|
|
16
13
|
provider.resource = resource
|
|
17
14
|
provider
|
|
18
15
|
end
|
|
@@ -27,9 +24,9 @@ describe provider_class do
|
|
|
27
24
|
resource.provider = provider
|
|
28
25
|
end
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
context "when installing" do
|
|
31
28
|
it "should use the path to the gem" do
|
|
32
|
-
|
|
29
|
+
described_class.expects(:which).with(puppet_gem).returns(puppet_gem)
|
|
33
30
|
provider.expects(:execute).with { |args| args[0] == puppet_gem }.returns ''
|
|
34
31
|
provider.install
|
|
35
32
|
end
|
|
@@ -46,9 +43,9 @@ describe provider_class do
|
|
|
46
43
|
end
|
|
47
44
|
end
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
context "when uninstalling" do
|
|
50
47
|
it "should use the path to the gem" do
|
|
51
|
-
|
|
48
|
+
described_class.expects(:which).with(puppet_gem).returns(puppet_gem)
|
|
52
49
|
provider.expects(:execute).with { |args| args[0] == puppet_gem }.returns ''
|
|
53
50
|
provider.install
|
|
54
51
|
end
|
|
@@ -2,17 +2,14 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
# Note that much of the functionality of the tdnf provider is already tested with yum provider tests,
|
|
4
4
|
# as yum is the parent provider, via dnf
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
context 'default' do
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
describe Puppet::Type.type(:package).provider(:tdnf) do
|
|
6
|
+
it_behaves_like 'RHEL package provider', described_class, 'tdnf'
|
|
7
|
+
|
|
8
|
+
context 'default' do
|
|
9
|
+
it 'should be the default provider on PhotonOS' do
|
|
10
|
+
Facter.stubs(:value).with(:osfamily).returns(:redhat)
|
|
11
|
+
Facter.stubs(:value).with(:operatingsystem).returns("PhotonOS")
|
|
12
|
+
expect(described_class).to be_default
|
|
13
|
+
end
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
|
-
|
|
16
|
-
describe provider_class do
|
|
17
|
-
it_behaves_like 'RHEL package provider', provider_class, 'tdnf'
|
|
18
|
-
end
|
|
@@ -76,7 +76,7 @@ describe Puppet::Provider::Package::Windows::ExePackage do
|
|
|
76
76
|
it 'should install using the source' do
|
|
77
77
|
cmd = subject.install_command({:source => source})
|
|
78
78
|
|
|
79
|
-
expect(cmd).to eq(
|
|
79
|
+
expect(cmd).to eq(source)
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
|
@@ -84,7 +84,7 @@ describe Puppet::Provider::Package::Windows::ExePackage do
|
|
|
84
84
|
['C:\uninstall.exe', 'C:\Program Files\uninstall.exe'].each do |exe|
|
|
85
85
|
it "should quote #{exe}" do
|
|
86
86
|
expect(subject.new(name, version, exe).uninstall_command).to eq(
|
|
87
|
-
|
|
87
|
+
"\"#{exe}\""
|
|
88
88
|
)
|
|
89
89
|
end
|
|
90
90
|
end
|
|
@@ -92,7 +92,7 @@ describe Puppet::Provider::Package::Windows::ExePackage do
|
|
|
92
92
|
['"C:\Program Files\uninstall.exe"', '"C:\Program Files (x86)\Git\unins000.exe" /SILENT"'].each do |exe|
|
|
93
93
|
it "should not quote #{exe}" do
|
|
94
94
|
expect(subject.new(name, version, exe).uninstall_command).to eq(
|
|
95
|
-
|
|
95
|
+
exe
|
|
96
96
|
)
|
|
97
97
|
end
|
|
98
98
|
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#! /usr/bin/env ruby
|
|
2
2
|
require 'spec_helper'
|
|
3
3
|
|
|
4
|
-
describe Puppet::Type.type(:package).provider(:windows) do
|
|
4
|
+
describe Puppet::Type.type(:package).provider(:windows), :if => Puppet.features.microsoft_windows? do
|
|
5
5
|
let (:name) { 'mysql-5.1.58-win-x64' }
|
|
6
|
-
let (:source) { 'E:\mysql-5.1.58-win-x64.msi' }
|
|
6
|
+
let (:source) { 'E:\Rando\Directory\mysql-5.1.58-win-x64.msi' }
|
|
7
7
|
let (:resource) { Puppet::Type.type(:package).new(:name => name, :provider => :windows, :source => source) }
|
|
8
8
|
let (:provider) { resource.provider }
|
|
9
|
-
let (:execute_options) do {:failonfail => false, :combine => true} end
|
|
9
|
+
let (:execute_options) do {:failonfail => false, :combine => true, :suppress_window => true} end
|
|
10
10
|
|
|
11
11
|
before :each do
|
|
12
12
|
# make sure we never try to execute anything
|
|
@@ -86,7 +86,7 @@ describe Puppet::Type.type(:package).provider(:windows) do
|
|
|
86
86
|
context '#install' do
|
|
87
87
|
let(:command) { 'blarg.exe /S' }
|
|
88
88
|
let(:klass) { mock('installer', :install_command => ['blarg.exe', '/S'] ) }
|
|
89
|
-
|
|
89
|
+
let(:execute_options) do {:failonfail => false, :combine => true, :cwd => 'E:\Rando\Directory', :suppress_window => true} end
|
|
90
90
|
before :each do
|
|
91
91
|
Puppet::Provider::Package::Windows::Package.expects(:installer_class).returns(klass)
|
|
92
92
|
end
|