puppet 6.14.0-universal-darwin → 6.15.0-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (195) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +15 -15
  3. data/ext/windows/service/daemon.rb +3 -3
  4. data/lib/puppet.rb +1 -1
  5. data/lib/puppet/agent.rb +2 -10
  6. data/lib/puppet/application/agent.rb +2 -1
  7. data/lib/puppet/application/filebucket.rb +5 -14
  8. data/lib/puppet/application/ssl.rb +2 -2
  9. data/lib/puppet/configurer.rb +7 -3
  10. data/lib/puppet/configurer/plugin_handler.rb +1 -1
  11. data/lib/puppet/defaults.rb +22 -2
  12. data/lib/puppet/environments.rb +4 -5
  13. data/lib/puppet/face/plugin.rb +1 -1
  14. data/lib/puppet/file_system/file_impl.rb +13 -9
  15. data/lib/puppet/forge/repository.rb +1 -1
  16. data/lib/puppet/functions/call.rb +1 -1
  17. data/lib/puppet/functions/reduce.rb +2 -4
  18. data/lib/puppet/http.rb +2 -0
  19. data/lib/puppet/http/client.rb +191 -52
  20. data/lib/puppet/http/external_client.rb +96 -0
  21. data/lib/puppet/http/redirector.rb +34 -0
  22. data/lib/puppet/http/resolver.rb +46 -3
  23. data/lib/puppet/http/resolver/server_list.rb +75 -15
  24. data/lib/puppet/http/resolver/settings.rb +22 -2
  25. data/lib/puppet/http/resolver/srv.rb +28 -2
  26. data/lib/puppet/http/response.rb +63 -1
  27. data/lib/puppet/http/retry_after_handler.rb +39 -0
  28. data/lib/puppet/http/service.rb +67 -1
  29. data/lib/puppet/http/service/ca.rb +71 -9
  30. data/lib/puppet/http/service/compiler.rb +213 -11
  31. data/lib/puppet/http/service/file_server.rb +105 -4
  32. data/lib/puppet/http/service/report.rb +36 -3
  33. data/lib/puppet/http/session.rb +59 -8
  34. data/lib/puppet/indirector/catalog/rest.rb +2 -1
  35. data/lib/puppet/indirector/facts/rest.rb +2 -1
  36. data/lib/puppet/indirector/file_bucket_file/rest.rb +48 -0
  37. data/lib/puppet/indirector/file_metadata/rest.rb +4 -2
  38. data/lib/puppet/indirector/node/rest.rb +2 -1
  39. data/lib/puppet/indirector/report/yaml.rb +23 -0
  40. data/lib/puppet/indirector/status/rest.rb +2 -1
  41. data/lib/puppet/metatype/manager.rb +80 -80
  42. data/lib/puppet/network/http/base_pool.rb +6 -1
  43. data/lib/puppet/network/http/pool.rb +2 -4
  44. data/lib/puppet/network/http_pool.rb +1 -0
  45. data/lib/puppet/node/environment.rb +11 -1
  46. data/lib/puppet/pal/pal_impl.rb +1 -29
  47. data/lib/puppet/parser/compiler.rb +14 -7
  48. data/lib/puppet/parser/functions.rb +18 -13
  49. data/lib/puppet/pops/loaders.rb +7 -5
  50. data/lib/puppet/provider/group/windows_adsi.rb +3 -3
  51. data/lib/puppet/provider/package/apt.rb +61 -1
  52. data/lib/puppet/provider/package/dnfmodule.rb +39 -12
  53. data/lib/puppet/provider/package/gem.rb +41 -7
  54. data/lib/puppet/provider/package/pacman.rb +2 -5
  55. data/lib/puppet/provider/package/pip.rb +105 -33
  56. data/lib/puppet/provider/package/pip3.rb +0 -2
  57. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  58. data/lib/puppet/provider/package/pkgng.rb +16 -4
  59. data/lib/puppet/provider/package/puppet_gem.rb +6 -2
  60. data/lib/puppet/provider/package/rpm.rb +6 -213
  61. data/lib/puppet/provider/package/yum.rb +92 -19
  62. data/lib/puppet/provider/service/systemd.rb +2 -1
  63. data/lib/puppet/reports/http.rb +13 -11
  64. data/lib/puppet/resource/type_collection.rb +20 -16
  65. data/lib/puppet/ssl.rb +1 -0
  66. data/lib/puppet/ssl/host.rb +4 -4
  67. data/lib/puppet/ssl/oids.rb +1 -0
  68. data/lib/puppet/ssl/state_machine.rb +50 -33
  69. data/lib/puppet/transaction/report.rb +2 -2
  70. data/lib/puppet/type.rb +6 -1
  71. data/lib/puppet/type/file/source.rb +4 -2
  72. data/lib/puppet/type/package.rb +25 -2
  73. data/lib/puppet/type/user.rb +0 -19
  74. data/lib/puppet/util/at_fork.rb +1 -1
  75. data/lib/puppet/util/autoload.rb +3 -0
  76. data/lib/puppet/util/instance_loader.rb +14 -10
  77. data/lib/puppet/util/package/version/debian.rb +175 -0
  78. data/lib/puppet/util/package/version/gem.rb +15 -0
  79. data/lib/puppet/util/package/version/pip.rb +167 -0
  80. data/lib/puppet/util/package/version/range.rb +50 -0
  81. data/lib/puppet/util/package/version/range/gt.rb +14 -0
  82. data/lib/puppet/util/package/version/range/gt_eq.rb +14 -0
  83. data/lib/puppet/util/package/version/range/lt.rb +14 -0
  84. data/lib/puppet/util/package/version/range/lt_eq.rb +14 -0
  85. data/lib/puppet/util/package/version/range/min_max.rb +21 -0
  86. data/lib/puppet/util/package/version/range/simple.rb +11 -0
  87. data/lib/puppet/util/package/version/rpm.rb +73 -0
  88. data/lib/puppet/util/pidlock.rb +13 -7
  89. data/lib/puppet/util/platform.rb +5 -0
  90. data/lib/puppet/util/rpm_compare.rb +193 -0
  91. data/lib/puppet/util/windows/adsi.rb +2 -2
  92. data/lib/puppet/util/windows/process.rb +15 -14
  93. data/lib/puppet/util/windows/security.rb +1 -0
  94. data/lib/puppet/util/windows/sid.rb +3 -3
  95. data/lib/puppet/version.rb +1 -1
  96. data/locales/puppet.pot +207 -201
  97. data/man/man5/puppet.conf.5 +11 -3
  98. data/man/man8/puppet-agent.8 +1 -1
  99. data/man/man8/puppet-apply.8 +1 -1
  100. data/man/man8/puppet-catalog.8 +1 -1
  101. data/man/man8/puppet-config.8 +1 -1
  102. data/man/man8/puppet-describe.8 +1 -1
  103. data/man/man8/puppet-device.8 +1 -1
  104. data/man/man8/puppet-doc.8 +1 -1
  105. data/man/man8/puppet-epp.8 +1 -1
  106. data/man/man8/puppet-facts.8 +1 -1
  107. data/man/man8/puppet-filebucket.8 +1 -1
  108. data/man/man8/puppet-generate.8 +1 -1
  109. data/man/man8/puppet-help.8 +1 -1
  110. data/man/man8/puppet-key.8 +1 -1
  111. data/man/man8/puppet-lookup.8 +1 -1
  112. data/man/man8/puppet-man.8 +1 -1
  113. data/man/man8/puppet-module.8 +1 -1
  114. data/man/man8/puppet-node.8 +1 -1
  115. data/man/man8/puppet-parser.8 +1 -1
  116. data/man/man8/puppet-plugin.8 +1 -1
  117. data/man/man8/puppet-report.8 +1 -1
  118. data/man/man8/puppet-resource.8 +1 -1
  119. data/man/man8/puppet-script.8 +1 -1
  120. data/man/man8/puppet-ssl.8 +1 -1
  121. data/man/man8/puppet-status.8 +1 -1
  122. data/man/man8/puppet.8 +2 -2
  123. data/spec/fixtures/ssl/unknown-127.0.0.1-key.pem +67 -0
  124. data/spec/fixtures/ssl/unknown-127.0.0.1.pem +48 -0
  125. data/spec/fixtures/ssl/unknown-ca-key.pem +67 -0
  126. data/spec/fixtures/ssl/unknown-ca.pem +59 -0
  127. data/spec/fixtures/unit/provider/package/dnfmodule/{dnf-module-list-installed.txt → dnf-module-list-enabled.txt} +2 -0
  128. data/spec/fixtures/unit/provider/package/pkgng/pkg.version +2 -0
  129. data/spec/fixtures/unit/provider/package/yum/yum-check-update-subscription-manager.txt +9 -0
  130. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +9 -0
  131. data/spec/integration/application/agent_spec.rb +329 -0
  132. data/spec/integration/application/apply_spec.rb +132 -3
  133. data/spec/integration/application/filebucket_spec.rb +190 -0
  134. data/spec/integration/application/plugin_spec.rb +50 -0
  135. data/spec/integration/http/client_spec.rb +34 -40
  136. data/spec/integration/indirector/report/yaml.rb +83 -0
  137. data/spec/integration/module_tool/forge_spec.rb +2 -15
  138. data/spec/integration/network/http_pool_spec.rb +11 -19
  139. data/spec/integration/node/environment_spec.rb +15 -0
  140. data/spec/integration/util/windows/adsi_spec.rb +1 -1
  141. data/spec/lib/puppet/test_ca.rb +2 -2
  142. data/spec/lib/puppet_spec/https.rb +10 -7
  143. data/spec/lib/puppet_spec/puppetserver.rb +119 -0
  144. data/spec/shared_contexts/https.rb +29 -0
  145. data/spec/unit/agent_spec.rb +33 -25
  146. data/spec/unit/application/agent_spec.rb +5 -1
  147. data/spec/unit/application/device_spec.rb +2 -2
  148. data/spec/unit/application/filebucket_spec.rb +22 -2
  149. data/spec/unit/configurer_spec.rb +1 -1
  150. data/spec/unit/defaults_spec.rb +24 -1
  151. data/spec/unit/environments_spec.rb +8 -0
  152. data/spec/unit/file_system_spec.rb +10 -0
  153. data/spec/unit/http/client_spec.rb +105 -46
  154. data/spec/unit/http/external_client_spec.rb +201 -0
  155. data/spec/unit/http/resolver_spec.rb +20 -0
  156. data/spec/unit/http/service/ca_spec.rb +25 -2
  157. data/spec/unit/http/service/compiler_spec.rb +184 -6
  158. data/spec/unit/http/service/file_server_spec.rb +35 -3
  159. data/spec/unit/http/service/report_spec.rb +3 -1
  160. data/spec/unit/http/service_spec.rb +3 -3
  161. data/spec/unit/http/session_spec.rb +56 -7
  162. data/spec/unit/indirector/file_bucket_file/rest_spec.rb +82 -2
  163. data/spec/unit/network/http/pool_spec.rb +3 -3
  164. data/spec/unit/node/environment_spec.rb +16 -0
  165. data/spec/unit/provider/group/windows_adsi_spec.rb +43 -10
  166. data/spec/unit/provider/package/apt_spec.rb +30 -0
  167. data/spec/unit/provider/package/dnfmodule_spec.rb +33 -14
  168. data/spec/unit/provider/package/gem_spec.rb +40 -0
  169. data/spec/unit/provider/package/pacman_spec.rb +6 -21
  170. data/spec/unit/provider/package/pip_spec.rb +26 -3
  171. data/spec/unit/provider/package/pkgdmg_spec.rb +1 -1
  172. data/spec/unit/provider/package/pkgng_spec.rb +38 -0
  173. data/spec/unit/provider/package/puppet_gem_spec.rb +8 -0
  174. data/spec/unit/provider/package/rpm_spec.rb +0 -212
  175. data/spec/unit/provider/package/yum_spec.rb +235 -1
  176. data/spec/unit/provider/service/systemd_spec.rb +10 -1
  177. data/spec/unit/provider/user/windows_adsi_spec.rb +3 -3
  178. data/spec/unit/puppet_pal_2pec.rb +0 -29
  179. data/spec/unit/reports/http_spec.rb +70 -52
  180. data/spec/unit/ssl/host_spec.rb +4 -2
  181. data/spec/unit/ssl/oids_spec.rb +1 -0
  182. data/spec/unit/ssl/state_machine_spec.rb +38 -6
  183. data/spec/unit/transaction/report_spec.rb +4 -0
  184. data/spec/unit/util/at_fork_spec.rb +2 -2
  185. data/spec/unit/util/package/version/debian_spec.rb +83 -0
  186. data/spec/unit/util/package/version/pip_spec.rb +464 -0
  187. data/spec/unit/util/package/version/range_spec.rb +154 -0
  188. data/spec/unit/util/package/version/rpm_spec.rb +121 -0
  189. data/spec/unit/util/pidlock_spec.rb +83 -47
  190. data/spec/unit/util/rpm_compare_spec.rb +196 -0
  191. data/spec/unit/util/windows/adsi_spec.rb +4 -4
  192. data/spec/unit/util/windows/sid_spec.rb +2 -2
  193. data/tasks/generate_cert_fixtures.rake +15 -1
  194. metadata +51 -6
  195. data/spec/integration/faces/plugin_spec.rb +0 -63
@@ -123,6 +123,36 @@ Version table:
123
123
  provider.install
124
124
  end
125
125
 
126
+ it "should select latest available version if range is specified" do
127
+ resource[:ensure] = '>60.0'
128
+ expect(provider).to receive(:aptget) do |*command|
129
+ expect(command[-1]).to eq("#{name}=72.0.1+build1-0ubuntu0.19.04.1")
130
+ end
131
+ expect(provider).to receive(:aptcache).with(:madison, name).and_return(<<-HERE)
132
+ #{name} | 72.0.1+build1-0ubuntu0.19.04.1 | http://ro.archive.ubuntu.com/ubuntu disco-updates/main amd64 Packages
133
+ #{name} | 72.0.1+build1-0ubuntu0.19.04.1 | http://security.ubuntu.com/ubuntu disco-security/main amd64 Packages
134
+ #{name} | 66.0.3+build1-0ubuntu1 | http://ro.archive.ubuntu.com/ubuntu disco/main amd64 Packages
135
+ HERE
136
+ expect(provider).to receive(:properties).and_return({:mark => :none})
137
+
138
+ provider.install
139
+ end
140
+
141
+ it "should pass through ensure is no version can be selected" do
142
+ resource[:ensure] = '>74.0'
143
+ expect(provider).to receive(:aptget) do |*command|
144
+ expect(command[-1]).to eq("#{name}=>74.0")
145
+ end
146
+ expect(provider).to receive(:aptcache).with(:madison, name).and_return(<<-HERE)
147
+ #{name} | 72.0.1+build1-0ubuntu0.19.04.1 | http://ro.archive.ubuntu.com/ubuntu disco-updates/main amd64 Packages
148
+ #{name} | 72.0.1+build1-0ubuntu0.19.04.1 | http://security.ubuntu.com/ubuntu disco-security/main amd64 Packages
149
+ #{name} | 66.0.3+build1-0ubuntu1 | http://ro.archive.ubuntu.com/ubuntu disco/main amd64 Packages
150
+ HERE
151
+ expect(provider).to receive(:properties).and_return({:mark => :none})
152
+
153
+ provider.install
154
+ end
155
+
126
156
  it "should use --force-yes if a package version is specified" do
127
157
  resource[:ensure] = '1.0'
128
158
  expect(provider).to receive(:aptget) do |*command|
@@ -18,7 +18,7 @@ describe Puppet::Type.type(:package).provider(:dnfmodule) do
18
18
  {:failonfail => true, :combine => true, :custom_environment => {}}
19
19
  end
20
20
 
21
- let(:packages) { File.read(my_fixture("dnf-module-list-installed.txt")) }
21
+ let(:packages) { File.read(my_fixture("dnf-module-list-enabled.txt")) }
22
22
  let(:dnf_path) { '/usr/bin/dnf' }
23
23
 
24
24
  before(:each) { allow(Puppet::Util).to receive(:which).with('/usr/bin/dnf').and_return(dnf_path) }
@@ -123,6 +123,23 @@ describe Puppet::Type.type(:package).provider(:dnfmodule) do
123
123
  provider.install
124
124
  end
125
125
 
126
+ it "should just enable the module if it has no default profile" do
127
+ dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nmissing groups or modules: #{resource[:name]}")
128
+ allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
129
+ resource[:ensure] = :present
130
+ expect(provider).to receive(:execute).with(array_including('install')).ordered
131
+ expect(provider).to receive(:execute).with(array_including('enable')).ordered
132
+ provider.install
133
+ end
134
+
135
+ it "should just enable the module if enable_only = true" do
136
+ resource[:ensure] = :present
137
+ resource[:enable_only] = true
138
+ expect(provider).to receive(:execute).with(array_including('enable'))
139
+ expect(provider).not_to receive(:execute).with(array_including('install'))
140
+ provider.install
141
+ end
142
+
126
143
  it "should install the default stream and flavor" do
127
144
  resource[:ensure] = :present
128
145
  expect(provider).to receive(:execute).with(array_including('baz'))
@@ -185,24 +202,26 @@ describe Puppet::Type.type(:package).provider(:dnfmodule) do
185
202
  end
186
203
  end
187
204
 
188
- context "parsing the output of module list --installed" do
205
+ context "parsing the output of module list --enabled" do
189
206
  before { allow(described_class).to receive(:command).with(:dnf).and_return(dnf_path) }
190
207
 
191
- it "returns an array of installed modules" do
208
+ it "returns an array of enabled modules" do
192
209
  allow(Puppet::Util::Execution).to receive(:execute)
193
- .with("/usr/bin/dnf module list --installed -d 0 -e 1")
210
+ .with("/usr/bin/dnf module list --enabled -d 0 -e 1")
194
211
  .and_return(packages)
195
212
 
196
- installed_packages = described_class.instances.map { |package| package.properties }
197
- expected_packages = [{name: "gimp", ensure: "2.8", flavor: "devel", :provider => :dnfmodule},
198
- {name: "mariadb", ensure: "10.3", flavor: "client", :provider => :dnfmodule},
199
- {name: "nodejs", ensure: "10", flavor: "minimal", :provider => :dnfmodule},
200
- {name: "perl", ensure: "5.26", flavor: "minimal", :provider => :dnfmodule},
201
- {name: "postgresql", ensure: "10", flavor: "server", :provider => :dnfmodule},
202
- {name: "rust-toolset", ensure: "rhel8", flavor: "common", :provider => :dnfmodule},
203
- {name: "subversion", ensure: "1.10", flavor: "server", :provider => :dnfmodule}]
204
-
205
- expect(installed_packages).to eql(expected_packages)
213
+ enabled_packages = described_class.instances.map { |package| package.properties }
214
+ expected_packages = [{name: "389-ds", ensure: "1.4", flavor: :absent, provider: :dnfmodule},
215
+ {name: "gimp", ensure: "2.8", flavor: "devel", provider: :dnfmodule},
216
+ {name: "mariadb", ensure: "10.3", flavor: "client", provider: :dnfmodule},
217
+ {name: "nodejs", ensure: "10", flavor: "minimal", provider: :dnfmodule},
218
+ {name: "perl", ensure: "5.26", flavor: "minimal", provider: :dnfmodule},
219
+ {name: "postgresql", ensure: "10", flavor: "server", provider: :dnfmodule},
220
+ {name: "ruby", ensure: "2.5", flavor: :absent, provider: :dnfmodule},
221
+ {name: "rust-toolset", ensure: "rhel8", flavor: "common", provider: :dnfmodule},
222
+ {name: "subversion", ensure: "1.10", flavor: "server", provider: :dnfmodule}]
223
+
224
+ expect(enabled_packages).to eql(expected_packages)
206
225
  end
207
226
  end
208
227
  end
@@ -257,6 +257,26 @@ context Puppet::Type.type(:package).provider(:gem) do
257
257
  resource[:ensure] = '3.6.2'
258
258
  expect(provider).to_not be_insync(is)
259
259
  end
260
+
261
+ it 'returns true for >2, <4' do
262
+ resource[:ensure] = '>2, <4'
263
+ expect(provider).to be_insync(is)
264
+ end
265
+
266
+ it 'returns false for >=4, <5' do
267
+ resource[:ensure] = '>=4, <5'
268
+ expect(provider).to_not be_insync(is)
269
+ end
270
+
271
+ it 'returns true for >2 <4' do
272
+ resource[:ensure] = '>2 <4'
273
+ expect(provider).to be_insync(is)
274
+ end
275
+
276
+ it 'returns false for >=4 <5' do
277
+ resource[:ensure] = '>=4 <5'
278
+ expect(provider).to_not be_insync(is)
279
+ end
260
280
  end
261
281
 
262
282
  context 'for string version' do
@@ -286,6 +306,26 @@ context Puppet::Type.type(:package).provider(:gem) do
286
306
  resource[:ensure] = '3.6.1'
287
307
  expect(provider).to_not be_insync(is)
288
308
  end
309
+
310
+ it 'returns true for >=1.3, <2' do
311
+ resource[:ensure] = '>=1.3, <2'
312
+ expect(provider).to be_insync(is)
313
+ end
314
+
315
+ it 'returns false for >1, <=1.3' do
316
+ resource[:ensure] = '>1, <=1.3'
317
+ expect(provider).to_not be_insync(is)
318
+ end
319
+
320
+ it 'returns true for >=1.3 <2' do
321
+ resource[:ensure] = '>=1.3 <2'
322
+ expect(provider).to be_insync(is)
323
+ end
324
+
325
+ it 'returns false for >1 <=1.3' do
326
+ resource[:ensure] = '>1 <=1.3'
327
+ expect(provider).to_not be_insync(is)
328
+ end
289
329
  end
290
330
 
291
331
  it 'should return false for bad version specifiers' do
@@ -26,14 +26,14 @@ describe Puppet::Type.type(:package).provider(:pacman) do
26
26
  end
27
27
 
28
28
  it "should call pacman to install the right package quietly when yaourt is not installed" do
29
- args = ['--noconfirm', '--needed', '--noprogressbar', '-Sy', resource[:name]]
29
+ args = ['--noconfirm', '--needed', '--noprogressbar', '-S', resource[:name]]
30
30
  expect(provider).to receive(:pacman).at_least(:once).with(*args).and_return('')
31
31
  provider.install
32
32
  end
33
33
 
34
34
  it "should call yaourt to install the right package quietly when yaourt is installed" do
35
35
  allow(described_class).to receive(:yaourt?).and_return(true)
36
- args = ['--noconfirm', '--needed', '--noprogressbar', '-Sy', resource[:name]]
36
+ args = ['--noconfirm', '--needed', '--noprogressbar', '-S', resource[:name]]
37
37
  expect(provider).to receive(:yaourt).at_least(:once).with(*args).and_return('')
38
38
  provider.install
39
39
  end
@@ -68,14 +68,14 @@ describe Puppet::Type.type(:package).provider(:pacman) do
68
68
  end
69
69
 
70
70
  it "should call pacman to install the right package quietly when yaourt is not installed" do
71
- args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '-Sy', resource[:name]]
71
+ args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '-S', resource[:name]]
72
72
  expect(provider).to receive(:pacman).at_least(:once).with(*args).and_return('')
73
73
  provider.install
74
74
  end
75
75
 
76
76
  it "should call yaourt to install the right package quietly when yaourt is installed" do
77
77
  expect(described_class).to receive(:yaourt?).and_return(true)
78
- args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '-Sy', resource[:name]]
78
+ args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '-S', resource[:name]]
79
79
  expect(provider).to receive(:yaourt).at_least(:once).with(*args).and_return('')
80
80
  provider.install
81
81
  end
@@ -94,7 +94,7 @@ describe Puppet::Type.type(:package).provider(:pacman) do
94
94
  resource[:source] = source
95
95
 
96
96
  expect(executor).to receive(:execute).
97
- with(include("-Sy") & include("--noprogressbar"), no_extra_options).
97
+ with(include("-S") & include("--noprogressbar"), no_extra_options).
98
98
  ordered.
99
99
  and_return("")
100
100
 
@@ -117,7 +117,7 @@ describe Puppet::Type.type(:package).provider(:pacman) do
117
117
 
118
118
  it "should install from the path segment of the URL" do
119
119
  expect(executor).to receive(:execute).
120
- with(include("-Sy") & include("--noprogressbar") & include("--noconfirm"),
120
+ with(include("-S") & include("--noprogressbar") & include("--noconfirm"),
121
121
  no_extra_options).
122
122
  ordered.
123
123
  and_return("")
@@ -348,21 +348,7 @@ EOF
348
348
  end
349
349
 
350
350
  describe "when determining the latest version" do
351
- it "should refresh package list" do
352
- expect(executor).to receive(:execute).
353
- ordered.
354
- with(['/usr/bin/pacman', '-Sy'], no_extra_options)
355
-
356
- expect(executor).to receive(:execute).
357
- ordered.
358
- and_return("")
359
-
360
- provider.latest
361
- end
362
-
363
351
  it "should get query pacman for the latest version" do
364
- expect(executor).to receive(:execute).ordered
365
-
366
352
  expect(executor).to receive(:execute).
367
353
  ordered.
368
354
  with(['/usr/bin/pacman', '-Sp', '--print-format', '%v', resource[:name]], no_extra_options).
@@ -379,7 +365,6 @@ EOF
379
365
 
380
366
  it "should return a virtual group version when resource is a package group" do
381
367
  allow(described_class).to receive(:group?).and_return(true)
382
- expect(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sy'], no_extra_options).ordered
383
368
  expect(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sp', '--print-format', '%n %v', resource[:name]], no_extra_options).ordered.
384
369
  and_return(<<EOF)
385
370
  package2 1.0.1
@@ -10,6 +10,7 @@ describe Puppet::Type.type(:package).provider(:pip) do
10
10
  it { is_expected.to be_versionable }
11
11
  it { is_expected.to be_install_options }
12
12
  it { is_expected.to be_targetable }
13
+ it { is_expected.to be_version_ranges }
13
14
 
14
15
  before do
15
16
  @resource = Puppet::Resource.new(:package, "fake_package")
@@ -150,6 +151,14 @@ describe Puppet::Type.type(:package).provider(:pip) do
150
151
  end
151
152
  end
152
153
 
154
+ context "when comparing versions" do
155
+ it "an abnormal version should still be compared (using default implementation) but a debug message should also be printed regarding it" do
156
+ expect(Puppet).to receive(:debug).with("Cannot compare 1.0 and abnormal-version.0.1. abnormal-version.0.1 is not a valid python package version. Please refer to https://www.python.org/dev/peps/pep-0440/. Falling through default comparison mechanism.")
157
+ expect(Puppet::Util::Package).to receive(:versioncmp).with('1.0', 'abnormal-version.0.1')
158
+ expect{ described_class.compare_pip_versions('1.0', 'abnormal-version.0.1') }.not_to raise_error
159
+ end
160
+ end
161
+
153
162
  context "latest" do
154
163
  context "with pip version < 1.5.4" do
155
164
  before :each do
@@ -206,6 +215,21 @@ describe Puppet::Type.type(:package).provider(:pip) do
206
215
  expect(@provider.latest).to eq(nil)
207
216
  end
208
217
 
218
+ it "should handle out-of-order version numbers for real_package" do
219
+ p = StringIO.new(
220
+ <<-EOS
221
+ Downloading/unpacking fake-package
222
+ Using version 2!2.3.4.alpha5.rev6.dev7+abc89 (newest of versions: 1.11, 13.0.3, 1.6, 1!1.2.rev33+123456, 1.9, 1.3.2, 14.0.1, 12.0.7, 13.0.3, 1.7.2, 1.8.4, 1.2+123abc456, 1.6.1, 0.9.2, 1.3, 1.8.3, 12.1.1, 1.1, 1.11.6, 1.2+123456, 1.4.8, 1.6.3, 1!1.0b2.post345.dev456, 1.10.1, 14.0.2, 1.11.3, 14.0.3, 1.4rc1, 1.0b2.post345.dev456, 0.8.4, 1.0, 1!1.0.post456, 12.0.5, 14.0.6, 1.11.5, 1.0rc2, 1.7.1.1, 1.11.4, 13.0.1, 13.1.2, 1.3.3, 0.8.2, 14.0.0, 12.0, 1.8, 1.3.4, 12.0, 1.2, 12.0.6, 0.9.1, 13.1.1, 2!2.3.4.alpha5.rev6.dev7+abc89, 14.0.5, 15.0.2, 15.0.0, 1.4.5, 1.4.3, 13.1.1, 1.11.2, 13.1.2, 1.2+abc123def, 1.3.1, 13.1.0, 12.0.2, 1.11.1, 12.0.1, 12.1.0, 0.9, 1.4.4, 1.2+abc123, 13.0.0, 1.4.9, 1.1.dev1, 12.1.0, 1.7.1, 1.4.2, 14.0.5, 0.8.1, 1.4.6, 0.8.3, 1.11.3, 1.5.1, 1.4.7, 13.0.2, 12.0.7, 1!13.0, 0!13.0, 1.9.1, 1.0.post456.dev34, 1.8.2, 14.0.1, 14.0.0, 1.2.rev33+123456, 14.0.4, 1.6.2, 15.0.1, 13.1.0, 0.8, 1.2+1234.abc, 1.7, 15.0.2, 12.0.5, 13.0.1, 1.8.1, 1.11.6, 15.0.1, 12.0.4, 1.2+123abc, 12.1.1, 13.0.2, 1.11.4, 1.10, 1.2.r32+123456, 14.0.4, 14.0.6, 1.4.1, 1.4, 1.5.2, 12.0.2, 12.0.1, 14.0.3, 14.0.2, 1.11.1, 1.7.1.2, 15.0.0, 12.0.4, 1.6.4, 1.11.2, 1.5, 0.1, 0.10, 0.10.1, 0.10.1.0.1, 1.0.dev456, 1.0a1, 1.0a2.dev456, 1.0a12.dev456, 1.0a12, 1.0b1.dev456, 1.0b2, 1.0b2.post345, 1.0b2-346, 1.0c1.dev456, 1.0c1, 1.0c3, 1.0, 1.0.post456, 1.2+abc, 1!1.0, 1!1.0.post456.dev34)
223
+ Downloading real-package-2!2.3.4.alpha5.rev6.dev7+abc89.tar.gz (544Kb): 544Kb downloaded
224
+ Saved ./foo/real-package-2!2.3.4.alpha5.rev6.dev7+abc89.tar.gz
225
+ Successfully downloaded real-package
226
+ EOS
227
+ )
228
+ expect(Puppet::Util::Execution).to receive(:execpipe).and_yield(p).once
229
+ @resource[:name] = "real_package"
230
+ expect(@provider.latest).to eq('2!2.3.4.alpha5.rev6.dev7+abc89')
231
+ end
232
+
209
233
  it "should use 'install_options' when specified" do
210
234
  expect(Puppet::Util::Execution).to receive(:execpipe).with(array_including([["--index=https://fake.example.com"]])).once
211
235
  @resource[:name] = "fake_package"
@@ -257,14 +281,13 @@ describe Puppet::Type.type(:package).provider(:pip) do
257
281
  p = StringIO.new(
258
282
  <<-EOS
259
283
  Collecting real-package==versionplease
260
- Could not find a version that satisfies the requirement real-package==versionplease (from versions: 1.11, 13.0.3, 1.6, 1.9, 1.3.2, 14.0.1, 12.0.7, 13.0.3, 1.7.2, 1.8.4, 1.6.1, 0.9.2, 1.3, 1.8.3, 12.1.1, 1.1, 1.11.6, 1.4.8, 1.6.3, 1.10.1, 14.0.2, 1.11.3, 14.0.3, 1.4rc1, 0.8.4, 1.0, 12.0.5, 14.0.6, 1.11.5, 1.7.1.1, 1.11.4, 13.0.1, 13.1.2, 1.3.3, 0.8.2, 14.0.0, 12.0, 1.8, 1.3.4, 12.0, 1.2, 12.0.6, 0.9.1, 13.1.1, 14.0.5, 15.0.2, 15.0.0, 1.4.5, 1.4.3, 13.1.1, 1.11.2, 13.1.2, 1.3.1, 13.1.0, 12.0.2, 1.11.1, 12.0.1, 12.1.0, 0.9, 1.4.4, 13.0.0, 1.4.9, 12.1.0, 1.7.1, 1.4.2, 14.0.5, 0.8.1, 1.4.6, 0.8.3, 1.11.3, 1.5.1, 1.4.7, 13.0.2, 12.0.7, 13.0.0, 1.9.1, 1.8.2, 14.0.1, 14.0.0, 14.0.4, 1.6.2, 15.0.1, 13.1.0, 0.8, 1.7, 15.0.2, 12.0.5, 13.0.1, 1.8.1, 1.11.6, 15.0.1, 12.0.4, 12.1.1, 13.0.2, 1.11.4, 1.10, 14.0.4, 14.0.6, 1.4.1, 1.4, 1.5.2, 12.0.2, 12.0.1, 14.0.3, 14.0.2, 1.11.1, 1.7.1.2, 15.0.0, 12.0.4, 1.6.4, 1.11.2, 1.5)
284
+ Could not find a version that satisfies the requirement real-package==versionplease (from versions: 1.11, 13.0.3, 1.6, 1!1.2.rev33+123456, 1.9, 1.3.2, 14.0.1, 12.0.7, 13.0.3, 1.7.2, 1.8.4, 1.2+123abc456, 1.6.1, 0.9.2, 1.3, 1.8.3, 12.1.1, 1.1, 1.11.6, 1.2+123456, 1.4.8, 1.6.3, 1!1.0b2.post345.dev456, 1.10.1, 14.0.2, 1.11.3, 14.0.3, 1.4rc1, 1.0b2.post345.dev456, 0.8.4, 1.0, 1!1.0.post456, 12.0.5, 14.0.6, 1.11.5, 1.0rc2, 1.7.1.1, 1.11.4, 13.0.1, 13.1.2, 1.3.3, 0.8.2, 14.0.0, 12.0, 1.8, 1.3.4, 12.0, 1.2, 12.0.6, 0.9.1, 13.1.1, 2!2.3.4.alpha5.rev6.dev7+abc89, 14.0.5, 15.0.2, 15.0.0, 1.4.5, 1.4.3, 13.1.1, 1.11.2, 13.1.2, 1.2+abc123def, 1.3.1, 13.1.0, 12.0.2, 1.11.1, 12.0.1, 12.1.0, 0.9, 1.4.4, 1.2+abc123, 13.0.0, 1.4.9, 1.1.dev1, 12.1.0, 1.7.1, 1.4.2, 14.0.5, 0.8.1, 1.4.6, 0.8.3, 1.11.3, 1.5.1, 1.4.7, 13.0.2, 12.0.7, 1!13.0, 0!13.0, 1.9.1, 1.0.post456.dev34, 1.8.2, 14.0.1, 14.0.0, 1.2.rev33+123456, 14.0.4, 1.6.2, 15.0.1, 13.1.0, 0.8, 1.2+1234.abc, 1.7, 15.0.2, 12.0.5, 13.0.1, 1.8.1, 1.11.6, 15.0.1, 12.0.4, 1.2+123abc, 12.1.1, 13.0.2, 1.11.4, 1.10, 1.2.r32+123456, 14.0.4, 14.0.6, 1.4.1, 1.4, 1.5.2, 12.0.2, 12.0.1, 14.0.3, 14.0.2, 1.11.1, 1.7.1.2, 15.0.0, 12.0.4, 1.6.4, 1.11.2, 1.5, 0.1, 0.10, 0.10.1, 0.10.1.0.1, 1.0.dev456, 1.0a1, 1.0a2.dev456, 1.0a12.dev456, 1.0a12, 1.0b1.dev456, 1.0b2, 1.0b2.post345, 1.0b2-346, 1.0c1.dev456, 1.0c1, 1.0c3, 1.0, 1.0.post456, 1.2+abc, 1!1.0, 1!1.0.post456.dev34)
261
285
  No distributions matching the version for real-package==versionplease
262
286
  EOS
263
287
  )
264
288
  expect(Puppet::Util::Execution).to receive(:execpipe).with(["/fake/bin/pip", "install", "real_package==versionplease"]).and_yield(p).once
265
289
  @resource[:name] = "real_package"
266
- latest = @provider.latest
267
- expect(latest).to eq('15.0.2')
290
+ expect(@provider.latest).to eq('2!2.3.4.alpha5.rev6.dev7+abc89')
268
291
  end
269
292
 
270
293
  it "should use 'install_options' when specified" do
@@ -45,7 +45,7 @@ describe Puppet::Type.type(:package).provider(:pkgdmg) do
45
45
  it "should call hdiutil to mount and eject the disk image" do
46
46
  allow(Dir).to receive(:entries).and_return([])
47
47
  expect(provider.class).to receive(:hdiutil).with("eject", fake_mountpoint).and_return(0)
48
- expect(provider.class).to receive(:hdiutil).with("mount", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", "/tmp", '/tmp/foo').and_return('a plist')
48
+ expect(provider.class).to receive(:hdiutil).with("mount", "-plist", "-nobrowse", "-readonly", "-mountrandom", "/tmp", '/tmp/foo').and_return('a plist')
49
49
  expect(Puppet::Util::Plist).to receive(:parse_plist).with('a plist').and_return(fake_hdiutil_plist)
50
50
  provider.install
51
51
  end
@@ -110,6 +110,30 @@ describe Puppet::Type.type(:package).provider(:pkgng) do
110
110
  end
111
111
  resource.provider.install
112
112
  end
113
+
114
+ it "should call pkg with the specified install options string" do
115
+ resource = Puppet::Type.type(:package).new(
116
+ :name => 'curl',
117
+ :provider => :pkgng,
118
+ :install_options => ['--foo', '--bar']
119
+ )
120
+ expect(resource.provider).to receive(:pkg) do |arg|
121
+ expect(arg).to include('--foo', '--bar')
122
+ end
123
+ resource.provider.install
124
+ end
125
+
126
+ it "should call pkg with the specified install options hash" do
127
+ resource = Puppet::Type.type(:package).new(
128
+ :name => 'curl',
129
+ :provider => :pkgng,
130
+ :install_options => ['--foo', { '--bar' => 'baz', '--baz' => 'foo' }]
131
+ )
132
+ expect(resource.provider).to receive(:pkg) do |arg|
133
+ expect(arg).to include('--foo', '--bar=baz', '--baz=foo')
134
+ end
135
+ resource.provider.install
136
+ end
113
137
  end
114
138
 
115
139
  context "#prefetch" do
@@ -177,6 +201,20 @@ describe Puppet::Type.type(:package).provider(:pkgng) do
177
201
 
178
202
  expect(bash_comp_latest_version).to eq('2.1_3')
179
203
  end
204
+
205
+ it "should return nil when the package is orphaned" do
206
+ version_list = File.read(my_fixture('pkg.version'))
207
+ allow(described_class).to receive(:get_version_list).and_return(version_list)
208
+ orphan_latest_version = described_class.get_latest_version('sysutils/orphan')
209
+ expect(orphan_latest_version).to be_nil
210
+ end
211
+
212
+ it "should return nil when the package is broken" do
213
+ version_list = File.read(my_fixture('pkg.version'))
214
+ allow(described_class).to receive(:get_version_list).and_return(version_list)
215
+ broken_latest_version = described_class.get_latest_version('sysutils/broken')
216
+ expect(broken_latest_version).to be_nil
217
+ end
180
218
  end
181
219
 
182
220
  describe "confine" do
@@ -67,6 +67,14 @@ describe Puppet::Type.type(:package).provider(:puppet_gem) do
67
67
  expect(described_class).to receive(:execute_gem_command).with(provider_gem_cmd, %w{uninstall --executables --all myresource --force --bindir=/usr/bin}).and_return('')
68
68
  provider.uninstall
69
69
  end
70
+
71
+ it 'should invalidate the rubygems cache' do
72
+ gem_source = double('gem_source')
73
+ allow(Puppet::Util::Autoload).to receive(:gem_source).and_return(gem_source)
74
+ expect(described_class).to receive(:execute_gem_command).with(provider_gem_cmd, %w{uninstall --executables --all myresource}).and_return('')
75
+ expect(gem_source).to receive(:clear_paths)
76
+ provider.uninstall
77
+ end
70
78
  end
71
79
 
72
80
  context 'calculated specificity' do
@@ -552,218 +552,6 @@ describe Puppet::Type.type(:package).provider(:rpm) do
552
552
  end
553
553
  end
554
554
 
555
- describe 'version comparison' do
556
- # test cases munged directly from rpm's own
557
- # tests/rpmvercmp.at
558
- it { expect(provider.rpmvercmp("1.0", "1.0")).to eq(0) }
559
- it { expect(provider.rpmvercmp("1.0", "2.0")).to eq(-1) }
560
- it { expect(provider.rpmvercmp("2.0", "1.0")).to eq(1) }
561
- it { expect(provider.rpmvercmp("2.0.1", "2.0.1")).to eq(0) }
562
- it { expect(provider.rpmvercmp("2.0", "2.0.1")).to eq(-1) }
563
- it { expect(provider.rpmvercmp("2.0.1", "2.0")).to eq(1) }
564
- it { expect(provider.rpmvercmp("2.0.1a", "2.0.1a")).to eq(0) }
565
- it { expect(provider.rpmvercmp("2.0.1a", "2.0.1")).to eq(1) }
566
- it { expect(provider.rpmvercmp("2.0.1", "2.0.1a")).to eq(-1) }
567
- it { expect(provider.rpmvercmp("5.5p1", "5.5p1")).to eq(0) }
568
- it { expect(provider.rpmvercmp("5.5p1", "5.5p2")).to eq(-1) }
569
- it { expect(provider.rpmvercmp("5.5p2", "5.5p1")).to eq(1) }
570
- it { expect(provider.rpmvercmp("5.5p10", "5.5p10")).to eq(0) }
571
- it { expect(provider.rpmvercmp("5.5p1", "5.5p10")).to eq(-1) }
572
- it { expect(provider.rpmvercmp("5.5p10", "5.5p1")).to eq(1) }
573
- it { expect(provider.rpmvercmp("10xyz", "10.1xyz")).to eq(-1) }
574
- it { expect(provider.rpmvercmp("10.1xyz", "10xyz")).to eq(1) }
575
- it { expect(provider.rpmvercmp("xyz10", "xyz10")).to eq(0) }
576
- it { expect(provider.rpmvercmp("xyz10", "xyz10.1")).to eq(-1) }
577
- it { expect(provider.rpmvercmp("xyz10.1", "xyz10")).to eq(1) }
578
- it { expect(provider.rpmvercmp("xyz.4", "xyz.4")).to eq(0) }
579
- it { expect(provider.rpmvercmp("xyz.4", "8")).to eq(-1) }
580
- it { expect(provider.rpmvercmp("8", "xyz.4")).to eq(1) }
581
- it { expect(provider.rpmvercmp("xyz.4", "2")).to eq(-1) }
582
- it { expect(provider.rpmvercmp("2", "xyz.4")).to eq(1) }
583
- it { expect(provider.rpmvercmp("5.5p2", "5.6p1")).to eq(-1) }
584
- it { expect(provider.rpmvercmp("5.6p1", "5.5p2")).to eq(1) }
585
- it { expect(provider.rpmvercmp("5.6p1", "6.5p1")).to eq(-1) }
586
- it { expect(provider.rpmvercmp("6.5p1", "5.6p1")).to eq(1) }
587
- it { expect(provider.rpmvercmp("6.0.rc1", "6.0")).to eq(1) }
588
- it { expect(provider.rpmvercmp("6.0", "6.0.rc1")).to eq(-1) }
589
- it { expect(provider.rpmvercmp("10b2", "10a1")).to eq(1) }
590
- it { expect(provider.rpmvercmp("10a2", "10b2")).to eq(-1) }
591
- it { expect(provider.rpmvercmp("1.0aa", "1.0aa")).to eq(0) }
592
- it { expect(provider.rpmvercmp("1.0a", "1.0aa")).to eq(-1) }
593
- it { expect(provider.rpmvercmp("1.0aa", "1.0a")).to eq(1) }
594
- it { expect(provider.rpmvercmp("10.0001", "10.0001")).to eq(0) }
595
- it { expect(provider.rpmvercmp("10.0001", "10.1")).to eq(0) }
596
- it { expect(provider.rpmvercmp("10.1", "10.0001")).to eq(0) }
597
- it { expect(provider.rpmvercmp("10.0001", "10.0039")).to eq(-1) }
598
- it { expect(provider.rpmvercmp("10.0039", "10.0001")).to eq(1) }
599
- it { expect(provider.rpmvercmp("4.999.9", "5.0")).to eq(-1) }
600
- it { expect(provider.rpmvercmp("5.0", "4.999.9")).to eq(1) }
601
- it { expect(provider.rpmvercmp("20101121", "20101121")).to eq(0) }
602
- it { expect(provider.rpmvercmp("20101121", "20101122")).to eq(-1) }
603
- it { expect(provider.rpmvercmp("20101122", "20101121")).to eq(1) }
604
- it { expect(provider.rpmvercmp("2_0", "2_0")).to eq(0) }
605
- it { expect(provider.rpmvercmp("2.0", "2_0")).to eq(0) }
606
- it { expect(provider.rpmvercmp("2_0", "2.0")).to eq(0) }
607
- it { expect(provider.rpmvercmp("a", "a")).to eq(0) }
608
- it { expect(provider.rpmvercmp("a+", "a+")).to eq(0) }
609
- it { expect(provider.rpmvercmp("a+", "a_")).to eq(0) }
610
- it { expect(provider.rpmvercmp("a_", "a+")).to eq(0) }
611
- it { expect(provider.rpmvercmp("+a", "+a")).to eq(0) }
612
- it { expect(provider.rpmvercmp("+a", "_a")).to eq(0) }
613
- it { expect(provider.rpmvercmp("_a", "+a")).to eq(0) }
614
- it { expect(provider.rpmvercmp("+_", "+_")).to eq(0) }
615
- it { expect(provider.rpmvercmp("_+", "+_")).to eq(0) }
616
- it { expect(provider.rpmvercmp("_+", "_+")).to eq(0) }
617
- it { expect(provider.rpmvercmp("+", "_")).to eq(0) }
618
- it { expect(provider.rpmvercmp("_", "+")).to eq(0) }
619
- it { expect(provider.rpmvercmp("1.0~rc1", "1.0~rc1")).to eq(0) }
620
- it { expect(provider.rpmvercmp("1.0~rc1", "1.0")).to eq(-1) }
621
- it { expect(provider.rpmvercmp("1.0", "1.0~rc1")).to eq(1) }
622
- it { expect(provider.rpmvercmp("1.0~rc1", "1.0~rc2")).to eq(-1) }
623
- it { expect(provider.rpmvercmp("1.0~rc2", "1.0~rc1")).to eq(1) }
624
- it { expect(provider.rpmvercmp("1.0~rc1~git123", "1.0~rc1~git123")).to eq(0) }
625
- it { expect(provider.rpmvercmp("1.0~rc1~git123", "1.0~rc1")).to eq(-1) }
626
- it { expect(provider.rpmvercmp("1.0~rc1", "1.0~rc1~git123")).to eq(1) }
627
- it { expect(provider.rpmvercmp("1.0~rc1", "1.0arc1")).to eq(-1) }
628
- it { expect(provider.rpmvercmp("", "~")).to eq(1) }
629
- it { expect(provider.rpmvercmp("~", "~~")).to eq(1) }
630
- it { expect(provider.rpmvercmp("~", "~+~")).to eq(1) }
631
- it { expect(provider.rpmvercmp("~", "~a")).to eq(-1) }
632
-
633
- # non-upstream test cases
634
- it { expect(provider.rpmvercmp("405", "406")).to eq(-1) }
635
- it { expect(provider.rpmvercmp("1", "0")).to eq(1) }
636
- end
637
-
638
- describe 'package evr parsing' do
639
- it 'should parse full simple evr' do
640
- v = provider.rpm_parse_evr('0:1.2.3-4.el5')
641
- expect(v[:epoch]).to eq('0')
642
- expect(v[:version]).to eq('1.2.3')
643
- expect(v[:release]).to eq('4.el5')
644
- end
645
-
646
- it 'should parse version only' do
647
- v = provider.rpm_parse_evr('1.2.3')
648
- expect(v[:epoch]).to eq(nil)
649
- expect(v[:version]).to eq('1.2.3')
650
- expect(v[:release]).to eq(nil)
651
- end
652
-
653
- it 'should parse version-release' do
654
- v = provider.rpm_parse_evr('1.2.3-4.5.el6')
655
- expect(v[:epoch]).to eq(nil)
656
- expect(v[:version]).to eq('1.2.3')
657
- expect(v[:release]).to eq('4.5.el6')
658
- end
659
-
660
- it 'should parse release with git hash' do
661
- v = provider.rpm_parse_evr('1.2.3-4.1234aefd')
662
- expect(v[:epoch]).to eq(nil)
663
- expect(v[:version]).to eq('1.2.3')
664
- expect(v[:release]).to eq('4.1234aefd')
665
- end
666
-
667
- it 'should parse single integer versions' do
668
- v = provider.rpm_parse_evr('12345')
669
- expect(v[:epoch]).to eq(nil)
670
- expect(v[:version]).to eq('12345')
671
- expect(v[:release]).to eq(nil)
672
- end
673
-
674
- it 'should parse text in the epoch to 0' do
675
- v = provider.rpm_parse_evr('foo0:1.2.3-4')
676
- expect(v[:epoch]).to eq(nil)
677
- expect(v[:version]).to eq('1.2.3')
678
- expect(v[:release]).to eq('4')
679
- end
680
-
681
- it 'should parse revisions with text' do
682
- v = provider.rpm_parse_evr('1.2.3-SNAPSHOT20140107')
683
- expect(v[:epoch]).to eq(nil)
684
- expect(v[:version]).to eq('1.2.3')
685
- expect(v[:release]).to eq('SNAPSHOT20140107')
686
- end
687
-
688
- # test cases for PUP-682
689
- it 'should parse revisions with text and numbers' do
690
- v = provider.rpm_parse_evr('2.2-SNAPSHOT20121119105647')
691
- expect(v[:epoch]).to eq(nil)
692
- expect(v[:version]).to eq('2.2')
693
- expect(v[:release]).to eq('SNAPSHOT20121119105647')
694
- end
695
- end
696
-
697
- describe 'rpm evr comparison' do
698
- # currently passing tests
699
- it 'should evaluate identical version-release as equal' do
700
- v = provider.rpm_compareEVR({:epoch => '0', :version => '1.2.3', :release => '1.el5'},
701
- {:epoch => '0', :version => '1.2.3', :release => '1.el5'})
702
- expect(v).to eq(0)
703
- end
704
-
705
- it 'should evaluate identical version as equal' do
706
- v = provider.rpm_compareEVR({:epoch => '0', :version => '1.2.3', :release => nil},
707
- {:epoch => '0', :version => '1.2.3', :release => nil})
708
- expect(v).to eq(0)
709
- end
710
-
711
- it 'should evaluate identical version but older release as less' do
712
- v = provider.rpm_compareEVR({:epoch => '0', :version => '1.2.3', :release => '1.el5'},
713
- {:epoch => '0', :version => '1.2.3', :release => '2.el5'})
714
- expect(v).to eq(-1)
715
- end
716
-
717
- it 'should evaluate identical version but newer release as greater' do
718
- v = provider.rpm_compareEVR({:epoch => '0', :version => '1.2.3', :release => '3.el5'},
719
- {:epoch => '0', :version => '1.2.3', :release => '2.el5'})
720
- expect(v).to eq(1)
721
- end
722
-
723
- it 'should evaluate a newer epoch as greater' do
724
- v = provider.rpm_compareEVR({:epoch => '1', :version => '1.2.3', :release => '4.5'},
725
- {:epoch => '0', :version => '1.2.3', :release => '4.5'})
726
- expect(v).to eq(1)
727
- end
728
-
729
- # these tests describe PUP-1244 logic yet to be implemented
730
- it 'should evaluate any version as equal to the same version followed by release' do
731
- v = provider.rpm_compareEVR({:epoch => '0', :version => '1.2.3', :release => nil},
732
- {:epoch => '0', :version => '1.2.3', :release => '2.el5'})
733
- expect(v).to eq(0)
734
- end
735
-
736
- # test cases for PUP-682
737
- it 'should evaluate same-length numeric revisions numerically' do
738
- expect(provider.rpm_compareEVR({:epoch => '0', :version => '2.2', :release => '405'},
739
- {:epoch => '0', :version => '2.2', :release => '406'})).to eq(-1)
740
- end
741
- end
742
-
743
- describe 'version segment comparison' do
744
- it 'should treat two nil values as equal' do
745
- v = provider.compare_values(nil, nil)
746
- expect(v).to eq(0)
747
- end
748
-
749
- it 'should treat a nil value as less than a non-nil value' do
750
- v = provider.compare_values(nil, '0')
751
- expect(v).to eq(-1)
752
- end
753
-
754
- it 'should treat a non-nil value as greater than a nil value' do
755
- v = provider.compare_values('0', nil)
756
- expect(v).to eq(1)
757
- end
758
-
759
- it 'should pass two non-nil values on to rpmvercmp' do
760
- allow(provider).to receive(:rpmvercmp).and_return(0)
761
- expect(provider).to receive(:rpmvercmp).with('s1', 's2')
762
- provider.compare_values('s1', 's2')
763
- end
764
- end
765
-
766
-
767
555
  describe 'insync?' do
768
556
  context 'for multiple versions' do
769
557
  let(:is) { '1:1.2.3.4-5.el4; 1:5.6.7.8-5.el4' }