puppet 5.5.17-x64-mingw32 → 5.5.18-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.

Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +1 -1
  3. data/Gemfile +2 -3
  4. data/Gemfile.lock +35 -31
  5. data/ext/build_defaults.yaml +1 -0
  6. data/ext/cert_inspector +3 -3
  7. data/ext/puppet-test +2 -2
  8. data/ext/regexp_nodes/regexp_nodes.rb +4 -4
  9. data/ext/windows/service/daemon.rb +54 -8
  10. data/install.rb +6 -6
  11. data/lib/puppet/application.rb +1 -1
  12. data/lib/puppet/application/apply.rb +2 -2
  13. data/lib/puppet/application/describe.rb +3 -9
  14. data/lib/puppet/application/doc.rb +1 -1
  15. data/lib/puppet/application/lookup.rb +1 -1
  16. data/lib/puppet/application/script.rb +2 -2
  17. data/lib/puppet/configurer.rb +86 -28
  18. data/lib/puppet/configurer/downloader.rb +2 -6
  19. data/lib/puppet/defaults.rb +17 -4
  20. data/lib/puppet/error.rb +9 -1
  21. data/lib/puppet/external/nagios/base.rb +1 -1
  22. data/lib/puppet/face/ca.rb +1 -1
  23. data/lib/puppet/face/module/list.rb +5 -5
  24. data/lib/puppet/face/module/search.rb +1 -1
  25. data/lib/puppet/face/module/uninstall.rb +1 -1
  26. data/lib/puppet/face/module/upgrade.rb +1 -1
  27. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  28. data/lib/puppet/file_system.rb +0 -8
  29. data/lib/puppet/file_system/memory_file.rb +1 -1
  30. data/lib/puppet/file_system/posix.rb +3 -2
  31. data/lib/puppet/forge.rb +3 -3
  32. data/lib/puppet/functions/epp.rb +4 -4
  33. data/lib/puppet/functions/inline_epp.rb +5 -5
  34. data/lib/puppet/gettext/module_translations.rb +1 -1
  35. data/lib/puppet/graph/rb_tree_map.rb +2 -2
  36. data/lib/puppet/graph/simple_graph.rb +6 -5
  37. data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
  38. data/lib/puppet/indirector/hiera.rb +2 -0
  39. data/lib/puppet/indirector/resource/ral.rb +1 -3
  40. data/lib/puppet/indirector/resource/validator.rb +1 -1
  41. data/lib/puppet/interface.rb +2 -1
  42. data/lib/puppet/loaders.rb +0 -1
  43. data/lib/puppet/metatype/manager.rb +1 -1
  44. data/lib/puppet/module.rb +1 -1
  45. data/lib/puppet/module_tool/applications/builder.rb +1 -1
  46. data/lib/puppet/module_tool/applications/installer.rb +1 -1
  47. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
  48. data/lib/puppet/module_tool/metadata.rb +1 -1
  49. data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
  50. data/lib/puppet/module_tool/tar/mini.rb +1 -1
  51. data/lib/puppet/network/http/api/indirected_routes.rb +12 -11
  52. data/lib/puppet/network/http/connection.rb +10 -12
  53. data/lib/puppet/network/http/pool.rb +2 -0
  54. data/lib/puppet/network/http/rack/rest.rb +2 -2
  55. data/lib/puppet/network/http/site.rb +1 -1
  56. data/lib/puppet/network/resolver.rb +2 -2
  57. data/lib/puppet/node/environment.rb +4 -2
  58. data/lib/puppet/parser/ast.rb +1 -1
  59. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  60. data/lib/puppet/parser/functions.rb +1 -1
  61. data/lib/puppet/parser/functions/epp.rb +3 -3
  62. data/lib/puppet/parser/functions/inline_epp.rb +5 -5
  63. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
  64. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
  65. data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -2
  66. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
  67. data/lib/puppet/pops/loaders.rb +1 -1
  68. data/lib/puppet/pops/lookup/hiera_config.rb +1 -0
  69. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  70. data/lib/puppet/pops/merge_strategy.rb +22 -18
  71. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  72. data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
  73. data/lib/puppet/pops/parser/locator.rb +1 -1
  74. data/lib/puppet/pops/parser/pn_parser.rb +17 -16
  75. data/lib/puppet/pops/puppet_stack.rb +51 -48
  76. data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
  77. data/lib/puppet/pops/types/string_converter.rb +10 -10
  78. data/lib/puppet/pops/types/types.rb +3 -3
  79. data/lib/puppet/property.rb +1 -1
  80. data/lib/puppet/property/ensure.rb +1 -1
  81. data/lib/puppet/provider/augeas/augeas.rb +1 -1
  82. data/lib/puppet/provider/cron/crontab.rb +1 -1
  83. data/lib/puppet/provider/exec.rb +6 -2
  84. data/lib/puppet/provider/mount.rb +1 -1
  85. data/lib/puppet/provider/mount/parsed.rb +8 -8
  86. data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
  87. data/lib/puppet/provider/nameservice/pw.rb +2 -2
  88. data/lib/puppet/provider/package/dnfmodule.rb +87 -0
  89. data/lib/puppet/provider/package/dpkg.rb +3 -12
  90. data/lib/puppet/provider/package/openbsd.rb +1 -1
  91. data/lib/puppet/provider/package/pip.rb +34 -9
  92. data/lib/puppet/provider/package/portage.rb +4 -4
  93. data/lib/puppet/provider/package/rpm.rb +6 -6
  94. data/lib/puppet/provider/package/windows/package.rb +1 -1
  95. data/lib/puppet/provider/package/yum.rb +1 -1
  96. data/lib/puppet/provider/package_targetable.rb +5 -4
  97. data/lib/puppet/provider/parsedfile.rb +1 -1
  98. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +3 -3
  99. data/lib/puppet/provider/service/daemontools.rb +9 -9
  100. data/lib/puppet/provider/service/openbsd.rb +1 -1
  101. data/lib/puppet/provider/service/rcng.rb +2 -2
  102. data/lib/puppet/provider/service/runit.rb +2 -8
  103. data/lib/puppet/provider/service/systemd.rb +8 -8
  104. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  105. data/lib/puppet/provider/user/hpux.rb +1 -1
  106. data/lib/puppet/provider/user/user_role_add.rb +1 -1
  107. data/lib/puppet/provider/user/useradd.rb +22 -13
  108. data/lib/puppet/provider/user/windows_adsi.rb +4 -5
  109. data/lib/puppet/provider/yumrepo/inifile.rb +2 -2
  110. data/lib/puppet/reference/indirection.rb +2 -2
  111. data/lib/puppet/reference/metaparameter.rb +1 -3
  112. data/lib/puppet/reference/providers.rb +1 -1
  113. data/lib/puppet/reference/type.rb +3 -9
  114. data/lib/puppet/reports.rb +1 -1
  115. data/lib/puppet/resource.rb +1 -1
  116. data/lib/puppet/resource/catalog.rb +1 -1
  117. data/lib/puppet/settings.rb +3 -3
  118. data/lib/puppet/settings/environment_conf.rb +1 -0
  119. data/lib/puppet/ssl/certificate_authority/interface.rb +1 -1
  120. data/lib/puppet/ssl/certificate_factory.rb +2 -2
  121. data/lib/puppet/ssl/host.rb +3 -3
  122. data/lib/puppet/ssl/oids.rb +1 -1
  123. data/lib/puppet/transaction/report.rb +1 -1
  124. data/lib/puppet/type.rb +2 -4
  125. data/lib/puppet/type/cron.rb +1 -1
  126. data/lib/puppet/type/exec.rb +7 -3
  127. data/lib/puppet/type/file.rb +1 -2
  128. data/lib/puppet/type/file/data_sync.rb +5 -1
  129. data/lib/puppet/type/group.rb +4 -2
  130. data/lib/puppet/type/interface.rb +1 -1
  131. data/lib/puppet/type/notify.rb +3 -2
  132. data/lib/puppet/type/package.rb +2 -2
  133. data/lib/puppet/type/schedule.rb +1 -1
  134. data/lib/puppet/type/selboolean.rb +17 -3
  135. data/lib/puppet/type/service.rb +1 -1
  136. data/lib/puppet/type/user.rb +4 -2
  137. data/lib/puppet/util.rb +35 -12
  138. data/lib/puppet/util/command_line/trollop.rb +1 -1
  139. data/lib/puppet/util/http_proxy.rb +8 -14
  140. data/lib/puppet/util/instance_loader.rb +1 -1
  141. data/lib/puppet/util/log.rb +1 -1
  142. data/lib/puppet/util/log/destinations.rb +2 -2
  143. data/lib/puppet/util/logging.rb +30 -18
  144. data/lib/puppet/util/metric.rb +2 -2
  145. data/lib/puppet/util/monkey_patches.rb +1 -1
  146. data/lib/puppet/util/nagios_maker.rb +2 -2
  147. data/lib/puppet/util/network_device/cisco/device.rb +1 -1
  148. data/lib/puppet/util/network_device/cisco/interface.rb +2 -2
  149. data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
  150. data/lib/puppet/util/provider_features.rb +2 -4
  151. data/lib/puppet/util/rdoc.rb +1 -1
  152. data/lib/puppet/util/reference.rb +1 -1
  153. data/lib/puppet/util/resource_template.rb +1 -1
  154. data/lib/puppet/util/selinux.rb +3 -1
  155. data/lib/puppet/util/windows/adsi.rb +58 -28
  156. data/lib/puppet/util/windows/registry.rb +7 -5
  157. data/lib/puppet/vendor.rb +1 -1
  158. data/lib/puppet/version.rb +1 -1
  159. data/lib/puppet_pal.rb +2 -2
  160. data/locales/puppet.pot +115 -95
  161. data/man/man5/puppet.conf.5 +21 -5
  162. data/man/man8/puppet-agent.8 +1 -1
  163. data/man/man8/puppet-apply.8 +1 -1
  164. data/man/man8/puppet-ca.8 +1 -1
  165. data/man/man8/puppet-catalog.8 +1 -1
  166. data/man/man8/puppet-cert.8 +1 -1
  167. data/man/man8/puppet-certificate.8 +1 -1
  168. data/man/man8/puppet-certificate_request.8 +1 -1
  169. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  170. data/man/man8/puppet-config.8 +1 -1
  171. data/man/man8/puppet-describe.8 +1 -1
  172. data/man/man8/puppet-device.8 +1 -1
  173. data/man/man8/puppet-doc.8 +1 -1
  174. data/man/man8/puppet-epp.8 +1 -1
  175. data/man/man8/puppet-facts.8 +1 -1
  176. data/man/man8/puppet-filebucket.8 +1 -1
  177. data/man/man8/puppet-generate.8 +1 -1
  178. data/man/man8/puppet-help.8 +1 -1
  179. data/man/man8/puppet-key.8 +1 -1
  180. data/man/man8/puppet-lookup.8 +1 -1
  181. data/man/man8/puppet-man.8 +1 -1
  182. data/man/man8/puppet-master.8 +1 -1
  183. data/man/man8/puppet-module.8 +1 -1
  184. data/man/man8/puppet-node.8 +1 -1
  185. data/man/man8/puppet-parser.8 +1 -1
  186. data/man/man8/puppet-plugin.8 +1 -1
  187. data/man/man8/puppet-report.8 +1 -1
  188. data/man/man8/puppet-resource.8 +1 -1
  189. data/man/man8/puppet-script.8 +1 -1
  190. data/man/man8/puppet-status.8 +1 -1
  191. data/man/man8/puppet.8 +2 -2
  192. data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list-installed.txt +11 -0
  193. data/spec/integration/configurer_spec.rb +52 -0
  194. data/spec/integration/type/notify_spec.rb +46 -0
  195. data/spec/unit/configurer_spec.rb +380 -397
  196. data/spec/unit/forge/forge_spec.rb +1 -3
  197. data/spec/unit/forge/repository_spec.rb +1 -3
  198. data/spec/unit/indirector/resource/ral_spec.rb +4 -4
  199. data/spec/unit/network/http/connection_spec.rb +26 -0
  200. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +8 -3
  201. data/spec/unit/provider/exec_spec.rb +209 -0
  202. data/spec/unit/provider/package/dnfmodule_spec.rb +186 -0
  203. data/spec/unit/provider/package/dpkg_spec.rb +15 -3
  204. data/spec/unit/provider/package/pip_spec.rb +51 -6
  205. data/spec/unit/provider/package/portage_spec.rb +4 -4
  206. data/spec/unit/provider/package_targetable_spec.rb +60 -0
  207. data/spec/unit/provider/service/daemontools_spec.rb +24 -0
  208. data/spec/unit/provider/service/runit_spec.rb +24 -0
  209. data/spec/unit/provider/service/systemd_spec.rb +22 -22
  210. data/spec/unit/provider/user/hpux_spec.rb +2 -2
  211. data/spec/unit/provider/user/useradd_spec.rb +46 -0
  212. data/spec/unit/type/exec_spec.rb +6 -12
  213. data/spec/unit/type/file/content_spec.rb +9 -3
  214. data/spec/unit/type/file_spec.rb +9 -4
  215. data/spec/unit/type/selboolean_spec.rb +4 -6
  216. data/spec/unit/util/execution_spec.rb +16 -0
  217. data/spec/unit/util/http_proxy_spec.rb +97 -0
  218. data/spec/unit/util/log/destinations_spec.rb +7 -3
  219. data/spec/unit/util/log_spec.rb +0 -138
  220. data/spec/unit/util/logging_spec.rb +200 -0
  221. data/spec/unit/util/windows/adsi_spec.rb +51 -0
  222. data/tasks/manpages.rake +1 -0
  223. metadata +12 -5
  224. data/lib/puppet/pops/loader/null_loader.rb +0 -60
  225. data/locales/ja/puppet.po +0 -12114
@@ -287,9 +287,21 @@ describe Puppet::Type.type(:package).provider(:dpkg) do
287
287
  provider.purge
288
288
  end
289
289
 
290
- it "raises error if package name is nil" do
291
- expect {provider.package_not_installed?(nil)}.to raise_error(ArgumentError,"Package name is nil or empty")
292
- expect {provider.package_not_installed?("")}.to raise_error(ArgumentError,"Package name is nil or empty")
290
+ context "package_not_installed?" do
291
+ it "returns true if package is not found" do
292
+ expect(provider).to receive(:dpkgquery).with("-W", "--showformat", "'${Status} ${Package} ${Version}\\n'", resource_name).and_raise(Puppet::ExecutionFailure.new("eh"))
293
+ expect(provider.package_not_installed?).to eq(true)
294
+ end
295
+
296
+ it "returns true if package is not installed" do
297
+ expect(provider).to receive(:dpkgquery).with("-W", "--showformat", "'${Status} ${Package} ${Version}\\n'", resource_name).and_return("unknown ok not-installed #{resource_name}")
298
+ expect(provider.package_not_installed?).to eq(true)
299
+ end
300
+
301
+ it "returns false if package is installed" do
302
+ expect(provider).to receive(:dpkgquery).with("-W", "--showformat", "'${Status} ${Package} ${Version}\\n'", resource_name).and_return("install ok installed resource_name 1.2.3")
303
+ expect(provider.package_not_installed?).to eq(false)
304
+ end
293
305
  end
294
306
  end
295
307
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- osfamilies = { 'windows' => ['pip.exe'], 'other' => ['pip', 'pip-python'] }
3
+ osfamilies = { 'windows' => ['pip.exe'], 'other' => ['pip', 'pip-python', 'pip2', 'pip-2'] }
4
4
 
5
5
  describe Puppet::Type.type(:package).provider(:pip) do
6
6
 
@@ -197,6 +197,13 @@ describe Puppet::Type.type(:package).provider(:pip) do
197
197
  @resource[:name] = "fake_package"
198
198
  expect(@provider.latest).to eq(nil)
199
199
  end
200
+
201
+ it "should use 'install_options' when specified" do
202
+ expect(Puppet::Util::Execution).to receive(:execpipe).with(array_including([["--index=https://fake.example.com"]])).once
203
+ @resource[:name] = "fake_package"
204
+ @resource[:install_options] = ['--index' => 'https://fake.example.com']
205
+ expect(@provider.latest).to eq(nil)
206
+ end
200
207
  end
201
208
 
202
209
  context "with pip version >= 1.5.4" do
@@ -251,6 +258,13 @@ describe Puppet::Type.type(:package).provider(:pip) do
251
258
  latest = @provider.latest
252
259
  expect(latest).to eq('15.0.2')
253
260
  end
261
+
262
+ it "should use 'install_options' when specified" do
263
+ expect(Puppet::Util::Execution).to receive(:execpipe).with(array_including([["--index=https://fake.example.com"]])).once
264
+ @resource[:name] = "fake_package"
265
+ @resource[:install_options] = ['--index' => 'https://fake.example.com']
266
+ expect(@provider.latest).to eq(nil)
267
+ end
254
268
  end
255
269
  end
256
270
 
@@ -341,12 +355,43 @@ describe Puppet::Type.type(:package).provider(:pip) do
341
355
  end
342
356
 
343
357
  context "pip_version" do
358
+ let(:pip) { '/fake/bin/pip' }
359
+
344
360
  it "should look up version if pip is present" do
345
- allow(described_class).to receive(:pip_cmd).and_return('/fake/bin/pip')
346
- p = double("process")
347
- expect(p).to receive(:collect).and_yield('pip 8.0.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)')
348
- expect(described_class).to receive(:execpipe).with(['/fake/bin/pip', '--version']).and_yield(p)
349
- expect(described_class.pip_version('/fake/bin/pip')).to eq('8.0.2')
361
+ allow(described_class).to receive(:pip_cmd).and_return(pip)
362
+ process = ['pip 8.0.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)']
363
+ allow(described_class).to receive(:execpipe).with([pip, '--version']).and_yield(process)
364
+
365
+ expect(described_class.pip_version(pip)).to eq('8.0.2')
366
+ end
367
+
368
+ it "parses multiple lines of output" do
369
+ allow(described_class).to receive(:pip_cmd).and_return(pip)
370
+ process = [
371
+ "/usr/local/lib/python2.7/dist-packages/urllib3/contrib/socks.py:37: DependencyWarning: SOCKS support in urllib3 requires the installation of optional dependencies: specifically, PySocks. For more information, see https://urllib3.readthedocs.io/en/latest/contrib.html#socks-proxies",
372
+ " DependencyWarning",
373
+ "pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)"
374
+ ]
375
+ allow(described_class).to receive(:execpipe).with([pip, '--version']).and_yield(process)
376
+
377
+ expect(described_class.pip_version(pip)).to eq('1.5.6')
378
+ end
379
+
380
+ it "raises if there isn't a version string" do
381
+ allow(described_class).to receive(:pip_cmd).and_return(pip)
382
+ allow(described_class).to receive(:execpipe).with([pip, '--version']).and_yield([""])
383
+ expect {
384
+ described_class.pip_version(pip)
385
+ }.to raise_error(Puppet::Error, 'Cannot resolve pip version')
386
+ end
387
+
388
+ it "quotes commands with spaces" do
389
+ pip = 'C:\Program Files\Python27\Scripts\pip.exe'
390
+ allow(described_class).to receive(:pip_cmd).and_return(pip)
391
+ process = ["pip 18.1 from c:\program files\python27\lib\site-packages\pip (python 2.7)\r\n"]
392
+ allow(described_class).to receive(:execpipe).with(["\"#{pip}\"", '--version']).and_yield(process)
393
+
394
+ expect(described_class.pip_version(pip)).to eq('18.1')
350
395
  end
351
396
  end
352
397
 
@@ -42,13 +42,13 @@ describe Puppet::Type.type(:package).provider(:portage) do
42
42
  allow(@unslotted_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>nil, :pr=>nil, :slot=>nil, :pfx=>nil, :sfx=>nil})
43
43
  allow(@unslotted_provider.class).to receive(:emerge).with('--list-sets').and_return(package_sets)
44
44
  @slotted_provider = described_class.new(@slotted_resource)
45
- allow(@slotted_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>nil, :pr=>nil, :slot=>":2.1", :pfx=>nil, :sfx=>nil})
45
+ allow(@slotted_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>nil, :pr=>nil, :slot=>"2.1", :pfx=>nil, :sfx=>nil})
46
46
  allow(@slotted_provider.class).to receive(:emerge).with('--list-sets').and_return(package_sets)
47
47
  @versioned_provider = described_class.new(@versioned_resource)
48
48
  allow(@versioned_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>"1.9.3", :pr=>nil, :slot=>nil, :pfx=>nil, :sfx=>nil})
49
49
  allow(@versioned_provider.class).to receive(:emerge).with('--list-sets').and_return(package_sets)
50
50
  @versioned_slotted_provider = described_class.new(@versioned_slotted_resource)
51
- allow(@versioned_slotted_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>"1.9.3", :pr=>nil, :slot=>":1.9", :pfx=>"=", :sfx=>nil})
51
+ allow(@versioned_slotted_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>"1.9.3", :pr=>nil, :slot=>"1.9", :pfx=>"=", :sfx=>nil})
52
52
  allow(@versioned_slotted_provider.class).to receive(:emerge).with('--list-sets').and_return(package_sets)
53
53
  @set_provider = described_class.new(@set_resource)
54
54
  allow(@set_provider).to receive(:qatom).and_return({:category=>nil, :pn=>"@system", :pv=>nil, :pr=>nil, :slot=>nil, :pfx=>nil, :sfx=>nil})
@@ -166,7 +166,7 @@ describe Puppet::Type.type(:package).provider(:portage) do
166
166
  end
167
167
 
168
168
  it "can extract the slot from the package name" do
169
- expect(@slotted_provider.qatom[:slot]).to eq(':2.1')
169
+ expect(@slotted_provider.qatom[:slot]).to eq('2.1')
170
170
  end
171
171
 
172
172
  it "returns nil for as the slot when no slot is specified" do
@@ -182,7 +182,7 @@ describe Puppet::Type.type(:package).provider(:portage) do
182
182
  expect(@versioned_slotted_provider.qatom[:category]).to eq('dev-lang')
183
183
  expect(@versioned_slotted_provider.qatom[:pn]).to eq('ruby')
184
184
  expect(@versioned_slotted_provider.qatom[:pv]).to eq('1.9.3')
185
- expect(@versioned_slotted_provider.qatom[:slot]).to eq(':1.9')
185
+ expect(@versioned_slotted_provider.qatom[:slot]).to eq('1.9')
186
186
  end
187
187
 
188
188
  it "can handle search output with slots for unslotted packages" do
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'puppet'
3
+ require 'puppet/provider/package_targetable'
4
+ require 'puppet/provider/package/gem'
5
+
6
+ describe Puppet::Provider::Package::Targetable do
7
+ let(:provider) { Puppet::Type.type(:package).provider(:gem) }
8
+ let(:command) { '/opt/bin/gem' }
9
+
10
+ describe "when prefetching" do
11
+ context "with a package without a command attribute" do
12
+ let(:resource) { Puppet::Type.type(:package).new(:name => 'noo', :provider => 'gem', :ensure => :present) }
13
+ let(:catalog) { Puppet::Resource::Catalog.new }
14
+ let(:instance) { provider.new(resource) }
15
+ let(:packages) { { 'noo' => resource } }
16
+
17
+ it "should pass a command to the instances method of the provider" do
18
+ catalog.add_resource(resource)
19
+ expect(provider).to receive(:instances).with(nil).and_return([instance])
20
+ expect(provider.prefetch(packages)).to eq([nil]) # prefetch arbitrarily returns the array of commands for a provider in the catalog
21
+ end
22
+ end
23
+
24
+ context "with a package with a command attribute" do
25
+ let(:resource) { Puppet::Type.type(:package).new(:name => 'noo', :provider => 'gem', :ensure => :present) }
26
+ let(:resource_targeted) { Puppet::Type.type(:package).new(:name => 'yes', :provider => 'gem', :command => command, :ensure => :present) }
27
+ let(:catalog) { Puppet::Resource::Catalog.new }
28
+ let(:instance) { provider.new(resource) }
29
+ let(:instance_targeted) { provider.new(resource_targeted) }
30
+ let(:packages) { { 'noo' => resource, 'yes' => resource_targeted } }
31
+
32
+ it "should pass the command to the instances method of the provider" do
33
+ catalog.add_resource(resource)
34
+ catalog.add_resource(resource_targeted)
35
+ expect(provider).to receive(:instances).with(nil).and_return([instance])
36
+ expect(provider).to receive(:instances).with(command).and_return([instance_targeted]).once
37
+ expect(provider.prefetch(packages)).to eq([nil, command]) # prefetch arbitrarily returns the array of commands for a provider in the catalog
38
+ end
39
+ end
40
+ end
41
+
42
+ describe "when validating a command" do
43
+ context "with no command" do
44
+ it "report not functional" do
45
+ expect { provider.validate_command(nil) }.to raise_error(Puppet::Error, "Provider gem package command is not functional on this host")
46
+ end
47
+ end
48
+ context "with a missing command" do
49
+ it "report does not exist" do
50
+ expect { provider.validate_command(command) }.to raise_error(Puppet::Error, "Provider gem package command '#{command}' does not exist on this host")
51
+ end
52
+ end
53
+ context "with an existing command" do
54
+ it "validates" do
55
+ allow(File).to receive(:file?).with(command).and_return(true)
56
+ expect { provider.validate_command(command) }.not_to raise_error
57
+ end
58
+ end
59
+ end
60
+ end
@@ -160,4 +160,28 @@ describe Puppet::Type.type(:service).provider(:daemontools) do
160
160
  expect(@provider.status).to eq(:stopped)
161
161
  end
162
162
  end
163
+
164
+ context '.instances' do
165
+ before do
166
+ allow(described_class).to receive(:defpath).and_return(path)
167
+ end
168
+
169
+ context 'when defpath is nil' do
170
+ let(:path) { nil }
171
+
172
+ it 'returns info message' do
173
+ expect(Puppet).to receive(:info).with(/daemontools is unsuitable because service directory is nil/)
174
+ described_class.instances
175
+ end
176
+ end
177
+
178
+ context 'when defpath does not exist' do
179
+ let(:path) { '/inexistent_path' }
180
+
181
+ it 'returns notice about missing path' do
182
+ expect(Puppet).to receive(:notice).with(/Service path #{path} does not exist/)
183
+ described_class.instances
184
+ end
185
+ end
186
+ end
163
187
  end
@@ -134,4 +134,28 @@ describe Puppet::Type.type(:service).provider(:runit) do
134
134
  expect(@provider.status).to eq(:stopped)
135
135
  end
136
136
  end
137
+
138
+ context '.instances' do
139
+ before do
140
+ allow(described_class).to receive(:defpath).and_return(path)
141
+ end
142
+
143
+ context 'when defpath is nil' do
144
+ let(:path) { nil }
145
+
146
+ it 'returns info message' do
147
+ expect(Puppet).to receive(:info).with(/runit is unsuitable because service directory is nil/)
148
+ described_class.instances
149
+ end
150
+ end
151
+
152
+ context 'when defpath does not exist' do
153
+ let(:path) { '/inexistent_path' }
154
+
155
+ it 'returns notice about missing path' do
156
+ expect(Puppet).to receive(:notice).with(/Service path #{path} does not exist/)
157
+ described_class.instances
158
+ end
159
+ end
160
+ end
137
161
  end
@@ -164,15 +164,15 @@ describe Puppet::Type.type(:service).provider(:systemd) do
164
164
 
165
165
  it "should start the service with systemctl start otherwise" do
166
166
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
167
- expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
168
- expect(provider).to receive(:execute).with(['/bin/systemctl','start','sshd.service'], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
167
+ expect(provider).to receive(:systemctl).with(:unmask, '--', 'sshd.service')
168
+ expect(provider).to receive(:execute).with(['/bin/systemctl','start', '--', 'sshd.service'], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
169
169
  provider.start
170
170
  end
171
171
 
172
172
  it "should show journald logs on failure" do
173
173
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
174
- expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
175
- expect(provider).to receive(:execute).with(['/bin/systemctl','start','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
174
+ expect(provider).to receive(:systemctl).with(:unmask, '--', 'sshd.service')
175
+ expect(provider).to receive(:execute).with(['/bin/systemctl','start', '--', 'sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
176
176
  .and_raise(Puppet::ExecutionFailure, "Failed to start sshd.service: Unit sshd.service failed to load: Invalid argument. See system logs and 'systemctl status sshd.service' for details.")
177
177
  journalctl_logs = <<-EOS
178
178
  -- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
@@ -194,13 +194,13 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
194
194
 
195
195
  it "should stop the service with systemctl stop otherwise" do
196
196
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
197
- expect(provider).to receive(:execute).with(['/bin/systemctl','stop','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
197
+ expect(provider).to receive(:execute).with(['/bin/systemctl','stop', '--', 'sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
198
198
  provider.stop
199
199
  end
200
200
 
201
201
  it "should show journald logs on failure" do
202
202
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
203
- expect(provider).to receive(:execute).with(['/bin/systemctl','stop','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
203
+ expect(provider).to receive(:execute).with(['/bin/systemctl','stop', '--', 'sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
204
204
  .and_raise(Puppet::ExecutionFailure, "Failed to stop sshd.service: Unit sshd.service failed to load: Invalid argument. See system logs and 'systemctl status sshd.service' for details.")
205
205
  journalctl_logs = <<-EOS
206
206
  -- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
@@ -216,42 +216,42 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
216
216
  describe "#enabled?" do
217
217
  it "should return :true if the service is enabled" do
218
218
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
219
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("enabled\n")
219
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("enabled\n")
220
220
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
221
221
  expect(provider.enabled?).to eq(:true)
222
222
  end
223
223
 
224
224
  it "should return :true if the service is static" do
225
225
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
226
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("static\n")
226
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','--', 'sshd.service'], :failonfail => false).and_return("static\n")
227
227
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
228
228
  expect(provider.enabled?).to eq(:true)
229
229
  end
230
230
 
231
231
  it "should return :false if the service is disabled" do
232
232
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
233
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("disabled\n")
233
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("disabled\n")
234
234
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
235
235
  expect(provider.enabled?).to eq(:false)
236
236
  end
237
237
 
238
238
  it "should return :false if the service is indirect" do
239
239
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
240
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("indirect\n")
240
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("indirect\n")
241
241
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
242
242
  expect(provider.enabled?).to eq(:false)
243
243
  end
244
244
 
245
245
  it "should return :false if the service is masked and the resource is attempting to be disabled" do
246
246
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service', :enable => false))
247
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("masked\n")
247
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("masked\n")
248
248
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
249
249
  expect(provider.enabled?).to eq(:false)
250
250
  end
251
251
 
252
252
  it "should return :mask if the service is masked and the resource is attempting to be masked" do
253
253
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service', :enable => 'mask'))
254
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("masked\n")
254
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("masked\n")
255
255
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
256
256
  expect(provider.enabled?).to eq(:mask)
257
257
  end
@@ -260,8 +260,8 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
260
260
  describe "#enable" do
261
261
  it "should run systemctl enable to enable a service" do
262
262
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
263
- expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
264
- expect(provider).to receive(:systemctl).with(:enable, 'sshd.service')
263
+ expect(provider).to receive(:systemctl).with(:unmask, '--', 'sshd.service')
264
+ expect(provider).to receive(:systemctl).with(:enable, '--', 'sshd.service')
265
265
  provider.enable
266
266
  end
267
267
  end
@@ -269,7 +269,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
269
269
  describe "#disable" do
270
270
  it "should run systemctl disable to disable a service" do
271
271
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
272
- expect(provider).to receive(:systemctl).with(:disable, 'sshd.service')
272
+ expect(provider).to receive(:systemctl).with(:disable, '--', 'sshd.service')
273
273
  provider.disable
274
274
  end
275
275
  end
@@ -280,8 +280,8 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
280
280
  # :disable is the only call in the provider that uses a symbol instead of
281
281
  # a string.
282
282
  # This should be made consistent in the future and all tests updated.
283
- expect(provider).to receive(:systemctl).with(:disable, 'sshd.service')
284
- expect(provider).to receive(:systemctl).with(:mask, 'sshd.service')
283
+ expect(provider).to receive(:systemctl).with(:disable, '--', 'sshd.service')
284
+ expect(provider).to receive(:systemctl).with(:mask, '--', 'sshd.service')
285
285
  provider.mask
286
286
  end
287
287
  end
@@ -291,7 +291,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
291
291
  describe "#status" do
292
292
  it "should return running if if the command returns 0" do
293
293
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
294
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-active','sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("active\n")
294
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-active','--','sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("active\n")
295
295
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
296
296
  expect(provider.status).to eq(:running)
297
297
  end
@@ -299,7 +299,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
299
299
  [-10,-1,3,10].each { |ec|
300
300
  it "should return stopped if the command returns something non-0" do
301
301
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
302
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-active','sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("inactive\n")
302
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-active','--','sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("inactive\n")
303
303
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(ec)
304
304
  expect(provider.status).to eq(:stopped)
305
305
  end
@@ -317,20 +317,20 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
317
317
  describe "#restart" do
318
318
  it "should use the supplied restart command if specified" do
319
319
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :restart => '/bin/foo'))
320
- expect(provider).not_to receive(:execute).with(['/bin/systemctl','restart','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
320
+ expect(provider).not_to receive(:execute).with(['/bin/systemctl','restart','--','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
321
321
  expect(provider).to receive(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
322
322
  provider.restart
323
323
  end
324
324
 
325
325
  it "should restart the service with systemctl restart" do
326
326
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
327
- expect(provider).to receive(:execute).with(['/bin/systemctl','restart','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
327
+ expect(provider).to receive(:execute).with(['/bin/systemctl','restart','--','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
328
328
  provider.restart
329
329
  end
330
330
 
331
331
  it "should show journald logs on failure" do
332
332
  provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
333
- expect(provider).to receive(:execute).with(['/bin/systemctl','restart','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
333
+ expect(provider).to receive(:execute).with(['/bin/systemctl','restart', '--', 'sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
334
334
  .and_raise(Puppet::ExecutionFailure, "Failed to restart sshd.service: Unit sshd.service failed to load: Invalid argument. See system logs and 'systemctl status sshd.service' for details.")
335
335
  journalctl_logs = <<-EOS
336
336
  -- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
@@ -56,14 +56,14 @@ describe Puppet::Type.type(:user).provider(:hpuxuseradd), :unless => Puppet.feat
56
56
  it "should add modprpw to modifycmd if Trusted System" do
57
57
  allow(resource).to receive(:allowdupe?).and_return(true)
58
58
  expect(provider).to receive(:exec_getprpw).with('root','-m uid').and_return('uid=0')
59
- expect(provider).to receive(:execute).with(['/usr/sam/lbin/usermod.sam', '-u', 1000, '-o', 'testuser', '-F', ';', '/usr/lbin/modprpw', '-v', '-l', 'testuser'], hash_including(custom_environment: {}))
59
+ expect(provider).to receive(:execute).with(['/usr/sam/lbin/usermod.sam', '-F', '-u', 1000, '-o', 'testuser', ';', '/usr/lbin/modprpw', '-v', '-l', 'testuser'], hash_including(custom_environment: {}))
60
60
  provider.uid = 1000
61
61
  end
62
62
 
63
63
  it "should not add modprpw if not Trusted System" do
64
64
  allow(resource).to receive(:allowdupe?).and_return(true)
65
65
  expect(provider).to receive(:exec_getprpw).with('root','-m uid').and_return('System is not trusted')
66
- expect(provider).to receive(:execute).with(['/usr/sam/lbin/usermod.sam', '-u', 1000, '-o', 'testuser', '-F'], hash_including(custom_environment: {}))
66
+ expect(provider).to receive(:execute).with(['/usr/sam/lbin/usermod.sam', '-F', '-u', 1000, '-o', 'testuser'], hash_including(custom_environment: {}))
67
67
  provider.uid = 1000
68
68
  end
69
69
  end
@@ -317,6 +317,52 @@ describe Puppet::Type.type(:user).provider(:useradd) do
317
317
  end
318
318
  end
319
319
 
320
+ describe "#comment" do
321
+ before { described_class.has_feature :libuser }
322
+
323
+ let(:content) { "myuser:x:x:x:local comment:x:x" }
324
+
325
+ it "should return the local comment string when forcelocal is true" do
326
+ resource[:forcelocal] = true
327
+ allow(File).to receive(:open).with('/etc/passwd').and_yield(content)
328
+ expect(provider.comment).to eq('local comment')
329
+ end
330
+
331
+ it "should fall back to nameservice comment string when forcelocal is false" do
332
+ resource[:forcelocal] = false
333
+ allow(provider).to receive(:get).with(:comment).and_return('remote comment')
334
+ expect(provider).not_to receive(:localcomment)
335
+ expect(provider.comment).to eq('remote comment')
336
+ end
337
+ end
338
+
339
+ describe "#finduser" do
340
+ before { allow(File).to receive(:open).with('/etc/passwd').and_yield(content) }
341
+
342
+ let(:content) { "sample_account:sample_password:sample_uid:sample_gid:sample_gecos:sample_directory:sample_shell" }
343
+ let(:output) do
344
+ {
345
+ account: 'sample_account',
346
+ password: 'sample_password',
347
+ uid: 'sample_uid',
348
+ gid: 'sample_gid',
349
+ gecos: 'sample_gecos',
350
+ directory: 'sample_directory',
351
+ shell: 'sample_shell',
352
+ }
353
+ end
354
+
355
+ [:account, :password, :uid, :gid, :gecos, :directory, :shell].each do |key|
356
+ it "finds an user by #{key} when asked" do
357
+ expect(provider.finduser(key, "sample_#{key}")).to eq(output)
358
+ end
359
+ end
360
+
361
+ it "returns false when specified key/value pair is not found" do
362
+ expect(provider.finduser(:account, 'invalid_account')).to eq(false)
363
+ end
364
+ end
365
+
320
366
  describe "#check_allow_dup" do
321
367
  it "should return an array with a flag if dup is allowed" do
322
368
  resource[:allowdupe] = :true