puppet 5.5.17-universal-darwin → 5.5.22-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 (340) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +1 -1
  3. data/Gemfile +4 -5
  4. data/Gemfile.lock +59 -55
  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.rb +5 -2
  12. data/lib/puppet/agent.rb +5 -13
  13. data/lib/puppet/application.rb +1 -1
  14. data/lib/puppet/application/agent.rb +3 -1
  15. data/lib/puppet/application/apply.rb +2 -2
  16. data/lib/puppet/application/describe.rb +3 -9
  17. data/lib/puppet/application/doc.rb +1 -1
  18. data/lib/puppet/application/filebucket.rb +13 -0
  19. data/lib/puppet/application/lookup.rb +1 -1
  20. data/lib/puppet/application/script.rb +2 -2
  21. data/lib/puppet/configurer.rb +106 -31
  22. data/lib/puppet/configurer/downloader.rb +33 -16
  23. data/lib/puppet/daemon.rb +1 -1
  24. data/lib/puppet/defaults.rb +86 -40
  25. data/lib/puppet/error.rb +9 -1
  26. data/lib/puppet/external/nagios/base.rb +1 -1
  27. data/lib/puppet/face/ca.rb +1 -1
  28. data/lib/puppet/face/module/list.rb +5 -5
  29. data/lib/puppet/face/module/search.rb +1 -1
  30. data/lib/puppet/face/module/uninstall.rb +1 -1
  31. data/lib/puppet/face/module/upgrade.rb +1 -1
  32. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  33. data/lib/puppet/file_serving/mount/locales.rb +1 -2
  34. data/lib/puppet/file_serving/mount/pluginfacts.rb +1 -2
  35. data/lib/puppet/file_serving/mount/plugins.rb +1 -2
  36. data/lib/puppet/file_system.rb +0 -8
  37. data/lib/puppet/file_system/memory_file.rb +1 -1
  38. data/lib/puppet/file_system/posix.rb +3 -2
  39. data/lib/puppet/file_system/uniquefile.rb +4 -0
  40. data/lib/puppet/forge.rb +3 -3
  41. data/lib/puppet/functions/epp.rb +4 -4
  42. data/lib/puppet/functions/inline_epp.rb +5 -5
  43. data/lib/puppet/functions/new.rb +8 -3
  44. data/lib/puppet/functions/reduce.rb +2 -4
  45. data/lib/puppet/functions/reverse_each.rb +1 -1
  46. data/lib/puppet/functions/step.rb +1 -1
  47. data/lib/puppet/gettext/module_translations.rb +1 -1
  48. data/lib/puppet/graph/rb_tree_map.rb +2 -2
  49. data/lib/puppet/graph/simple_graph.rb +6 -5
  50. data/lib/puppet/indirector/catalog/compiler.rb +8 -0
  51. data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
  52. data/lib/puppet/indirector/hiera.rb +6 -0
  53. data/lib/puppet/indirector/resource/ral.rb +1 -3
  54. data/lib/puppet/indirector/resource/validator.rb +1 -1
  55. data/lib/puppet/interface.rb +2 -1
  56. data/lib/puppet/loaders.rb +0 -1
  57. data/lib/puppet/metatype/manager.rb +1 -1
  58. data/lib/puppet/module.rb +1 -1
  59. data/lib/puppet/module_tool/applications/builder.rb +1 -1
  60. data/lib/puppet/module_tool/applications/installer.rb +1 -1
  61. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
  62. data/lib/puppet/module_tool/metadata.rb +1 -1
  63. data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
  64. data/lib/puppet/module_tool/tar/mini.rb +1 -1
  65. data/lib/puppet/network/http/api/indirected_routes.rb +13 -12
  66. data/lib/puppet/network/http/api/master/v3/environment.rb +3 -0
  67. data/lib/puppet/network/http/connection.rb +14 -12
  68. data/lib/puppet/network/http/pool.rb +7 -1
  69. data/lib/puppet/network/http/rack/rest.rb +2 -2
  70. data/lib/puppet/network/http/site.rb +1 -1
  71. data/lib/puppet/network/resolver.rb +2 -2
  72. data/lib/puppet/node/environment.rb +11 -3
  73. data/lib/puppet/parser/ast.rb +1 -1
  74. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  75. data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +2 -0
  76. data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +2 -0
  77. data/lib/puppet/parser/environment_compiler.rb +3 -0
  78. data/lib/puppet/parser/functions.rb +14 -10
  79. data/lib/puppet/parser/functions/epp.rb +3 -3
  80. data/lib/puppet/parser/functions/inline_epp.rb +5 -5
  81. data/lib/puppet/parser/resource.rb +3 -2
  82. data/lib/puppet/parser/resource/param.rb +6 -0
  83. data/lib/puppet/pops/adaptable.rb +7 -13
  84. data/lib/puppet/pops/adapters.rb +8 -4
  85. data/lib/puppet/pops/evaluator/access_operator.rb +2 -2
  86. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -3
  87. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
  88. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
  89. data/lib/puppet/pops/evaluator/evaluator_impl.rb +1 -1
  90. data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -2
  91. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
  92. data/lib/puppet/pops/issues.rb +5 -0
  93. data/lib/puppet/pops/loaders.rb +1 -1
  94. data/lib/puppet/pops/lookup/hiera_config.rb +1 -0
  95. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  96. data/lib/puppet/pops/merge_strategy.rb +22 -18
  97. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  98. data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
  99. data/lib/puppet/pops/parser/locator.rb +1 -1
  100. data/lib/puppet/pops/parser/pn_parser.rb +17 -16
  101. data/lib/puppet/pops/puppet_stack.rb +51 -48
  102. data/lib/puppet/pops/resource/resource_type_impl.rb +2 -0
  103. data/lib/puppet/pops/types/iterable.rb +34 -8
  104. data/lib/puppet/pops/types/p_meta_type.rb +1 -1
  105. data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
  106. data/lib/puppet/pops/types/p_type_set_type.rb +4 -0
  107. data/lib/puppet/pops/types/string_converter.rb +10 -10
  108. data/lib/puppet/pops/types/type_calculator.rb +24 -0
  109. data/lib/puppet/pops/types/types.rb +3 -3
  110. data/lib/puppet/pops/validation/checker4_0.rb +29 -15
  111. data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -0
  112. data/lib/puppet/property.rb +1 -1
  113. data/lib/puppet/property/ensure.rb +1 -1
  114. data/lib/puppet/provider/augeas/augeas.rb +1 -1
  115. data/lib/puppet/provider/cron/crontab.rb +1 -1
  116. data/lib/puppet/provider/exec.rb +6 -2
  117. data/lib/puppet/provider/group/groupadd.rb +19 -19
  118. data/lib/puppet/provider/group/windows_adsi.rb +3 -3
  119. data/lib/puppet/provider/mailalias/aliases.rb +1 -1
  120. data/lib/puppet/provider/mount.rb +1 -1
  121. data/lib/puppet/provider/mount/parsed.rb +8 -8
  122. data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
  123. data/lib/puppet/provider/nameservice/pw.rb +2 -2
  124. data/lib/puppet/provider/package/aix.rb +17 -2
  125. data/lib/puppet/provider/package/apt.rb +14 -3
  126. data/lib/puppet/provider/package/dnfmodule.rb +141 -0
  127. data/lib/puppet/provider/package/dpkg.rb +16 -18
  128. data/lib/puppet/provider/package/fink.rb +20 -3
  129. data/lib/puppet/provider/package/gem.rb +4 -2
  130. data/lib/puppet/provider/package/openbsd.rb +14 -2
  131. data/lib/puppet/provider/package/pip.rb +37 -10
  132. data/lib/puppet/provider/package/pkg.rb +18 -5
  133. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  134. data/lib/puppet/provider/package/pkgng.rb +16 -4
  135. data/lib/puppet/provider/package/portage.rb +4 -4
  136. data/lib/puppet/provider/package/puppet_gem.rb +5 -0
  137. data/lib/puppet/provider/package/rpm.rb +6 -6
  138. data/lib/puppet/provider/package/windows/package.rb +1 -1
  139. data/lib/puppet/provider/package/yum.rb +28 -20
  140. data/lib/puppet/provider/package/zypper.rb +1 -0
  141. data/lib/puppet/provider/package_targetable.rb +5 -4
  142. data/lib/puppet/provider/parsedfile.rb +1 -1
  143. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +3 -3
  144. data/lib/puppet/provider/selmodule/semodule.rb +43 -26
  145. data/lib/puppet/provider/service/daemontools.rb +9 -9
  146. data/lib/puppet/provider/service/openbsd.rb +1 -1
  147. data/lib/puppet/provider/service/rcng.rb +2 -2
  148. data/lib/puppet/provider/service/runit.rb +2 -8
  149. data/lib/puppet/provider/service/systemd.rb +31 -13
  150. data/lib/puppet/provider/user/directoryservice.rb +31 -6
  151. data/lib/puppet/provider/user/hpux.rb +1 -1
  152. data/lib/puppet/provider/user/user_role_add.rb +1 -1
  153. data/lib/puppet/provider/user/useradd.rb +39 -20
  154. data/lib/puppet/provider/user/windows_adsi.rb +4 -5
  155. data/lib/puppet/provider/yumrepo/inifile.rb +2 -2
  156. data/lib/puppet/reference/indirection.rb +2 -2
  157. data/lib/puppet/reference/metaparameter.rb +1 -3
  158. data/lib/puppet/reference/providers.rb +1 -1
  159. data/lib/puppet/reference/type.rb +3 -9
  160. data/lib/puppet/reports.rb +1 -1
  161. data/lib/puppet/resource.rb +1 -1
  162. data/lib/puppet/resource/catalog.rb +1 -1
  163. data/lib/puppet/resource/type.rb +10 -1
  164. data/lib/puppet/settings.rb +3 -3
  165. data/lib/puppet/settings/environment_conf.rb +1 -0
  166. data/lib/puppet/ssl/certificate.rb +2 -1
  167. data/lib/puppet/ssl/certificate_authority.rb +6 -5
  168. data/lib/puppet/ssl/certificate_authority/interface.rb +1 -1
  169. data/lib/puppet/ssl/certificate_factory.rb +2 -2
  170. data/lib/puppet/ssl/host.rb +3 -3
  171. data/lib/puppet/ssl/oids.rb +1 -1
  172. data/lib/puppet/test/test_helper.rb +20 -12
  173. data/lib/puppet/transaction/report.rb +1 -1
  174. data/lib/puppet/transaction/resource_harness.rb +1 -1
  175. data/lib/puppet/type.rb +8 -4
  176. data/lib/puppet/type/cron.rb +1 -1
  177. data/lib/puppet/type/exec.rb +7 -3
  178. data/lib/puppet/type/file.rb +14 -2
  179. data/lib/puppet/type/file/data_sync.rb +5 -1
  180. data/lib/puppet/type/group.rb +4 -2
  181. data/lib/puppet/type/interface.rb +1 -1
  182. data/lib/puppet/type/notify.rb +3 -2
  183. data/lib/puppet/type/package.rb +97 -8
  184. data/lib/puppet/type/schedule.rb +1 -1
  185. data/lib/puppet/type/selboolean.rb +17 -3
  186. data/lib/puppet/type/service.rb +2 -8
  187. data/lib/puppet/type/user.rb +5 -9
  188. data/lib/puppet/util.rb +35 -12
  189. data/lib/puppet/util/autoload.rb +9 -7
  190. data/lib/puppet/util/command_line/trollop.rb +1 -1
  191. data/lib/puppet/util/http_proxy.rb +8 -14
  192. data/lib/puppet/util/instance_loader.rb +1 -1
  193. data/lib/puppet/util/log.rb +1 -1
  194. data/lib/puppet/util/log/destinations.rb +3 -12
  195. data/lib/puppet/util/logging.rb +30 -18
  196. data/lib/puppet/util/metric.rb +2 -2
  197. data/lib/puppet/util/monkey_patches.rb +1 -1
  198. data/lib/puppet/util/nagios_maker.rb +2 -2
  199. data/lib/puppet/util/network_device/cisco/device.rb +1 -1
  200. data/lib/puppet/util/network_device/cisco/interface.rb +2 -2
  201. data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
  202. data/lib/puppet/util/pidlock.rb +12 -6
  203. data/lib/puppet/util/plist.rb +6 -0
  204. data/lib/puppet/util/provider_features.rb +2 -4
  205. data/lib/puppet/util/rdoc.rb +1 -1
  206. data/lib/puppet/util/reference.rb +1 -1
  207. data/lib/puppet/util/resource_template.rb +1 -1
  208. data/lib/puppet/util/selinux.rb +3 -1
  209. data/lib/puppet/util/windows/adsi.rb +60 -30
  210. data/lib/puppet/util/windows/api_types.rb +45 -32
  211. data/lib/puppet/util/windows/eventlog.rb +1 -6
  212. data/lib/puppet/util/windows/principal.rb +8 -6
  213. data/lib/puppet/util/windows/process.rb +16 -15
  214. data/lib/puppet/util/windows/registry.rb +17 -15
  215. data/lib/puppet/util/windows/security.rb +1 -0
  216. data/lib/puppet/util/windows/sid.rb +3 -3
  217. data/lib/puppet/vendor.rb +1 -1
  218. data/lib/puppet/version.rb +1 -1
  219. data/lib/puppet_pal.rb +2 -2
  220. data/locales/puppet.pot +362 -318
  221. data/man/man5/puppet.conf.5 +39 -9
  222. data/man/man8/puppet-agent.8 +2 -2
  223. data/man/man8/puppet-apply.8 +1 -1
  224. data/man/man8/puppet-ca.8 +1 -1
  225. data/man/man8/puppet-catalog.8 +1 -1
  226. data/man/man8/puppet-cert.8 +1 -1
  227. data/man/man8/puppet-certificate.8 +1 -1
  228. data/man/man8/puppet-certificate_request.8 +1 -1
  229. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  230. data/man/man8/puppet-config.8 +1 -1
  231. data/man/man8/puppet-describe.8 +1 -1
  232. data/man/man8/puppet-device.8 +1 -1
  233. data/man/man8/puppet-doc.8 +1 -1
  234. data/man/man8/puppet-epp.8 +1 -1
  235. data/man/man8/puppet-facts.8 +1 -1
  236. data/man/man8/puppet-filebucket.8 +16 -1
  237. data/man/man8/puppet-generate.8 +1 -1
  238. data/man/man8/puppet-help.8 +1 -1
  239. data/man/man8/puppet-key.8 +1 -1
  240. data/man/man8/puppet-lookup.8 +1 -1
  241. data/man/man8/puppet-man.8 +1 -1
  242. data/man/man8/puppet-master.8 +1 -1
  243. data/man/man8/puppet-module.8 +1 -1
  244. data/man/man8/puppet-node.8 +1 -1
  245. data/man/man8/puppet-parser.8 +1 -1
  246. data/man/man8/puppet-plugin.8 +1 -1
  247. data/man/man8/puppet-report.8 +1 -1
  248. data/man/man8/puppet-resource.8 +1 -1
  249. data/man/man8/puppet-script.8 +1 -1
  250. data/man/man8/puppet-status.8 +1 -1
  251. data/man/man8/puppet.8 +2 -2
  252. data/spec/fixtures/integration/provider/mailalias/aliases/test1 +1 -0
  253. data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list.txt +19 -0
  254. data/spec/fixtures/unit/provider/package/pkgng/pkg.version +2 -0
  255. data/spec/fixtures/unit/provider/package/yum/yum-check-update-subscription-manager.txt +9 -0
  256. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +9 -0
  257. data/spec/integration/configurer_spec.rb +66 -0
  258. data/spec/integration/data_binding_spec.rb +1 -0
  259. data/spec/integration/defaults_spec.rb +1 -2
  260. data/spec/integration/faces/plugin_spec.rb +29 -47
  261. data/spec/integration/indirector/facts/facter_spec.rb +4 -0
  262. data/spec/integration/parser/compiler_spec.rb +11 -0
  263. data/spec/integration/type/notify_spec.rb +46 -0
  264. data/spec/integration/util/windows/adsi_spec.rb +6 -1
  265. data/spec/integration/util/windows/registry_spec.rb +7 -7
  266. data/spec/shared_contexts/types_setup.rb +2 -0
  267. data/spec/unit/agent_spec.rb +34 -26
  268. data/spec/unit/application/apply_spec.rb +2 -12
  269. data/spec/unit/configurer/downloader_spec.rb +10 -0
  270. data/spec/unit/configurer/fact_handler_spec.rb +0 -4
  271. data/spec/unit/configurer_spec.rb +430 -415
  272. data/spec/unit/daemon_spec.rb +0 -1
  273. data/spec/unit/file_serving/mount/locales_spec.rb +2 -2
  274. data/spec/unit/file_serving/mount/pluginfacts_spec.rb +2 -2
  275. data/spec/unit/file_serving/mount/plugins_spec.rb +2 -2
  276. data/spec/unit/file_system/uniquefile_spec.rb +11 -0
  277. data/spec/unit/forge/forge_spec.rb +1 -3
  278. data/spec/unit/forge/repository_spec.rb +1 -3
  279. data/spec/unit/indirector/catalog/compiler_spec.rb +45 -26
  280. data/spec/unit/indirector/resource/ral_spec.rb +4 -4
  281. data/spec/unit/network/http/api/indirected_routes_spec.rb +2 -1
  282. data/spec/unit/network/http/connection_spec.rb +43 -1
  283. data/spec/unit/network/http/pool_spec.rb +32 -0
  284. data/spec/unit/node_spec.rb +7 -4
  285. data/spec/unit/parser/environment_compiler_spec.rb +7 -0
  286. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +8 -3
  287. data/spec/unit/provider/exec_spec.rb +209 -0
  288. data/spec/unit/provider/group/groupadd_spec.rb +30 -1
  289. data/spec/unit/provider/group/windows_adsi_spec.rb +43 -10
  290. data/spec/unit/provider/package/aix_spec.rb +29 -0
  291. data/spec/unit/provider/package/apt_spec.rb +13 -2
  292. data/spec/unit/provider/package/aptitude_spec.rb +1 -0
  293. data/spec/unit/provider/package/dnfmodule_spec.rb +247 -0
  294. data/spec/unit/provider/package/dpkg_spec.rb +35 -7
  295. data/spec/unit/provider/package/openbsd_spec.rb +17 -0
  296. data/spec/unit/provider/package/pip_spec.rb +93 -22
  297. data/spec/unit/provider/package/pkg_spec.rb +13 -1
  298. data/spec/unit/provider/package/pkgdmg_spec.rb +1 -1
  299. data/spec/unit/provider/package/pkgng_spec.rb +36 -0
  300. data/spec/unit/provider/package/portage_spec.rb +4 -4
  301. data/spec/unit/provider/package/puppet_gem_spec.rb +4 -1
  302. data/spec/unit/provider/package/yum_spec.rb +90 -0
  303. data/spec/unit/provider/package/zypper_spec.rb +13 -0
  304. data/spec/unit/provider/package_targetable_spec.rb +60 -0
  305. data/spec/unit/provider/selmodule_spec.rb +118 -47
  306. data/spec/unit/provider/service/daemontools_spec.rb +24 -0
  307. data/spec/unit/provider/service/runit_spec.rb +24 -0
  308. data/spec/unit/provider/service/systemd_spec.rb +109 -36
  309. data/spec/unit/provider/user/directoryservice_spec.rb +41 -0
  310. data/spec/unit/provider/user/hpux_spec.rb +2 -2
  311. data/spec/unit/provider/user/openbsd_spec.rb +1 -0
  312. data/spec/unit/provider/user/useradd_spec.rb +81 -16
  313. data/spec/unit/provider/user/windows_adsi_spec.rb +3 -3
  314. data/spec/unit/puppet_pal_2pec.rb +3 -0
  315. data/spec/unit/ssl/certificate_authority_spec.rb +2 -3
  316. data/spec/unit/ssl/certificate_spec.rb +7 -0
  317. data/spec/unit/ssl/host_spec.rb +2 -0
  318. data/spec/unit/test/test_helper_spec.rb +17 -0
  319. data/spec/unit/type/exec_spec.rb +6 -12
  320. data/spec/unit/type/file/content_spec.rb +9 -3
  321. data/spec/unit/type/file_spec.rb +9 -4
  322. data/spec/unit/type/package_spec.rb +8 -0
  323. data/spec/unit/type/selboolean_spec.rb +4 -6
  324. data/spec/unit/type/service_spec.rb +9 -8
  325. data/spec/unit/type/user_spec.rb +19 -13
  326. data/spec/unit/util/execution_spec.rb +16 -0
  327. data/spec/unit/util/http_proxy_spec.rb +97 -0
  328. data/spec/unit/util/log/destinations_spec.rb +2 -26
  329. data/spec/unit/util/log_spec.rb +0 -138
  330. data/spec/unit/util/logging_spec.rb +200 -0
  331. data/spec/unit/util/pidlock_spec.rb +67 -40
  332. data/spec/unit/util/plist_spec.rb +20 -0
  333. data/spec/unit/util/windows/adsi_spec.rb +55 -4
  334. data/spec/unit/util/windows/api_types_spec.rb +104 -40
  335. data/spec/unit/util/windows/sid_spec.rb +2 -2
  336. data/tasks/manpages.rake +1 -0
  337. metadata +16 -7
  338. data/lib/puppet/pops/loader/null_loader.rb +0 -60
  339. data/locales/ja/puppet.po +0 -12114
  340. data/spec/integration/test/test_helper_spec.rb +0 -31
@@ -395,4 +395,21 @@ describe Puppet::Type.type(:package).provider(:openbsd) do
395
395
  end
396
396
  end
397
397
  end
398
+
399
+ context "#flavor" do
400
+ before do
401
+ provider.instance_variable_get('@property_hash')[:flavor] = 'no_x11-python'
402
+ end
403
+
404
+ it 'should return the existing flavor' do
405
+ expect(provider.flavor).to eq('no_x11-python')
406
+ end
407
+
408
+ it 'should remove and install the new flavor if different' do
409
+ provider.resource[:flavor] = 'no_x11-ruby'
410
+ expect(provider).to receive(:uninstall).ordered
411
+ expect(provider).to receive(:install).ordered
412
+ provider.flavor = provider.resource[:flavor]
413
+ end
414
+ end
398
415
  end
@@ -1,6 +1,7 @@
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
+ pip_path_with_spaces = 'C:\Program Files (x86)\Python\Scripts\pip.exe'
4
5
 
5
6
  describe Puppet::Type.type(:package).provider(:pip) do
6
7
 
@@ -93,6 +94,16 @@ describe Puppet::Type.type(:package).provider(:pip) do
93
94
  expect(described_class.instances).to eq([])
94
95
  end
95
96
  end
97
+
98
+ context "when pip path location contains spaces" do
99
+ it "should quote the command before doing execpipe" do
100
+ allow(described_class).to receive(:which).and_return(pip_path_with_spaces)
101
+ allow(described_class).to receive(:pip_version).with(pip_path_with_spaces).and_return('8.0.1')
102
+
103
+ expect(described_class).to receive(:execpipe).with(["\"#{pip_path_with_spaces}\"", ["freeze"]])
104
+ described_class.instances
105
+ end
106
+ end
96
107
  end
97
108
 
98
109
  context "query" do
@@ -143,15 +154,18 @@ describe Puppet::Type.type(:package).provider(:pip) do
143
154
  end
144
155
 
145
156
  context "latest" do
157
+ before do
158
+ allow(described_class).to receive(:pip_version).with(pip_path).and_return(pip_version)
159
+ allow(described_class).to receive(:which).with('pip').and_return(pip_path)
160
+ allow(described_class).to receive(:which).with('pip-python').and_return(pip_path)
161
+ allow(described_class).to receive(:which).with('pip.exe').and_return(pip_path)
162
+ allow(described_class).to receive(:provider_command).and_return(pip_path)
163
+ allow(described_class).to receive(:validate_command).with(pip_path)
164
+ end
165
+
146
166
  context "with pip version < 1.5.4" do
147
- before :each do
148
- allow(described_class).to receive(:pip_version).with("/fake/bin/pip").and_return('1.0.1')
149
- allow(described_class).to receive(:which).with('pip').and_return("/fake/bin/pip")
150
- allow(described_class).to receive(:which).with('pip-python').and_return("/fake/bin/pip")
151
- allow(described_class).to receive(:which).with('pip.exe').and_return("/fake/bin/pip")
152
- allow(described_class).to receive(:provider_command).and_return('/fake/bin/pip')
153
- allow(described_class).to receive(:validate_command).with('/fake/bin/pip')
154
- end
167
+ let(:pip_version) { '1.0.1' }
168
+ let(:pip_path) { '/fake/bin/pip' }
155
169
 
156
170
  it "should find a version number for new_pip_package" do
157
171
  p = StringIO.new(
@@ -197,19 +211,29 @@ describe Puppet::Type.type(:package).provider(:pip) do
197
211
  @resource[:name] = "fake_package"
198
212
  expect(@provider.latest).to eq(nil)
199
213
  end
214
+
215
+ it "should use 'install_options' when specified" do
216
+ expect(Puppet::Util::Execution).to receive(:execpipe).with(array_including([["--index=https://fake.example.com"]])).once
217
+ @resource[:name] = "fake_package"
218
+ @resource[:install_options] = ['--index' => 'https://fake.example.com']
219
+ expect(@provider.latest).to eq(nil)
220
+ end
221
+
222
+ context "when pip path location contains spaces" do
223
+ let(:pip_path) { pip_path_with_spaces }
224
+
225
+ it "should quote the command before doing execpipe" do
226
+ expect(Puppet::Util::Execution).to receive(:execpipe).with(array_including("\"#{pip_path}\""))
227
+ @provider.latest
228
+ end
229
+ end
200
230
  end
201
231
 
202
232
  context "with pip version >= 1.5.4" do
203
233
  # For Pip 1.5.4 and above, you can get a version list from CLI - which allows for native pip behavior
204
234
  # with regards to custom repositories, proxies and the like
205
- before :each do
206
- allow(described_class).to receive(:pip_version).with("/fake/bin/pip").and_return('1.5.4')
207
- allow(described_class).to receive(:which).with('pip').and_return("/fake/bin/pip")
208
- allow(described_class).to receive(:which).with('pip-python').and_return("/fake/bin/pip")
209
- allow(described_class).to receive(:which).with('pip.exe').and_return("/fake/bin/pip")
210
- allow(described_class).to receive(:provider_command).and_return('/fake/bin/pip')
211
- allow(described_class).to receive(:validate_command).with('/fake/bin/pip')
212
- end
235
+ let(:pip_version) { '1.5.4' }
236
+ let(:pip_path) { '/fake/bin/pip' }
213
237
 
214
238
  it "should find a version number for real_package" do
215
239
  p = StringIO.new(
@@ -251,6 +275,22 @@ describe Puppet::Type.type(:package).provider(:pip) do
251
275
  latest = @provider.latest
252
276
  expect(latest).to eq('15.0.2')
253
277
  end
278
+
279
+ it "should use 'install_options' when specified" do
280
+ expect(Puppet::Util::Execution).to receive(:execpipe).with(array_including([["--index=https://fake.example.com"]])).once
281
+ @resource[:name] = "fake_package"
282
+ @resource[:install_options] = ['--index' => 'https://fake.example.com']
283
+ expect(@provider.latest).to eq(nil)
284
+ end
285
+
286
+ context "when pip path location contains spaces" do
287
+ let(:pip_path) { pip_path_with_spaces }
288
+
289
+ it "should quote the command before doing execpipe" do
290
+ expect(Puppet::Util::Execution).to receive(:execpipe).with(array_including("\"#{pip_path}\""))
291
+ @provider.latest
292
+ end
293
+ end
254
294
  end
255
295
  end
256
296
 
@@ -341,12 +381,43 @@ describe Puppet::Type.type(:package).provider(:pip) do
341
381
  end
342
382
 
343
383
  context "pip_version" do
384
+ let(:pip) { '/fake/bin/pip' }
385
+
344
386
  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')
387
+ allow(described_class).to receive(:pip_cmd).and_return(pip)
388
+ process = ['pip 8.0.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)']
389
+ allow(described_class).to receive(:execpipe).with([pip, '--version']).and_yield(process)
390
+
391
+ expect(described_class.pip_version(pip)).to eq('8.0.2')
392
+ end
393
+
394
+ it "parses multiple lines of output" do
395
+ allow(described_class).to receive(:pip_cmd).and_return(pip)
396
+ process = [
397
+ "/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",
398
+ " DependencyWarning",
399
+ "pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)"
400
+ ]
401
+ allow(described_class).to receive(:execpipe).with([pip, '--version']).and_yield(process)
402
+
403
+ expect(described_class.pip_version(pip)).to eq('1.5.6')
404
+ end
405
+
406
+ it "raises if there isn't a version string" do
407
+ allow(described_class).to receive(:pip_cmd).and_return(pip)
408
+ allow(described_class).to receive(:execpipe).with([pip, '--version']).and_yield([""])
409
+ expect {
410
+ described_class.pip_version(pip)
411
+ }.to raise_error(Puppet::Error, 'Cannot resolve pip version')
412
+ end
413
+
414
+ it "quotes commands with spaces" do
415
+ pip = 'C:\Program Files\Python27\Scripts\pip.exe'
416
+ allow(described_class).to receive(:pip_cmd).and_return(pip)
417
+ process = ["pip 18.1 from c:\program files\python27\lib\site-packages\pip (python 2.7)\r\n"]
418
+ allow(described_class).to receive(:execpipe).with(["\"#{pip}\"", '--version']).and_yield(process)
419
+
420
+ expect(described_class.pip_version(pip)).to eq('18.1')
350
421
  end
351
422
  end
352
423
 
@@ -90,7 +90,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
90
90
 
91
91
  {
92
92
  'pkg://omnios/SUNWcs@0.5.11,5.11-0.151006:20130506T161045Z i--' => {:name => 'SUNWcs', :ensure => '0.5.11,5.11-0.151006:20130506T161045Z', :status => 'installed', :provider => :pkg, :publisher => 'omnios'},
93
- 'pkg://omnios/incorporation/jeos/illumos-gate@11,5.11-0.151006:20130506T183443Z if-' => {:name => 'incorporation/jeos/illumos-gate', :ensure => 'held', :status => 'installed', :provider => :pkg, :publisher => 'omnios'},
93
+ 'pkg://omnios/incorporation/jeos/illumos-gate@11,5.11-0.151006:20130506T183443Z if-' => {:name => 'incorporation/jeos/illumos-gate', :ensure => "11,5.11-0.151006:20130506T183443Z", :mark => :hold, :status => 'installed', :provider => :pkg, :publisher => 'omnios'},
94
94
  'pkg://solaris/SUNWcs@0.5.11,5.11-0.151.0.1:20101105T001108Z installed -----' => {:name => 'SUNWcs', :ensure => '0.5.11,5.11-0.151.0.1:20101105T001108Z', :status => 'installed', :provider => :pkg, :publisher => 'solaris'},
95
95
  }.each do |k, v|
96
96
  it "[#{k}] should correctly parse" do
@@ -251,6 +251,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
251
251
 
252
252
  it "should accept all licenses" do
253
253
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => :absent})
254
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
254
255
  expect(Puppet::Util::Execution).to receive(:execute)
255
256
  .with(['/bin/pkg', 'install', *hash[:flags], 'dummy'], {:failonfail => false, :combine => true})
256
257
  .and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))
@@ -265,6 +266,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
265
266
  # Should install also check if the version installed is the same version we are asked to install? or should we rely on puppet for that?
266
267
  resource[:ensure] = '0.0.7,5.11-0.151006:20131230T130000Z'
267
268
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
269
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
268
270
  expect(Puppet::Util::Execution).to receive(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
269
271
  expect(Puppet::Util::Execution).to receive(:execute)
270
272
  .with(['/bin/pkg', 'list', '-Hv', 'dummy'], {:failonfail => false, :combine => true})
@@ -277,6 +279,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
277
279
 
278
280
  it "should install specific version(2)" do
279
281
  resource[:ensure] = '0.0.8'
282
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
280
283
  expect(Puppet::Util::Execution).to receive(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
281
284
  expect(Puppet::Util::Execution).to receive(:execute)
282
285
  .with(['/bin/pkg', 'list', '-Hv', 'dummy'], {:failonfail => false, :combine => true})
@@ -290,6 +293,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
290
293
 
291
294
  it "should downgrade to specific version" do
292
295
  resource[:ensure] = '0.0.7'
296
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
293
297
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => '0.0.8,5.11-0.151106:20131230T130000Z'})
294
298
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
295
299
  expect(Puppet::Util::Execution).to receive(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
@@ -301,6 +305,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
301
305
 
302
306
  it "should install any if version is not specified" do
303
307
  resource[:ensure] = :present
308
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
304
309
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => :absent})
305
310
  expect(Puppet::Util::Execution).to receive(:execute)
306
311
  .with(['/bin/pkg', 'install', *hash[:flags], 'dummy'], {:failonfail => false, :combine => true})
@@ -312,6 +317,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
312
317
 
313
318
  it "should install if no version was previously installed, and a specific version was requested" do
314
319
  resource[:ensure] = '0.0.7'
320
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
315
321
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => :absent})
316
322
  expect(Puppet::Util::Execution).to receive(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
317
323
  expect(Puppet::Util::Execution).to receive(:execute)
@@ -325,6 +331,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
325
331
  resource[:ensure] = '1.0-0.151006'
326
332
  is = :absent
327
333
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => is})
334
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
328
335
  expect(described_class).to receive(:pkg)
329
336
  .with(:list, '-Hvfa', 'dummy@1.0-0.151006')
330
337
  .and_return(Puppet::Util::Execution::ProcessOutput.new(File.read(my_fixture('dummy_implicit_version')), 0))
@@ -340,6 +347,7 @@ describe Puppet::Type.type(:package).provider(:pkg) do
340
347
  resource[:ensure] = '1.0-0.151006'
341
348
  is = '1.0,5.11-0.151006:20140219T191204Z'
342
349
  expect(provider).to receive(:query).with(no_args).and_return({:ensure => is})
350
+ expect(provider).to receive(:properties).and_return({:mark => :hold})
343
351
  expect(described_class).to receive(:pkg).with(:list, '-Hvfa', 'dummy@1.0-0.151006').and_return(File.read(my_fixture('dummy_implicit_version')))
344
352
  expect(Puppet::Util::Execution).to receive(:execute).with(['/bin/pkg', 'update', '-n', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
345
353
  expect(provider).to receive(:unhold).with(no_args)
@@ -398,12 +406,16 @@ describe Puppet::Type.type(:package).provider(:pkg) do
398
406
  it "should support current pkg version" do
399
407
  expect(described_class).to receive(:pkg).with(:version).and_return('630e1ffc7a19')
400
408
  expect(described_class).to receive(:pkg).with([:uninstall, resource[:name]])
409
+ expect(provider).to receive(:properties).and_return({:hold => false})
410
+
401
411
  provider.uninstall
402
412
  end
403
413
 
404
414
  it "should support original pkg commands" do
405
415
  expect(described_class).to receive(:pkg).with(:version).and_return('052adf36c3f4')
406
416
  expect(described_class).to receive(:pkg).with([:uninstall, '-r', resource[:name]])
417
+ expect(provider).to receive(:properties).and_return({:hold => false})
418
+
407
419
  provider.uninstall
408
420
  end
409
421
  end
@@ -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
@@ -169,6 +193,18 @@ describe Puppet::Type.type(:package).provider(:pkgng) do
169
193
  bash_comp_latest_version = described_class.get_latest_version('shells/bash-completion', version_list)
170
194
  expect(bash_comp_latest_version).to eq('2.1_3')
171
195
  end
196
+
197
+ it "should return nil when the package is orphaned" do
198
+ version_list = File.read(my_fixture('pkg.version'))
199
+ orphan_latest_version = described_class.get_latest_version('sysutils/orphan', version_list)
200
+ expect(orphan_latest_version).to be_nil
201
+ end
202
+
203
+ it "should return nil when the package is broken" do
204
+ version_list = File.read(my_fixture('pkg.version'))
205
+ broken_latest_version = described_class.get_latest_version('sysutils/broken', version_list)
206
+ expect(broken_latest_version).to be_nil
207
+ end
172
208
  end
173
209
 
174
210
  describe "confine" do
@@ -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
@@ -20,7 +20,10 @@ describe Puppet::Type.type(:package).provider(:puppet_gem) do
20
20
  let(:provider_gem_cmd) { '/opt/puppetlabs/puppet/bin/gem' }
21
21
  end
22
22
 
23
- let(:execute_options) { {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}} }
23
+ custom_environment = {"HOME"=>ENV["HOME"]}
24
+ custom_environment['PKG_CONFIG_PATH'] = '/opt/puppetlabs/puppet/lib/pkgconfig' unless Puppet::Util::Platform.windows?
25
+
26
+ let(:execute_options) { {:failonfail => true, :combine => true, :custom_environment => custom_environment} }
24
27
 
25
28
  before :each do
26
29
  resource.provider = provider
@@ -54,6 +54,87 @@ describe Puppet::Type.type(:package).provider(:yum) do
54
54
  provider.install
55
55
  end
56
56
  end
57
+
58
+ describe 'with install_options' do
59
+ it 'can parse disable-repo with array of strings' do
60
+ resource[:install_options] = ['--disable-repo=dev*', '--disable-repo=prod*']
61
+ expect(provider).to receive(:execute) do | arr|
62
+ expect(arr[-3]).to eq(["--disable-repo=dev*", "--disable-repo=prod*"])
63
+ end
64
+ provider.install
65
+ end
66
+
67
+ it 'can parse disable-repo with array of hashes' do
68
+ resource[:install_options] = [{'--disable-repo' => 'dev*'}, {'--disable-repo' => 'prod*'}]
69
+ expect(provider).to receive(:execute) do | arr|
70
+ expect(arr[-3]).to eq(["--disable-repo=dev*", "--disable-repo=prod*"])
71
+ end
72
+ provider.install
73
+ end
74
+
75
+ it 'can parse enable-repo with array of strings' do
76
+ resource[:install_options] = ['--enable-repo=dev*', '--enable-repo=prod*']
77
+ expect(provider).to receive(:execute) do | arr|
78
+ expect(arr[-3]).to eq(["--enable-repo=dev*", "--enable-repo=prod*"])
79
+ end
80
+ provider.install
81
+ end
82
+
83
+ it 'can parse enable-repo with array of hashes' do
84
+ resource[:install_options] = [{'--enable-repo' => 'dev*'}, {'--disable-repo' => 'prod*'}]
85
+ expect(provider).to receive(:execute) do | arr|
86
+ expect(arr[-3]).to eq(["--enable-repo=dev*", "--disable-repo=prod*"])
87
+ end
88
+ provider.install
89
+ end
90
+
91
+ it 'can parse enable-repo with single hash' do
92
+ resource[:install_options] = [{'--enable-repo' => 'dev*','--disable-repo' => 'prod*'}]
93
+ expect(provider).to receive(:execute) do | arr|
94
+ expect(arr[-3]).to eq(["--disable-repo=prod*", "--enable-repo=dev*"])
95
+ end
96
+ provider.install
97
+ end
98
+
99
+ it 'can parse enable-repo with empty array' do
100
+ resource[:install_options] = []
101
+ expect(provider).to receive(:execute) do | arr|
102
+ expect(arr[-3]).to eq([])
103
+ end
104
+ provider.install
105
+ end
106
+ end
107
+ end
108
+
109
+ context "latest" do
110
+ let(:name) { 'baz' }
111
+
112
+ let(:resource) do
113
+ Puppet::Type.type(:package).new(
114
+ :name => name,
115
+ :provider => 'yum',
116
+ )
117
+ end
118
+
119
+ let(:provider) do
120
+ provider = described_class.new
121
+ provider.resource = resource
122
+ provider
123
+ end
124
+
125
+ before {
126
+ allow(described_class).to receive(:command).with(:cmd).and_return("/usr/bin/yum")
127
+ Puppet[:log_level] = 'debug'
128
+ }
129
+
130
+ it "should print a debug message with the current version if newer package is not available" do
131
+ expect(provider).to receive(:query).and_return({:ensure => "1.2.3"})
132
+ expect(described_class).to receive(:latest_package_version).and_return(nil)
133
+ resource[:ensure] = :present
134
+
135
+ provider.latest
136
+ expect(@logs).to include(an_object_having_attributes(level: :debug, message: "Yum didn't find updates, current version (1.2.3) is the latest"))
137
+ end
57
138
  end
58
139
 
59
140
  context "parsing the output of check-update" do
@@ -144,5 +225,14 @@ describe Puppet::Type.type(:package).provider(:yum) do
144
225
  expect(output).not_to include("Random plugin")
145
226
  end
146
227
  end
228
+
229
+ context "with subscription manager enabled " do
230
+ let(:check_update) { File.read(my_fixture("yum-check-update-subscription-manager.txt")) }
231
+ let(:output) { described_class.parse_updates(check_update) }
232
+
233
+ it "parses correctly formatted entries" do
234
+ expect(output['curl.x86_64']).to eq([{:name => 'curl', :epoch => '0', :version => '7.32.0', :release => '10.fc20', :arch => 'x86_64'}])
235
+ end
236
+ end
147
237
  end
148
238
  end