puppet 5.5.16-x64-mingw32 → 5.5.17-x64-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/CODEOWNERS +9 -9
- data/Gemfile.lock +18 -18
- data/ext/project_data.yaml +2 -2
- data/install.rb +3 -21
- data/lib/puppet/application/agent.rb +12 -0
- data/lib/puppet/application/device.rb +4 -4
- data/lib/puppet/application/resource.rb +4 -4
- data/lib/puppet/defaults.rb +4 -0
- data/lib/puppet/face/config.rb +10 -48
- data/lib/puppet/face/facts.rb +1 -1
- data/lib/puppet/face/plugin.rb +9 -2
- data/lib/puppet/module_tool/tar/mini.rb +11 -1
- data/lib/puppet/network/http/factory.rb +1 -11
- data/lib/puppet/parameter.rb +8 -0
- data/lib/puppet/provider/file/posix.rb +5 -0
- data/lib/puppet/provider/nameservice.rb +10 -3
- data/lib/puppet/provider/package/dnf.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +51 -13
- data/lib/puppet/provider/package/yum.rb +8 -4
- data/lib/puppet/provider/service/launchd.rb +20 -5
- data/lib/puppet/provider/service/systemd.rb +4 -9
- data/lib/puppet/provider/service/windows.rb +8 -0
- data/lib/puppet/provider/user/pw.rb +12 -3
- data/lib/puppet/provider/user/user_role_add.rb +4 -0
- data/lib/puppet/provider/user/useradd.rb +23 -7
- data/lib/puppet/resource.rb +17 -0
- data/lib/puppet/settings.rb +40 -0
- data/lib/puppet/type.rb +7 -0
- data/lib/puppet/type/exec.rb +14 -6
- data/lib/puppet/type/package.rb +10 -0
- data/lib/puppet/type/service.rb +7 -2
- data/lib/puppet/type/user.rb +1 -15
- data/lib/puppet/type/yumrepo.rb +3 -7
- data/lib/puppet/util/execution.rb +4 -3
- data/lib/puppet/util/http_proxy.rb +16 -2
- data/lib/puppet/util/selinux.rb +5 -1
- data/lib/puppet/util/windows/security.rb +2 -0
- data/lib/puppet/util/windows/service.rb +149 -4
- data/lib/puppet/util/windows/sid.rb +1 -0
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +189 -193
- data/man/man5/puppet.conf.5 +10 -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 +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-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/integration/provider/service/systemd_spec.rb +8 -5
- data/spec/integration/type/file_spec.rb +28 -0
- data/spec/integration/util/execution_spec.rb +27 -0
- data/spec/unit/application/agent_spec.rb +18 -0
- data/spec/unit/application/device_spec.rb +1 -1
- data/spec/unit/face/facts_spec.rb +9 -0
- data/spec/unit/face/plugin_spec.rb +8 -0
- data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
- data/spec/unit/network/http/api/indirected_routes_spec.rb +26 -10
- data/spec/unit/network/http/factory_spec.rb +27 -5
- data/spec/unit/pops/validator/validator_spec.rb +7 -0
- data/spec/unit/provider/package/aptrpm_spec.rb +1 -1
- data/spec/unit/provider/package/dnf_spec.rb +7 -0
- data/spec/unit/provider/package/rpm_spec.rb +150 -16
- data/spec/unit/provider/package/yum_spec.rb +7 -0
- data/spec/unit/provider/service/launchd_spec.rb +28 -0
- data/spec/unit/provider/service/windows_spec.rb +20 -0
- data/spec/unit/provider/user/pw_spec.rb +37 -0
- data/spec/unit/provider/user/useradd_spec.rb +42 -0
- data/spec/unit/resource_spec.rb +26 -1
- data/spec/unit/transaction_spec.rb +18 -0
- data/spec/unit/type/exec_spec.rb +9 -0
- data/spec/unit/type/file/source_spec.rb +4 -4
- data/spec/unit/type/schedule_spec.rb +3 -1
- data/spec/unit/type/service_spec.rb +16 -0
- data/spec/unit/type/user_spec.rb +13 -13
- data/spec/unit/type/yumrepo_spec.rb +30 -0
- data/spec/unit/type_spec.rb +40 -0
- data/spec/unit/util/http_proxy_spec.rb +24 -1
- data/spec/unit/util/log_spec.rb +27 -1
- data/spec/unit/util/windows/service_spec.rb +9 -0
- metadata +5 -9
- data/ext/windows/eventlog/Rakefile +0 -32
- data/ext/windows/eventlog/puppetres.dll +0 -0
- data/ext/windows/eventlog/puppetres.mc +0 -18
@@ -481,7 +481,7 @@ describe Puppet::Application::Device do
|
|
481
481
|
allow(@device.options).to receive(:[]).with(:to_yaml).and_return(true)
|
482
482
|
allow(@device.command_line).to receive(:args).and_return(['user'])
|
483
483
|
expect(Puppet::Resource.indirection).to receive(:search).with('user/', {}).and_return(resources)
|
484
|
-
expect(@device).to receive(:puts).with("
|
484
|
+
expect(@device).to receive(:puts).with("---\nuser:\n title: {}\n")
|
485
485
|
expect { @device.main }.to exit_with 0
|
486
486
|
end
|
487
487
|
|
@@ -45,6 +45,15 @@ CONF
|
|
45
45
|
subject.upload
|
46
46
|
end
|
47
47
|
|
48
|
+
it "passes the current environment" do
|
49
|
+
env = Puppet::Node::Environment.remote('qa')
|
50
|
+
expect(model.indirection).to receive(:save).with(anything, nil, :environment => env)
|
51
|
+
|
52
|
+
Puppet.override(:current_environment => env) do
|
53
|
+
subject.upload
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
48
57
|
it "uses settings from the agent section of puppet.conf" do
|
49
58
|
expect(facter_terminus).to receive(:find).with(have_attributes(key: 'puppet.node.test')).and_return(test_data)
|
50
59
|
|
@@ -50,6 +50,14 @@ describe Puppet::Face[:plugin, :current] do
|
|
50
50
|
expect(receive_count).to eq(3)
|
51
51
|
expect(render(result)).to eq('Downloaded these plugins: /a, /b, /c')
|
52
52
|
end
|
53
|
+
|
54
|
+
it "uses persistent HTTP pool" do
|
55
|
+
allow_any_instance_of(Puppet::Configurer::Downloader).to receive(:evaluate) do
|
56
|
+
expect(Puppet.lookup(:http_pool)).to be_instance_of(Puppet::Network::HTTP::Pool)
|
57
|
+
end.and_return([])
|
58
|
+
|
59
|
+
pluginface.download
|
60
|
+
end
|
53
61
|
end
|
54
62
|
|
55
63
|
context "download when server_agent_version is 5.3.3" do
|
@@ -82,7 +82,7 @@ describe Puppet::ModuleTool::Tar::Mini, :if => (Puppet.features.minitar? and Pup
|
|
82
82
|
expect(Zlib::GzipReader).to receive(:open).with(sourcefile).and_yield(reader)
|
83
83
|
expect(minitar).to receive(:find_valid_files).with(reader).and_return([name])
|
84
84
|
entry = MockFileStatEntry.new(mode)
|
85
|
-
expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, [name]).
|
85
|
+
expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, [name], :fsync => false).
|
86
86
|
and_yield(type, name, {:entry => entry})
|
87
87
|
entry
|
88
88
|
end
|
@@ -38,19 +38,27 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should fail if there is no environment specified" do
|
41
|
-
expect
|
41
|
+
expect {
|
42
|
+
handler.uri2indirection("GET", "#{master_url_prefix}/node/bar", {})
|
43
|
+
}.to raise_error(bad_request_error)
|
42
44
|
end
|
43
45
|
|
44
46
|
it "should fail if the environment is not alphanumeric" do
|
45
|
-
expect
|
47
|
+
expect {
|
48
|
+
handler.uri2indirection("GET", "#{master_url_prefix}/node/bar", {:environment => "env ness"})
|
49
|
+
}.to raise_error(bad_request_error)
|
46
50
|
end
|
47
51
|
|
48
52
|
it "should fail if the indirection does not match the prefix" do
|
49
|
-
expect
|
53
|
+
expect {
|
54
|
+
handler.uri2indirection("GET", "#{master_url_prefix}/certificate/foo", params)
|
55
|
+
}.to raise_error(bad_request_error)
|
50
56
|
end
|
51
57
|
|
52
58
|
it "should fail if the indirection does not have the correct version" do
|
53
|
-
expect
|
59
|
+
expect {
|
60
|
+
handler.uri2indirection("GET", "#{Puppet::Network::HTTP::CA_URL_PREFIX}/v3/certificate/foo", params)
|
61
|
+
}.to raise_error(bad_request_error)
|
54
62
|
end
|
55
63
|
|
56
64
|
it "should not pass a buck_path parameter through (See Bugs #13553, #13518, #13511)" do
|
@@ -74,7 +82,9 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
|
|
74
82
|
end
|
75
83
|
|
76
84
|
it "should fail if the indirection name is not alphanumeric" do
|
77
|
-
expect
|
85
|
+
expect {
|
86
|
+
handler.uri2indirection("GET", "#{master_url_prefix}/foo ness/bar", params)
|
87
|
+
}.to raise_error(bad_request_error)
|
78
88
|
end
|
79
89
|
|
80
90
|
it "should use the remainder of the URI as the indirection key" do
|
@@ -86,7 +96,9 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
|
|
86
96
|
end
|
87
97
|
|
88
98
|
it "should fail if no indirection key is specified" do
|
89
|
-
expect
|
99
|
+
expect {
|
100
|
+
handler.uri2indirection("GET", "#{master_url_prefix}/node", params)
|
101
|
+
}.to raise_error(bad_request_error)
|
90
102
|
end
|
91
103
|
|
92
104
|
it "should choose 'find' as the indirection method if the http method is a GET and the indirection name is singular" do
|
@@ -126,7 +138,9 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
|
|
126
138
|
end
|
127
139
|
|
128
140
|
it "should fail if an indirection method cannot be picked" do
|
129
|
-
expect
|
141
|
+
expect {
|
142
|
+
handler.uri2indirection("UPDATE", "#{master_url_prefix}/node/bar", params)
|
143
|
+
}.to raise_error(method_not_allowed_error)
|
130
144
|
end
|
131
145
|
|
132
146
|
it "should not URI unescape the indirection key" do
|
@@ -146,9 +160,11 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
|
|
146
160
|
expect(handler).to receive(:check_authorization) do |_, _, arg|
|
147
161
|
expect(arg).not_to include(:environment)
|
148
162
|
end
|
149
|
-
expect
|
150
|
-
|
151
|
-
|
163
|
+
expect {
|
164
|
+
handler.uri2indirection("GET",
|
165
|
+
"#{master_url_prefix}/node/bar",
|
166
|
+
{:environment => 'bogus'})
|
167
|
+
}.to raise_error(not_found_error)
|
152
168
|
end
|
153
169
|
|
154
170
|
it "should not URI unescape the indirection key as passed through to a call to check_authorization" do
|
@@ -42,10 +42,11 @@ describe Puppet::Network::HTTP::Factory do
|
|
42
42
|
context "proxy settings" do
|
43
43
|
let(:proxy_host) { 'myhost' }
|
44
44
|
let(:proxy_port) { 432 }
|
45
|
+
let(:proxy_user) { 'mo' }
|
46
|
+
let(:proxy_pass) { 'password' }
|
45
47
|
|
46
|
-
it "should not set a proxy if the
|
48
|
+
it "should not set a proxy if the http_proxy_host setting is 'none'" do
|
47
49
|
Puppet[:http_proxy_host] = 'none'
|
48
|
-
expect(Puppet::Util::HttpProxy).to receive(:no_proxy?).and_return(false)
|
49
50
|
conn = create_connection(site)
|
50
51
|
|
51
52
|
expect(conn.proxy_address).to be_nil
|
@@ -54,7 +55,18 @@ describe Puppet::Network::HTTP::Factory do
|
|
54
55
|
it 'should not set a proxy if a no_proxy env var matches the destination' do
|
55
56
|
Puppet[:http_proxy_host] = proxy_host
|
56
57
|
Puppet[:http_proxy_port] = proxy_port
|
57
|
-
|
58
|
+
Puppet::Util.withenv('NO_PROXY' => site.host) do
|
59
|
+
conn = create_connection(site)
|
60
|
+
|
61
|
+
expect(conn.proxy_address).to be_nil
|
62
|
+
expect(conn.proxy_port).to be_nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should not set a proxy if the no_proxy setting matches the destination' do
|
67
|
+
Puppet[:http_proxy_host] = proxy_host
|
68
|
+
Puppet[:http_proxy_port] = proxy_port
|
69
|
+
Puppet[:no_proxy] = site.host
|
58
70
|
conn = create_connection(site)
|
59
71
|
|
60
72
|
expect(conn.proxy_address).to be_nil
|
@@ -63,7 +75,6 @@ describe Puppet::Network::HTTP::Factory do
|
|
63
75
|
|
64
76
|
it 'sets proxy_address' do
|
65
77
|
Puppet[:http_proxy_host] = proxy_host
|
66
|
-
expect(Puppet::Util::HttpProxy).to receive(:no_proxy?).and_return(false)
|
67
78
|
conn = create_connection(site)
|
68
79
|
|
69
80
|
expect(conn.proxy_address).to eq(proxy_host)
|
@@ -72,11 +83,22 @@ describe Puppet::Network::HTTP::Factory do
|
|
72
83
|
it 'sets proxy address and port' do
|
73
84
|
Puppet[:http_proxy_host] = proxy_host
|
74
85
|
Puppet[:http_proxy_port] = proxy_port
|
75
|
-
expect(Puppet::Util::HttpProxy).to receive(:no_proxy?).and_return(false)
|
76
86
|
conn = create_connection(site)
|
77
87
|
|
78
88
|
expect(conn.proxy_port).to eq(proxy_port)
|
79
89
|
end
|
90
|
+
|
91
|
+
it 'sets proxy user and password' do
|
92
|
+
Puppet[:http_proxy_host] = proxy_host
|
93
|
+
Puppet[:http_proxy_port] = proxy_port
|
94
|
+
Puppet[:http_proxy_user] = proxy_user
|
95
|
+
Puppet[:http_proxy_password] = proxy_pass
|
96
|
+
|
97
|
+
conn = create_connection(site)
|
98
|
+
|
99
|
+
expect(conn.proxy_user).to eq(proxy_user)
|
100
|
+
expect(conn.proxy_pass).to eq(proxy_pass)
|
101
|
+
end
|
80
102
|
end
|
81
103
|
|
82
104
|
context 'socket timeouts' do
|
@@ -599,6 +599,13 @@ describe "validating 4x" do
|
|
599
599
|
end
|
600
600
|
end
|
601
601
|
|
602
|
+
context 'for hash keys' do
|
603
|
+
it "should not allow reassignment of hash keys" do
|
604
|
+
source = "$my_hash = {'one' => '1', 'two' => '2' }; $my_hash['one']='1.5'"
|
605
|
+
expect(validate(parse(source))).to have_issue(Puppet::Pops::Issues::ILLEGAL_INDEXED_ASSIGNMENT)
|
606
|
+
end
|
607
|
+
end
|
608
|
+
|
602
609
|
context 'for parameter names' do
|
603
610
|
['class', 'define'].each do |word|
|
604
611
|
it "should require that #{word} parameter names are unique" do
|
@@ -16,7 +16,7 @@ describe Puppet::Type.type(:package).provider(:aptrpm) do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def rpm_args
|
19
|
-
['-q', 'faff', '--nosignature', '--nodigest', '--qf', "
|
19
|
+
['-q', 'faff', '--nosignature', '--nodigest', '--qf', "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\\n"]
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should report purged packages" do
|
@@ -37,5 +37,12 @@ describe Puppet::Type.type(:package).provider(:dnf) do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
describe 'provider features' do
|
41
|
+
it { is_expected.to be_versionable }
|
42
|
+
it { is_expected.to be_install_options }
|
43
|
+
it { is_expected.to be_virtual_packages }
|
44
|
+
it { is_expected.to be_install_only }
|
45
|
+
end
|
46
|
+
|
40
47
|
it_behaves_like 'RHEL package provider', described_class, 'dnf'
|
41
48
|
end
|
@@ -9,6 +9,8 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
9
9
|
myresource 0 1.2.3.4 5.el4 noarch
|
10
10
|
mysummaryless 0 1.2.3.4 5.el4 noarch
|
11
11
|
tomcat 1 1.2.3.4 5.el4 x86_64
|
12
|
+
kernel 1 1.2.3.4 5.el4 x86_64
|
13
|
+
kernel 1 1.2.3.6 5.el4 x86_64
|
12
14
|
'
|
13
15
|
RPM_OUTPUT
|
14
16
|
end
|
@@ -57,7 +59,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
57
59
|
describe "with a modern version of RPM" do
|
58
60
|
it "includes all the modern flags" do
|
59
61
|
expect(Puppet::Util::Execution).to receive(:execpipe)
|
60
|
-
.with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}'")
|
62
|
+
.with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}' | sort")
|
61
63
|
.and_yield(packages)
|
62
64
|
|
63
65
|
described_class.instances
|
@@ -69,7 +71,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
69
71
|
|
70
72
|
it "excludes the --nosignature flag" do
|
71
73
|
expect(Puppet::Util::Execution).to receive(:execpipe)
|
72
|
-
.with("/bin/rpm -qa --nodigest --qf '#{nevra_format}'")
|
74
|
+
.with("/bin/rpm -qa --nodigest --qf '#{nevra_format}' | sort")
|
73
75
|
.and_yield(packages)
|
74
76
|
|
75
77
|
described_class.instances
|
@@ -81,7 +83,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
81
83
|
|
82
84
|
it "excludes the --nodigest flag" do
|
83
85
|
expect(Puppet::Util::Execution).to receive(:execpipe)
|
84
|
-
.with("/bin/rpm -qa --qf '#{nevra_format}'")
|
86
|
+
.with("/bin/rpm -qa --qf '#{nevra_format}' | sort")
|
85
87
|
.and_yield(packages)
|
86
88
|
|
87
89
|
described_class.instances
|
@@ -90,7 +92,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
90
92
|
|
91
93
|
it "returns an array of packages" do
|
92
94
|
expect(Puppet::Util::Execution).to receive(:execpipe)
|
93
|
-
.with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}'")
|
95
|
+
.with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}' | sort")
|
94
96
|
.and_yield(packages)
|
95
97
|
|
96
98
|
installed_packages = described_class.instances
|
@@ -161,6 +163,17 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
161
163
|
:ensure => "1:1.2.3.4-5.el4",
|
162
164
|
}
|
163
165
|
)
|
166
|
+
expect(installed_packages[6].properties).to eq(
|
167
|
+
{
|
168
|
+
:provider => :rpm,
|
169
|
+
:name => "kernel",
|
170
|
+
:epoch => "1",
|
171
|
+
:version => "1.2.3.4",
|
172
|
+
:release => "5.el4",
|
173
|
+
:arch => "x86_64",
|
174
|
+
:ensure => "1:1.2.3.4-5.el4; 1:1.2.3.6-5.el4",
|
175
|
+
}
|
176
|
+
)
|
164
177
|
end
|
165
178
|
end
|
166
179
|
|
@@ -218,7 +231,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
218
231
|
it "retrieves version string after querying rpm for version from source file" do
|
219
232
|
expect(resource).to receive(:[]).with(:source).and_return('source-string')
|
220
233
|
expect(Puppet::Util::Execution).to receive(:execute)
|
221
|
-
.with(["/bin/rpm", "-q", "--qf", "
|
234
|
+
.with(["/bin/rpm", "-q", "--qf", "#{nevra_format}", "-p", "source-string"])
|
222
235
|
.and_return(Puppet::Util::Execution::ProcessOutput.new("myresource 0 1.2.3.4 5.el4 noarch\n", 0))
|
223
236
|
expect(provider.latest).to eq("1.2.3.4-5.el4")
|
224
237
|
end
|
@@ -226,7 +239,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
226
239
|
it "raises an error if the rpm command fails" do
|
227
240
|
expect(resource).to receive(:[]).with(:source).and_return('source-string')
|
228
241
|
expect(Puppet::Util::Execution).to receive(:execute)
|
229
|
-
.with(["/bin/rpm", "-q", "--qf", "
|
242
|
+
.with(["/bin/rpm", "-q", "--qf", "#{nevra_format}", "-p", "source-string"])
|
230
243
|
.and_raise(Puppet::ExecutionFailure, 'rpm command failed')
|
231
244
|
|
232
245
|
expect {
|
@@ -248,7 +261,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
248
261
|
|
249
262
|
before(:each) do
|
250
263
|
expect(Puppet::Util::Execution).to receive(:execute)
|
251
|
-
.with(["/bin/rpm", "-q", resource_name, '', '', '--qf', "
|
264
|
+
.with(["/bin/rpm", "-q", resource_name, '', '', '--qf', "#{nevra_format}"], execute_options)
|
252
265
|
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
253
266
|
end
|
254
267
|
|
@@ -266,7 +279,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
266
279
|
|
267
280
|
before(:each) do
|
268
281
|
expect(Puppet::Util::Execution).to receive(:execute)
|
269
|
-
.with(["/bin/rpm", "-q", resource_name, '--nosignature', '--nodigest', "--qf", "
|
282
|
+
.with(["/bin/rpm", "-q", resource_name, '--nosignature', '--nodigest', "--qf", "#{nevra_format}"], execute_options)
|
270
283
|
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
271
284
|
end
|
272
285
|
|
@@ -290,7 +303,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
290
303
|
|
291
304
|
before(:each) do
|
292
305
|
expect(Puppet::Util::Execution).to receive(:execute)
|
293
|
-
.with(["/bin/rpm", "-q", "#{resource_name}.noarch", '--nosignature', '--nodigest', "--qf", "
|
306
|
+
.with(["/bin/rpm", "-q", "#{resource_name}.noarch", '--nosignature', '--nodigest', "--qf", "#{nevra_format}"], execute_options)
|
294
307
|
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
295
308
|
end
|
296
309
|
|
@@ -312,7 +325,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
312
325
|
|
313
326
|
before(:each) do
|
314
327
|
expect(Puppet::Util::Execution).to receive(:execute)
|
315
|
-
.with(["/bin/rpm", "-q", "#{resource_name}-1.2.3.4-5.el4", '--nosignature', '--nodigest', "--qf", "
|
328
|
+
.with(["/bin/rpm", "-q", "#{resource_name}-1.2.3.4-5.el4", '--nosignature', '--nodigest', "--qf", "#{nevra_format}"], execute_options)
|
316
329
|
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
317
330
|
end
|
318
331
|
|
@@ -334,7 +347,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
334
347
|
|
335
348
|
before(:each) do
|
336
349
|
expect(Puppet::Util::Execution).to receive(:execute)
|
337
|
-
.with(["/bin/rpm", "-q", "#{resource_name}-1.2.3.4", '--nosignature', '--nodigest', "--qf", "
|
350
|
+
.with(["/bin/rpm", "-q", "#{resource_name}-1.2.3.4", '--nosignature', '--nodigest', "--qf", "#{nevra_format}"], execute_options)
|
338
351
|
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
339
352
|
end
|
340
353
|
|
@@ -358,7 +371,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
358
371
|
|
359
372
|
before(:each) do
|
360
373
|
expect(Puppet::Util::Execution).to receive(:execute)
|
361
|
-
.with(["/bin/rpm", "-q", resource_name, '--nosignature', '--nodigest', "--qf", "
|
374
|
+
.with(["/bin/rpm", "-q", resource_name, '--nosignature', '--nodigest', "--qf", "#{nevra_format}"], execute_options)
|
362
375
|
.and_return(Puppet::Util::Execution::ProcessOutput.new("#{resource_name} 0 1.2.3.4 5.el4 noarch\n", 0))
|
363
376
|
end
|
364
377
|
|
@@ -374,7 +387,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
374
387
|
def parser_test(rpm_output_string, gold_hash, number_of_debug_logs = 0)
|
375
388
|
expect(Puppet).to receive(:debug).exactly(number_of_debug_logs).times()
|
376
389
|
expect(Puppet::Util::Execution).to receive(:execute)
|
377
|
-
.with(["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "
|
390
|
+
.with(["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "#{nevra_format}"], execute_options)
|
378
391
|
.and_return(Puppet::Util::Execution::ProcessOutput.new(rpm_output_string, 0))
|
379
392
|
expect(provider.query).to eq(gold_hash)
|
380
393
|
end
|
@@ -413,7 +426,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
413
426
|
describe "when the package is not found" do
|
414
427
|
before do
|
415
428
|
expect(Puppet).not_to receive(:debug)
|
416
|
-
expected_args = ["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "
|
429
|
+
expected_args = ["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "#{nevra_format}"]
|
417
430
|
expect(Puppet::Util::Execution).to receive(:execute)
|
418
431
|
.with(expected_args, execute_options)
|
419
432
|
.and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not installed"))
|
@@ -426,7 +439,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
426
439
|
|
427
440
|
it "does not log or fail if allow_virtual is true" do
|
428
441
|
resource[:allow_virtual] = true
|
429
|
-
expected_args = ['/bin/rpm', '-q', resource_name, '--nosignature', '--nodigest', '--qf', "
|
442
|
+
expected_args = ['/bin/rpm', '-q', resource_name, '--nosignature', '--nodigest', '--qf', "#{nevra_format}", '--whatprovides']
|
430
443
|
expect(Puppet::Util::Execution).to receive(:execute)
|
431
444
|
.with(expected_args, execute_options)
|
432
445
|
.and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not provided"))
|
@@ -436,7 +449,7 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
436
449
|
|
437
450
|
it "parses virtual package" do
|
438
451
|
provider.resource[:allow_virtual] = true
|
439
|
-
expected_args = ["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "
|
452
|
+
expected_args = ["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", "#{nevra_format}"]
|
440
453
|
expect(Puppet::Util::Execution).to receive(:execute)
|
441
454
|
.with(expected_args, execute_options)
|
442
455
|
.and_raise(Puppet::ExecutionFailure.new("package #{resource_name} is not installed"))
|
@@ -749,4 +762,125 @@ describe Puppet::Type.type(:package).provider(:rpm) do
|
|
749
762
|
provider.compare_values('s1', 's2')
|
750
763
|
end
|
751
764
|
end
|
765
|
+
|
766
|
+
|
767
|
+
describe 'insync?' do
|
768
|
+
context 'for multiple versions' do
|
769
|
+
let(:is) { '1:1.2.3.4-5.el4; 1:5.6.7.8-5.el4' }
|
770
|
+
it 'returns true if there is match and feature is enabled' do
|
771
|
+
resource[:install_only] = true
|
772
|
+
resource[:ensure] = '1:1.2.3.4-5.el4'
|
773
|
+
expect(provider).to be_insync(is)
|
774
|
+
end
|
775
|
+
it 'returns false if there is match and feature is not enabled' do
|
776
|
+
resource[:ensure] = '1:1.2.3.4-5.el4'
|
777
|
+
expect(provider).to_not be_insync(is)
|
778
|
+
end
|
779
|
+
it 'returns false if no match and feature is enabled' do
|
780
|
+
resource[:install_only] = true
|
781
|
+
resource[:ensure] = '1:1.2.3.6-5.el4'
|
782
|
+
expect(provider).to_not be_insync(is)
|
783
|
+
end
|
784
|
+
it 'returns false if no match and feature is not enabled' do
|
785
|
+
resource[:ensure] = '1:1.2.3.6-5.el4'
|
786
|
+
expect(provider).to_not be_insync(is)
|
787
|
+
end
|
788
|
+
end
|
789
|
+
context 'for simple versions' do
|
790
|
+
let(:is) { '1:1.2.3.4-5.el4' }
|
791
|
+
it 'returns true if there is match and feature is enabled' do
|
792
|
+
resource[:install_only] = true
|
793
|
+
resource[:ensure] = '1:1.2.3.4-5.el4'
|
794
|
+
expect(provider).to be_insync(is)
|
795
|
+
end
|
796
|
+
it 'returns true if there is match and feature is not enabled' do
|
797
|
+
resource[:ensure] = '1:1.2.3.4-5.el4'
|
798
|
+
expect(provider).to be_insync(is)
|
799
|
+
end
|
800
|
+
it 'returns false if no match and feature is enabled' do
|
801
|
+
resource[:install_only] = true
|
802
|
+
resource[:ensure] = '1:1.2.3.6-5.el4'
|
803
|
+
expect(provider).to_not be_insync(is)
|
804
|
+
end
|
805
|
+
it 'returns false if no match and feature is not enabled' do
|
806
|
+
resource[:ensure] = '1:1.2.3.6-5.el4'
|
807
|
+
expect(provider).to_not be_insync(is)
|
808
|
+
end
|
809
|
+
end
|
810
|
+
end
|
811
|
+
|
812
|
+
describe 'rpm multiversion to hash' do
|
813
|
+
it 'should return empty hash for empty imput' do
|
814
|
+
package_hash = described_class.nevra_to_multiversion_hash('')
|
815
|
+
expect(package_hash).to eq({})
|
816
|
+
end
|
817
|
+
|
818
|
+
it 'should return package hash for one package input' do
|
819
|
+
package_list = <<-RPM_OUTPUT
|
820
|
+
kernel-devel 1 1.2.3.4 5.el4 x86_64
|
821
|
+
RPM_OUTPUT
|
822
|
+
package_hash = described_class.nevra_to_multiversion_hash(package_list)
|
823
|
+
expect(package_hash).to eq(
|
824
|
+
{
|
825
|
+
:arch => "x86_64",
|
826
|
+
:ensure => "1:1.2.3.4-5.el4",
|
827
|
+
:epoch => "1",
|
828
|
+
:name => "kernel-devel",
|
829
|
+
:provider => :rpm,
|
830
|
+
:release => "5.el4",
|
831
|
+
:version => "1.2.3.4",
|
832
|
+
}
|
833
|
+
)
|
834
|
+
end
|
835
|
+
|
836
|
+
it 'should return package hash with versions concatenated in ensure for two package input' do
|
837
|
+
package_list = <<-RPM_OUTPUT
|
838
|
+
kernel-devel 1 1.2.3.4 5.el4 x86_64
|
839
|
+
kernel-devel 1 5.6.7.8 5.el4 x86_64
|
840
|
+
RPM_OUTPUT
|
841
|
+
package_hash = described_class.nevra_to_multiversion_hash(package_list)
|
842
|
+
expect(package_hash).to eq(
|
843
|
+
{
|
844
|
+
:arch => "x86_64",
|
845
|
+
:ensure => "1:1.2.3.4-5.el4; 1:5.6.7.8-5.el4",
|
846
|
+
:epoch => "1",
|
847
|
+
:name => "kernel-devel",
|
848
|
+
:provider => :rpm,
|
849
|
+
:release => "5.el4",
|
850
|
+
:version => "1.2.3.4",
|
851
|
+
}
|
852
|
+
)
|
853
|
+
end
|
854
|
+
|
855
|
+
it 'should return list of packages for one multiversion and one package input' do
|
856
|
+
package_list = <<-RPM_OUTPUT
|
857
|
+
kernel-devel 1 1.2.3.4 5.el4 x86_64
|
858
|
+
kernel-devel 1 5.6.7.8 5.el4 x86_64
|
859
|
+
basesystem 0 8.0 5.1.1.el5.centos noarch
|
860
|
+
RPM_OUTPUT
|
861
|
+
package_hash = described_class.nevra_to_multiversion_hash(package_list)
|
862
|
+
expect(package_hash).to eq(
|
863
|
+
[
|
864
|
+
{
|
865
|
+
:arch => "x86_64",
|
866
|
+
:ensure => "1:1.2.3.4-5.el4; 1:5.6.7.8-5.el4",
|
867
|
+
:epoch => "1",
|
868
|
+
:name => "kernel-devel",
|
869
|
+
:provider => :rpm,
|
870
|
+
:release => "5.el4",
|
871
|
+
:version => "1.2.3.4",
|
872
|
+
},
|
873
|
+
{
|
874
|
+
:provider => :rpm,
|
875
|
+
:name => "basesystem",
|
876
|
+
:epoch => "0",
|
877
|
+
:version => "8.0",
|
878
|
+
:release => "5.1.1.el5.centos",
|
879
|
+
:arch => "noarch",
|
880
|
+
:ensure => "8.0-5.1.1.el5.centos",
|
881
|
+
}
|
882
|
+
]
|
883
|
+
)
|
884
|
+
end
|
885
|
+
end
|
752
886
|
end
|