puppet 6.8.1-x86-mingw32 → 6.9.0-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.

Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/Gemfile.lock +10 -11
  4. data/ext/project_data.yaml +1 -0
  5. data/lib/puppet.rb +9 -1
  6. data/lib/puppet/application/agent.rb +12 -0
  7. data/lib/puppet/application_support.rb +1 -1
  8. data/lib/puppet/context.rb +120 -48
  9. data/lib/puppet/face/config.rb +10 -48
  10. data/lib/puppet/face/help.rb +1 -1
  11. data/lib/puppet/face/plugin.rb +9 -2
  12. data/lib/puppet/forge/repository.rb +1 -1
  13. data/lib/puppet/functions/regsubst.rb +58 -37
  14. data/lib/puppet/indirector/catalog/compiler.rb +10 -6
  15. data/lib/puppet/module_tool/applications/uninstaller.rb +2 -3
  16. data/lib/puppet/network/http/connection.rb +1 -1
  17. data/lib/puppet/network/http/factory.rb +1 -1
  18. data/lib/puppet/network/http_pool.rb +1 -0
  19. data/lib/puppet/provider/package/dnf.rb +1 -1
  20. data/lib/puppet/provider/package/rpm.rb +51 -13
  21. data/lib/puppet/provider/package/yum.rb +8 -4
  22. data/lib/puppet/provider/service/systemd.rb +1 -1
  23. data/lib/puppet/settings.rb +40 -0
  24. data/lib/puppet/ssl.rb +1 -1
  25. data/lib/puppet/ssl/base.rb +1 -1
  26. data/lib/puppet/ssl/openssl_loader.rb +28 -0
  27. data/lib/puppet/ssl/validator.rb +1 -1
  28. data/lib/puppet/ssl/validator/default_validator.rb +1 -1
  29. data/lib/puppet/ssl/validator/no_validator.rb +1 -1
  30. data/lib/puppet/thread_local.rb +7 -0
  31. data/lib/puppet/type/exec.rb +14 -6
  32. data/lib/puppet/type/group.rb +4 -2
  33. data/lib/puppet/type/package.rb +10 -0
  34. data/lib/puppet/type/user.rb +4 -2
  35. data/lib/puppet/util/checksums.rb +3 -3
  36. data/lib/puppet/util/http_proxy.rb +8 -6
  37. data/lib/puppet/util/monkey_patches.rb +53 -47
  38. data/lib/puppet/util/platform.rb +16 -0
  39. data/lib/puppet/util/ssl.rb +1 -1
  40. data/lib/puppet/util/windows/root_certs.rb +1 -1
  41. data/lib/puppet/version.rb +1 -1
  42. data/lib/puppet/x509.rb +1 -1
  43. data/locales/puppet.pot +119 -119
  44. data/man/man5/puppet.conf.5 +2 -2
  45. data/man/man8/puppet-agent.8 +1 -1
  46. data/man/man8/puppet-apply.8 +1 -1
  47. data/man/man8/puppet-catalog.8 +1 -1
  48. data/man/man8/puppet-config.8 +1 -1
  49. data/man/man8/puppet-describe.8 +1 -1
  50. data/man/man8/puppet-device.8 +1 -1
  51. data/man/man8/puppet-doc.8 +1 -1
  52. data/man/man8/puppet-epp.8 +1 -1
  53. data/man/man8/puppet-facts.8 +1 -1
  54. data/man/man8/puppet-filebucket.8 +1 -1
  55. data/man/man8/puppet-generate.8 +1 -1
  56. data/man/man8/puppet-help.8 +1 -1
  57. data/man/man8/puppet-key.8 +1 -1
  58. data/man/man8/puppet-lookup.8 +1 -1
  59. data/man/man8/puppet-man.8 +1 -1
  60. data/man/man8/puppet-module.8 +1 -1
  61. data/man/man8/puppet-node.8 +1 -1
  62. data/man/man8/puppet-parser.8 +1 -1
  63. data/man/man8/puppet-plugin.8 +1 -1
  64. data/man/man8/puppet-report.8 +1 -1
  65. data/man/man8/puppet-resource.8 +1 -1
  66. data/man/man8/puppet-script.8 +1 -1
  67. data/man/man8/puppet-ssl.8 +1 -1
  68. data/man/man8/puppet-status.8 +1 -1
  69. data/man/man8/puppet.8 +3 -3
  70. data/spec/integration/provider/service/systemd_spec.rb +7 -6
  71. data/spec/integration/util/execution_spec.rb +1 -1
  72. data/spec/lib/puppet_spec/matchers.rb +0 -13
  73. data/spec/spec_helper.rb +1 -3
  74. data/spec/unit/application/agent_spec.rb +19 -0
  75. data/spec/unit/context_spec.rb +119 -38
  76. data/spec/unit/face/help_spec.rb +1 -1
  77. data/spec/unit/face/plugin_spec.rb +8 -0
  78. data/spec/unit/forge/forge_spec.rb +1 -3
  79. data/spec/unit/forge/repository_spec.rb +1 -3
  80. data/spec/unit/functions/contain_spec.rb +1 -1
  81. data/spec/unit/indirector/catalog/compiler_spec.rb +62 -5
  82. data/spec/unit/module_tool/applications/uninstaller_spec.rb +16 -7
  83. data/spec/unit/node/environment_spec.rb +1 -1
  84. data/spec/unit/provider/package/aptrpm_spec.rb +1 -1
  85. data/spec/unit/provider/package/dnf_spec.rb +7 -0
  86. data/spec/unit/provider/package/pkgin_spec.rb +1 -1
  87. data/spec/unit/provider/package/rpm_spec.rb +150 -16
  88. data/spec/unit/provider/package/yum_spec.rb +7 -0
  89. data/spec/unit/type/exec_spec.rb +9 -0
  90. data/spec/unit/type/schedule_spec.rb +1 -1
  91. data/spec/unit/util/http_proxy_spec.rb +50 -0
  92. data/spec/unit/util/inifile_spec.rb +5 -5
  93. metadata +18 -2
@@ -155,7 +155,7 @@ describe Puppet::Face[:help, '0.0.1'] do
155
155
  # If we don't, these tests are ... less than useful, because they assume
156
156
  # it. When this breaks you should consider ditching the entire feature
157
157
  # and tests, but if not work out how to fake one. --daniel 2011-04-11
158
- it { is_expected.to have_at_least(1).item }
158
+ it { expect(subject.count).to be > 1 }
159
159
 
160
160
  # Meh. This is nasty, but we can't control the other list; the specific
161
161
  # bug that caused these to be listed is annoyingly subtle and has a nasty
@@ -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
@@ -97,10 +97,8 @@ describe Puppet::Forge do
97
97
  def mock_proxy(port, proxy_args, result, &block)
98
98
  http = double("http client")
99
99
  proxy = double("http proxy")
100
- proxy_class = double("http proxy class")
101
100
 
102
- expect(Net::HTTP).to receive(:Proxy).with(*proxy_args).and_return(proxy_class)
103
- expect(proxy_class).to receive(:new).with(host, port).and_return(proxy)
101
+ expect(Net::HTTP).to receive(:new).with(host, port, *proxy_args).and_return(proxy)
104
102
 
105
103
  expect(proxy).to receive(:open_timeout=)
106
104
  expect(proxy).to receive(:read_timeout=)
@@ -234,10 +234,8 @@ describe Puppet::Forge::Repository do
234
234
  def mock_proxy(port, proxy_args, result, &block)
235
235
  http = double("http client")
236
236
  proxy = double("http proxy")
237
- proxy_class = double("http proxy class")
238
237
 
239
- expect(Net::HTTP).to receive(:Proxy).with(*proxy_args).and_return(proxy_class)
240
- expect(proxy_class).to receive(:new).with("fake.com", port).and_return(proxy)
238
+ expect(Net::HTTP).to receive(:new).with("fake.com", port, *proxy_args).and_return(proxy)
241
239
 
242
240
  expect(proxy).to receive(:open_timeout=)
243
241
  expect(proxy).to receive(:read_timeout=)
@@ -192,7 +192,7 @@ describe 'The "contain" function' do
192
192
  contained = catalog.resource("Class", "contained")
193
193
  container = catalog.resource("Class", "container")
194
194
 
195
- expect(catalog.edges_between(container, contained)).to have(1).item
195
+ expect(catalog.edges_between(container, contained).count).to eq 1
196
196
  end
197
197
 
198
198
  context "when a containing class has a dependency order" do
@@ -4,6 +4,12 @@ require 'matchers/resource'
4
4
 
5
5
  require 'puppet/indirector/catalog/compiler'
6
6
 
7
+ def set_facts(fact_hash)
8
+ fact_hash.each do |key, value|
9
+ allow(Facter).to receive(:value).with(key).and_return(value)
10
+ end
11
+ end
12
+
7
13
  describe Puppet::Resource::Catalog::Compiler do
8
14
  let(:compiler) { described_class.new }
9
15
  let(:node_name) { "foo" }
@@ -16,8 +22,11 @@ describe Puppet::Resource::Catalog::Compiler do
16
22
  describe "when initializing" do
17
23
  before do
18
24
  expect(Puppet).to receive(:version).and_return(1)
19
- expect(Facter).to receive(:value).with('fqdn').and_return("my.server.com")
20
- expect(Facter).to receive(:value).with('ipaddress').and_return("my.ip.address")
25
+ set_facts({
26
+ 'fqdn' => "my.server.com",
27
+ 'ipaddress' => "my.ip.address",
28
+ 'ipaddress6' => nil
29
+ })
21
30
  end
22
31
 
23
32
  it "should gather data about itself" do
@@ -390,9 +399,12 @@ describe Puppet::Resource::Catalog::Compiler do
390
399
 
391
400
  describe "after finding nodes" do
392
401
  before do
393
- expect(Puppet).to receive(:version).and_return(1)
394
- expect(Facter).to receive(:value).with('fqdn').and_return("my.server.com")
395
- expect(Facter).to receive(:value).with('ipaddress').and_return("my.ip.address")
402
+ allow(Puppet).to receive(:version).and_return(1)
403
+ set_facts({
404
+ 'fqdn' => "my.server.com",
405
+ 'ipaddress' => "my.ip.address",
406
+ 'ipaddress6' => nil
407
+ })
396
408
  @request = Puppet::Indirector::Request.new(:catalog, :find, node_name, nil)
397
409
  allow(compiler).to receive(:compile)
398
410
  allow(Puppet::Node.indirection).to receive(:find).with(node_name, anything).and_return(node)
@@ -412,6 +424,51 @@ describe Puppet::Resource::Catalog::Compiler do
412
424
  expect(node).to receive(:merge).with(hash_including("serverip" => "my.ip.address"))
413
425
  compiler.find(@request)
414
426
  end
427
+
428
+ it "shouldn't warn if there is at least one ip fact" do
429
+ expect(node).to receive(:merge).with(hash_including("serverip" => "my.ip.address"))
430
+ compiler.find(@request)
431
+ expect(@logs).not_to be_any {|log| log.level == :warning and log.message =~ /Could not retrieve either serverip or serverip6 fact/}
432
+ end
433
+ end
434
+
435
+ describe "in an IPv6 only environment" do
436
+ before do |example|
437
+ allow(Puppet).to receive(:version).and_return(1)
438
+ set_facts({
439
+ 'fqdn' => "my.server.com",
440
+ 'ipaddress' => nil,
441
+ })
442
+ if example.metadata[:nil_ipv6]
443
+ set_facts({
444
+ 'ipaddress6' => nil
445
+ })
446
+ else
447
+ set_facts({
448
+ 'ipaddress6' => "my.ipv6.address"
449
+ })
450
+ end
451
+ @request = Puppet::Indirector::Request.new(:catalog, :find, node_name, nil)
452
+ allow(compiler).to receive(:compile)
453
+ allow(Puppet::Node.indirection).to receive(:find).with(node_name, anything).and_return(node)
454
+ end
455
+
456
+ it "should populate the :serverip6 fact" do
457
+ expect(node).to receive(:merge).with(hash_including("serverip6" => "my.ipv6.address"))
458
+ compiler.find(@request)
459
+ end
460
+
461
+ it "shouldn't warn if there is at least one ip fact" do
462
+ expect(node).to receive(:merge).with(hash_including("serverip6" => "my.ipv6.address"))
463
+ compiler.find(@request)
464
+ expect(@logs).not_to be_any {|log| log.level == :warning and log.message =~ /Could not retrieve either serverip or serverip6 fact/}
465
+ end
466
+
467
+ it "should warn if there are no ip facts", :nil_ipv6 do
468
+ expect(node).to receive(:merge)
469
+ compiler.find(@request)
470
+ expect(@logs).to be_any {|log| log.level == :warning and log.message =~ /Could not retrieve either serverip or serverip6 fact/}
471
+ end
415
472
  end
416
473
 
417
474
  describe "when filtering resources" do
@@ -58,6 +58,12 @@ describe Puppet::ModuleTool::Applications::Uninstaller do
58
58
  subject[:affected_modules].length == 1
59
59
  end
60
60
 
61
+ it 'should refuse to uninstall in FIPS mode' do
62
+ allow(Facter).to receive(:value).with(:fips_enabled).and_return(true)
63
+ err = subject[:error][:oneline]
64
+ expect(err).to eq("Either the `--ignore_changes` or `--force` argument must be specified to uninstall modules when running in FIPS mode.")
65
+ end
66
+
61
67
  context 'in two modulepaths' do
62
68
  before { preinstall('pmtacceptance-stdlib', '2.0.0', :into => secondary_dir) }
63
69
 
@@ -126,6 +132,11 @@ describe Puppet::ModuleTool::Applications::Uninstaller do
126
132
  it 'overwrites the installed module with the greatest version matching that range' do
127
133
  expect(subject).to include :result => :success
128
134
  end
135
+
136
+ it 'uninstalls in FIPS mode' do
137
+ allow(Facter).to receive(:value).with(:fips_enabled).and_return(true)
138
+ expect(subject).to include :result => :success
139
+ end
129
140
  end
130
141
 
131
142
  context 'without local changes' do
@@ -150,6 +161,11 @@ describe Puppet::ModuleTool::Applications::Uninstaller do
150
161
  expect(subject[:affected_modules].length).to eq(1)
151
162
  expect(subject[:affected_modules].first.forge_name).to eq("pmtacceptance/stdlib")
152
163
  end
164
+
165
+ it 'uninstalls in FIPS mode' do
166
+ allow(Facter).to receive(:value).with(:fips_enabled).and_return(true)
167
+ expect(subject).to include :result => :success
168
+ end
153
169
  end
154
170
 
155
171
  context "while depended upon" do
@@ -162,11 +178,4 @@ describe Puppet::ModuleTool::Applications::Uninstaller do
162
178
  end
163
179
  end
164
180
  end
165
-
166
- context 'when in FIPS mode...' do
167
- it 'module uninstaller refuses to run' do
168
- allow(Facter).to receive(:value).with(:fips_enabled).and_return(true)
169
- expect {application.run}.to raise_error(/Module uninstall is prohibited in FIPS mode/)
170
- end
171
- end
172
181
  end
@@ -53,7 +53,7 @@ describe Puppet::Node::Environment do
53
53
 
54
54
  expect(hash[base]).to eq("same env")
55
55
  expect(hash[different]).to eq("different env")
56
- expect(hash).to have(2).item
56
+ expect(hash.count).to eq 2
57
57
  end
58
58
 
59
59
  it "is equal when name, modules, and manifests are the same" 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', "'%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\\n'"]
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
@@ -44,5 +44,12 @@ describe Puppet::Type.type(:package).provider(:dnf) do
44
44
  end
45
45
  end
46
46
 
47
+ describe 'provider features' do
48
+ it { is_expected.to be_versionable }
49
+ it { is_expected.to be_install_options }
50
+ it { is_expected.to be_virtual_packages }
51
+ it { is_expected.to be_install_only }
52
+ end
53
+
47
54
  it_behaves_like 'RHEL package provider', described_class, 'dnf'
48
55
  end
@@ -48,7 +48,7 @@ describe Puppet::Type.type(:package).provider(:pkgin) do
48
48
 
49
49
  it "returns an array of providers for each package" do
50
50
  instances = described_class.instances
51
- expect(instances).to have(2).items
51
+ expect(instances.count).to eq 2
52
52
  instances.each do |instance|
53
53
  expect(instance).to be_a(described_class)
54
54
  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", "'#{nevra_format}'", "-p", "source-string"])
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", "'#{nevra_format}'", "-p", "source-string"])
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', "'#{nevra_format}'"], execute_options)
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", "'#{nevra_format}'"], execute_options)
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", "'#{nevra_format}'"], execute_options)
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", "'#{nevra_format}'"], execute_options)
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", "'#{nevra_format}'"], execute_options)
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", "'#{nevra_format}'"], execute_options)
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", "'#{nevra_format}'"], execute_options)
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", "'#{nevra_format}'"]
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', "'#{nevra_format}'", '--whatprovides']
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", "'#{nevra_format}'"]
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