chef 15.11.3-universal-mingw32 → 16.1.16-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (513) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -7
  3. data/README.md +1 -1
  4. data/Rakefile +44 -16
  5. data/chef.gemspec +6 -4
  6. data/distro/powershell/chef/chef.psm1 +3 -3
  7. data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
  8. data/lib/chef/action_collection.rb +16 -5
  9. data/lib/chef/application.rb +33 -54
  10. data/lib/chef/application/apply.rb +18 -1
  11. data/lib/chef/application/base.rb +8 -3
  12. data/lib/chef/application/knife.rb +1 -1
  13. data/lib/chef/chef_class.rb +4 -4
  14. data/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb +1 -1
  15. data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +1 -1
  16. data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +6 -2
  17. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
  18. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  19. data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +1 -1
  20. data/lib/chef/chef_fs/path_utils.rb +3 -3
  21. data/lib/chef/client.rb +16 -14
  22. data/lib/chef/config.rb +1 -1
  23. data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
  24. data/lib/chef/cookbook/gem_installer.rb +1 -1
  25. data/lib/chef/cookbook/metadata.rb +45 -22
  26. data/lib/chef/cookbook_loader.rb +1 -1
  27. data/lib/chef/cookbook_manifest.rb +1 -1
  28. data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
  29. data/lib/chef/cookbook_version.rb +38 -3
  30. data/lib/chef/data_collector.rb +1 -1
  31. data/lib/chef/data_collector/error_handlers.rb +1 -1
  32. data/lib/chef/data_collector/run_end_message.rb +7 -1
  33. data/lib/chef/decorator/lazy_array.rb +2 -2
  34. data/lib/chef/deprecated.rb +4 -0
  35. data/lib/chef/digester.rb +4 -4
  36. data/lib/chef/dist.rb +8 -0
  37. data/lib/chef/dsl/chef_vault.rb +84 -0
  38. data/lib/chef/dsl/declare_resource.rb +7 -5
  39. data/lib/chef/dsl/platform_introspection.rb +3 -2
  40. data/lib/chef/dsl/recipe.rb +7 -12
  41. data/lib/chef/dsl/universal.rb +3 -7
  42. data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
  43. data/lib/chef/encrypted_data_bag_item/encryptor.rb +1 -1
  44. data/lib/chef/event_dispatch/base.rb +3 -0
  45. data/lib/chef/formatters/base.rb +1 -1
  46. data/lib/chef/formatters/doc.rb +1 -1
  47. data/lib/chef/formatters/indentable_output_stream.rb +7 -16
  48. data/lib/chef/http.rb +1 -1
  49. data/lib/chef/http/decompressor.rb +1 -1
  50. data/lib/chef/http/http_request.rb +3 -2
  51. data/lib/chef/json_compat.rb +1 -1
  52. data/lib/chef/key.rb +1 -1
  53. data/lib/chef/knife.rb +2 -4
  54. data/lib/chef/knife/acl_add.rb +57 -0
  55. data/lib/chef/knife/acl_base.rb +183 -0
  56. data/lib/chef/knife/acl_bulk_add.rb +78 -0
  57. data/lib/chef/knife/acl_bulk_remove.rb +83 -0
  58. data/lib/chef/knife/acl_remove.rb +62 -0
  59. data/lib/chef/knife/acl_show.rb +56 -0
  60. data/lib/chef/knife/bootstrap.rb +84 -90
  61. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +2 -2
  62. data/lib/chef/knife/bootstrap/client_builder.rb +2 -2
  63. data/lib/chef/knife/bootstrap/templates/chef-full.erb +11 -11
  64. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +12 -12
  65. data/lib/chef/knife/core/bootstrap_context.rb +63 -60
  66. data/lib/chef/knife/core/generic_presenter.rb +4 -3
  67. data/lib/chef/knife/core/hashed_command_loader.rb +1 -1
  68. data/lib/chef/knife/core/node_presenter.rb +2 -2
  69. data/lib/chef/knife/core/status_presenter.rb +5 -5
  70. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  71. data/lib/chef/knife/core/ui.rb +17 -1
  72. data/lib/chef/knife/core/windows_bootstrap_context.rb +44 -42
  73. data/lib/chef/knife/data_bag_secret_options.rb +18 -45
  74. data/lib/chef/knife/group_add.rb +55 -0
  75. data/lib/chef/knife/{cookbook_site_download.rb → group_create.rb} +21 -12
  76. data/lib/chef/knife/group_destroy.rb +53 -0
  77. data/lib/chef/knife/{cookbook_site_list.rb → group_list.rb} +14 -11
  78. data/lib/chef/knife/group_remove.rb +56 -0
  79. data/lib/chef/knife/{cookbook_site_install.rb → group_show.rb} +21 -12
  80. data/lib/chef/knife/key_create_base.rb +1 -1
  81. data/lib/chef/knife/key_edit_base.rb +1 -1
  82. data/lib/chef/knife/ssh.rb +12 -31
  83. data/lib/chef/knife/status.rb +3 -3
  84. data/lib/chef/knife/supermarket_download.rb +1 -2
  85. data/lib/chef/knife/supermarket_install.rb +2 -3
  86. data/lib/chef/knife/supermarket_list.rb +1 -2
  87. data/lib/chef/knife/supermarket_search.rb +1 -2
  88. data/lib/chef/knife/supermarket_share.rb +1 -2
  89. data/lib/chef/knife/supermarket_show.rb +1 -2
  90. data/lib/chef/knife/supermarket_unshare.rb +1 -2
  91. data/lib/chef/knife/{cookbook_site_show.rb → user_dissociate.rb} +15 -13
  92. data/lib/chef/knife/{cookbook_site_search.rb → user_invite_add.rb} +16 -13
  93. data/lib/chef/knife/user_invite_list.rb +34 -0
  94. data/lib/chef/knife/user_invite_rescind.rb +63 -0
  95. data/lib/chef/knife/yaml_convert.rb +91 -0
  96. data/lib/chef/mixin/api_version_request_handling.rb +1 -1
  97. data/lib/chef/mixin/checksum.rb +0 -1
  98. data/lib/chef/mixin/openssl_helper.rb +4 -4
  99. data/lib/chef/mixin/powershell_exec.rb +10 -1
  100. data/lib/chef/mixin/powershell_out.rb +1 -1
  101. data/lib/chef/mixin/properties.rb +16 -2
  102. data/lib/chef/mixin/shell_out.rb +1 -5
  103. data/lib/chef/monkey_patches/net_http.rb +0 -4
  104. data/lib/chef/node.rb +18 -6
  105. data/lib/chef/node/attribute.rb +2 -2
  106. data/lib/chef/node/immutable_collections.rb +1 -1
  107. data/lib/chef/node/mixin/immutablize_array.rb +4 -0
  108. data/lib/chef/node/mixin/immutablize_hash.rb +3 -0
  109. data/lib/chef/node_map.rb +5 -31
  110. data/lib/chef/platform/priority_map.rb +4 -4
  111. data/lib/chef/platform/query_helpers.rb +6 -34
  112. data/lib/chef/policy_builder/policyfile.rb +1 -1
  113. data/lib/chef/powershell.rb +14 -0
  114. data/lib/chef/property.rb +24 -6
  115. data/lib/chef/provider.rb +40 -6
  116. data/lib/chef/provider/cron.rb +2 -2
  117. data/lib/chef/provider/directory.rb +3 -3
  118. data/lib/chef/provider/dsc_resource.rb +1 -1
  119. data/lib/chef/provider/dsc_script.rb +1 -1
  120. data/lib/chef/provider/execute.rb +3 -9
  121. data/lib/chef/provider/file.rb +6 -6
  122. data/lib/chef/provider/git.rb +84 -27
  123. data/lib/chef/provider/group.rb +4 -4
  124. data/lib/chef/provider/http_request.rb +6 -6
  125. data/lib/chef/provider/ifconfig.rb +4 -4
  126. data/lib/chef/provider/launchd.rb +45 -64
  127. data/lib/chef/provider/link.rb +2 -2
  128. data/lib/chef/provider/mount.rb +5 -5
  129. data/lib/chef/provider/osx_profile.rb +7 -3
  130. data/lib/chef/provider/package.rb +2 -2
  131. data/lib/chef/provider/package/cab.rb +5 -6
  132. data/lib/chef/provider/package/chocolatey.rb +1 -3
  133. data/lib/chef/provider/package/dnf.rb +66 -10
  134. data/lib/chef/provider/package/dnf/dnf_helper.py +85 -26
  135. data/lib/chef/provider/package/dnf/python_helper.rb +79 -36
  136. data/lib/chef/provider/package/dnf/version.rb +5 -1
  137. data/lib/chef/provider/package/dpkg.rb +1 -1
  138. data/lib/chef/provider/package/freebsd/base.rb +2 -1
  139. data/lib/chef/provider/package/homebrew.rb +107 -43
  140. data/lib/chef/provider/package/macports.rb +0 -2
  141. data/lib/chef/provider/package/msu.rb +4 -1
  142. data/lib/chef/provider/package/pacman.rb +25 -34
  143. data/lib/chef/provider/package/portage.rb +1 -0
  144. data/lib/chef/provider/package/powershell.rb +1 -1
  145. data/lib/chef/provider/package/rubygems.rb +30 -3
  146. data/lib/chef/provider/package/windows.rb +29 -53
  147. data/lib/chef/provider/package/windows/msi.rb +2 -2
  148. data/lib/chef/provider/package/yum.rb +1 -9
  149. data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
  150. data/lib/chef/provider/package/zypper.rb +0 -1
  151. data/lib/chef/provider/powershell_script.rb +5 -11
  152. data/lib/chef/provider/registry_key.rb +4 -4
  153. data/lib/chef/provider/remote_directory.rb +5 -5
  154. data/lib/chef/provider/remote_file/ftp.rb +3 -2
  155. data/lib/chef/provider/remote_file/local_file.rb +2 -1
  156. data/lib/chef/provider/remote_file/sftp.rb +3 -2
  157. data/lib/chef/provider/route.rb +5 -3
  158. data/lib/chef/provider/ruby_block.rb +1 -1
  159. data/lib/chef/provider/script.rb +2 -2
  160. data/lib/chef/provider/service.rb +8 -8
  161. data/lib/chef/provider/service/aixinit.rb +1 -1
  162. data/lib/chef/provider/service/arch.rb +1 -1
  163. data/lib/chef/provider/service/debian.rb +30 -28
  164. data/lib/chef/provider/service/macosx.rb +16 -10
  165. data/lib/chef/provider/service/systemd.rb +12 -12
  166. data/lib/chef/provider/service/upstart.rb +1 -1
  167. data/lib/chef/provider/service/windows.rb +5 -11
  168. data/lib/chef/provider/subversion.rb +25 -5
  169. data/lib/chef/provider/systemd_unit.rb +26 -25
  170. data/lib/chef/provider/user.rb +6 -6
  171. data/lib/chef/provider/user/aix.rb +1 -1
  172. data/lib/chef/provider/user/dscl.rb +6 -6
  173. data/lib/chef/provider/user/mac.rb +20 -15
  174. data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
  175. data/lib/chef/provider/windows_env.rb +3 -3
  176. data/lib/chef/provider/windows_script.rb +2 -2
  177. data/lib/chef/provider/windows_task.rb +10 -10
  178. data/lib/chef/providers.rb +0 -6
  179. data/lib/chef/recipe.rb +36 -0
  180. data/lib/chef/resource.rb +44 -57
  181. data/lib/chef/resource/action_class.rb +24 -22
  182. data/lib/chef/resource/alternatives.rb +210 -0
  183. data/lib/chef/resource/apt_package.rb +33 -3
  184. data/lib/chef/resource/apt_preference.rb +103 -7
  185. data/lib/chef/resource/apt_repository.rb +357 -18
  186. data/lib/chef/resource/apt_update.rb +58 -5
  187. data/lib/chef/resource/archive_file.rb +6 -5
  188. data/lib/chef/resource/bash.rb +3 -1
  189. data/lib/chef/resource/batch.rb +1 -1
  190. data/lib/chef/resource/bff_package.rb +10 -2
  191. data/lib/chef/resource/breakpoint.rb +1 -2
  192. data/lib/chef/resource/build_essential.rb +49 -51
  193. data/lib/chef/resource/cab_package.rb +9 -2
  194. data/lib/chef/resource/chef_client_cron.rb +228 -0
  195. data/lib/chef/resource/chef_client_scheduled_task.rb +201 -0
  196. data/lib/chef/resource/chef_client_systemd_timer.rb +180 -0
  197. data/lib/chef/resource/chef_gem.rb +15 -18
  198. data/lib/chef/resource/chef_handler.rb +5 -4
  199. data/lib/chef/resource/chef_sleep.rb +7 -5
  200. data/lib/chef/resource/chef_vault_secret.rb +135 -0
  201. data/lib/chef/resource/chocolatey_config.rb +8 -4
  202. data/lib/chef/resource/chocolatey_feature.rb +7 -4
  203. data/lib/chef/resource/chocolatey_package.rb +7 -4
  204. data/lib/chef/resource/chocolatey_source.rb +7 -4
  205. data/lib/chef/resource/cookbook_file.rb +4 -3
  206. data/lib/chef/resource/cron.rb +34 -80
  207. data/lib/chef/resource/cron_access.rb +10 -6
  208. data/lib/chef/resource/cron_d.rb +44 -95
  209. data/lib/chef/resource/csh.rb +3 -1
  210. data/lib/chef/resource/directory.rb +3 -3
  211. data/lib/chef/resource/dmg_package.rb +22 -19
  212. data/lib/chef/resource/dnf_package.rb +3 -4
  213. data/lib/chef/resource/dpkg_package.rb +3 -2
  214. data/lib/chef/resource/dsc_resource.rb +6 -4
  215. data/lib/chef/resource/dsc_script.rb +3 -2
  216. data/lib/chef/resource/execute.rb +15 -14
  217. data/lib/chef/resource/file.rb +14 -9
  218. data/lib/chef/resource/freebsd_package.rb +3 -2
  219. data/lib/chef/resource/gem_package.rb +19 -11
  220. data/lib/chef/resource/group.rb +5 -2
  221. data/lib/chef/resource/helpers/cron_validations.rb +98 -0
  222. data/lib/chef/resource/homebrew_cask.rb +3 -2
  223. data/lib/chef/resource/homebrew_package.rb +5 -3
  224. data/lib/chef/resource/homebrew_tap.rb +3 -2
  225. data/lib/chef/resource/hostname.rb +26 -20
  226. data/lib/chef/resource/http_request.rb +1 -2
  227. data/lib/chef/resource/ifconfig.rb +8 -8
  228. data/lib/chef/resource/ips_package.rb +11 -3
  229. data/lib/chef/resource/kernel_module.rb +30 -30
  230. data/lib/chef/resource/ksh.rb +3 -1
  231. data/lib/chef/resource/launchd.rb +3 -3
  232. data/lib/chef/resource/link.rb +5 -27
  233. data/lib/chef/resource/locale.rb +60 -26
  234. data/lib/chef/resource/log.rb +13 -2
  235. data/lib/chef/resource/lwrp_base.rb +1 -1
  236. data/lib/chef/resource/macos_userdefaults.rb +18 -10
  237. data/lib/chef/resource/macosx_service.rb +3 -2
  238. data/lib/chef/resource/macports_package.rb +10 -2
  239. data/lib/chef/resource/mdadm.rb +63 -3
  240. data/lib/chef/resource/mount.rb +4 -1
  241. data/lib/chef/resource/msu_package.rb +19 -2
  242. data/lib/chef/resource/notify_group.rb +8 -3
  243. data/lib/chef/resource/ohai.rb +20 -4
  244. data/lib/chef/resource/ohai_hint.rb +4 -13
  245. data/lib/chef/resource/openbsd_package.rb +10 -2
  246. data/lib/chef/resource/openssl_dhparam.rb +11 -2
  247. data/lib/chef/resource/openssl_ec_private_key.rb +24 -2
  248. data/lib/chef/resource/openssl_ec_public_key.rb +22 -2
  249. data/lib/chef/resource/openssl_rsa_private_key.rb +21 -2
  250. data/lib/chef/resource/openssl_rsa_public_key.rb +23 -2
  251. data/lib/chef/resource/openssl_x509_certificate.rb +38 -2
  252. data/lib/chef/resource/openssl_x509_crl.rb +13 -2
  253. data/lib/chef/resource/openssl_x509_request.rb +38 -2
  254. data/lib/chef/resource/osx_profile.rb +4 -3
  255. data/lib/chef/resource/package.rb +3 -2
  256. data/lib/chef/resource/pacman_package.rb +3 -2
  257. data/lib/chef/resource/paludis_package.rb +13 -4
  258. data/lib/chef/resource/perl.rb +3 -1
  259. data/lib/chef/resource/plist.rb +207 -0
  260. data/lib/chef/resource/portage_package.rb +14 -4
  261. data/lib/chef/resource/powershell_package.rb +2 -4
  262. data/lib/chef/resource/powershell_package_source.rb +4 -2
  263. data/lib/chef/resource/powershell_script.rb +8 -18
  264. data/lib/chef/resource/python.rb +3 -1
  265. data/lib/chef/resource/reboot.rb +1 -2
  266. data/lib/chef/resource/registry_key.rb +2 -3
  267. data/lib/chef/resource/remote_directory.rb +3 -1
  268. data/lib/chef/resource/remote_file.rb +3 -2
  269. data/lib/chef/resource/rhsm_errata.rb +1 -4
  270. data/lib/chef/resource/rhsm_errata_level.rb +1 -2
  271. data/lib/chef/resource/rhsm_register.rb +3 -3
  272. data/lib/chef/resource/rhsm_repo.rb +4 -3
  273. data/lib/chef/resource/rhsm_subscription.rb +5 -4
  274. data/lib/chef/resource/route.rb +6 -2
  275. data/lib/chef/resource/rpm_package.rb +13 -3
  276. data/lib/chef/resource/ruby.rb +3 -1
  277. data/lib/chef/resource/ruby_block.rb +2 -5
  278. data/lib/chef/resource/scm/_scm.rb +49 -0
  279. data/lib/chef/resource/{scm.rb → scm/git.rb} +16 -30
  280. data/lib/chef/resource/{subversion.rb → scm/subversion.rb} +10 -7
  281. data/lib/chef/resource/script.rb +7 -4
  282. data/lib/chef/resource/service.rb +7 -8
  283. data/lib/chef/resource/smartos_package.rb +10 -2
  284. data/lib/chef/resource/snap_package.rb +4 -2
  285. data/lib/chef/resource/solaris_package.rb +10 -2
  286. data/lib/chef/resource/ssh_known_hosts_entry.rb +6 -3
  287. data/lib/chef/resource/sudo.rb +11 -11
  288. data/lib/chef/resource/support/cron.d.erb +1 -1
  289. data/lib/chef/resource/support/cron_access.erb +1 -1
  290. data/lib/chef/resource/support/sudoer.erb +1 -2
  291. data/lib/chef/resource/support/ulimit.erb +41 -0
  292. data/lib/chef/resource/swap_file.rb +7 -5
  293. data/lib/chef/resource/sysctl.rb +63 -4
  294. data/lib/chef/resource/systemd_unit.rb +6 -4
  295. data/lib/chef/resource/template.rb +0 -1
  296. data/lib/chef/resource/timezone.rb +8 -19
  297. data/lib/chef/resource/user.rb +3 -5
  298. data/lib/chef/resource/user/aix_user.rb +0 -2
  299. data/lib/chef/resource/user/dscl_user.rb +1 -1
  300. data/lib/chef/resource/user/linux_user.rb +0 -2
  301. data/lib/chef/resource/user/mac_user.rb +1 -1
  302. data/lib/chef/resource/user/pw_user.rb +0 -2
  303. data/lib/chef/resource/user/solaris_user.rb +0 -2
  304. data/lib/chef/resource/user/windows_user.rb +0 -2
  305. data/lib/chef/resource/user_ulimit.rb +116 -0
  306. data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
  307. data/lib/chef/resource/windows_ad_join.rb +20 -7
  308. data/lib/chef/resource/windows_auto_run.rb +2 -3
  309. data/lib/chef/resource/windows_certificate.rb +3 -3
  310. data/lib/chef/resource/windows_dfs_folder.rb +1 -2
  311. data/lib/chef/resource/windows_dfs_namespace.rb +1 -2
  312. data/lib/chef/resource/windows_dfs_server.rb +2 -3
  313. data/lib/chef/resource/windows_dns_record.rb +0 -1
  314. data/lib/chef/resource/windows_dns_zone.rb +0 -1
  315. data/lib/chef/resource/windows_env.rb +12 -4
  316. data/lib/chef/resource/windows_feature.rb +59 -4
  317. data/lib/chef/resource/windows_feature_dism.rb +24 -24
  318. data/lib/chef/resource/windows_feature_powershell.rb +44 -78
  319. data/lib/chef/resource/windows_firewall_rule.rb +121 -8
  320. data/lib/chef/resource/windows_font.rb +10 -2
  321. data/lib/chef/resource/windows_package.rb +76 -7
  322. data/lib/chef/resource/windows_pagefile.rb +31 -4
  323. data/lib/chef/resource/windows_path.rb +18 -2
  324. data/lib/chef/resource/windows_printer.rb +26 -7
  325. data/lib/chef/resource/windows_printer_port.rb +29 -2
  326. data/lib/chef/resource/windows_script.rb +3 -4
  327. data/lib/chef/resource/windows_security_policy.rb +119 -0
  328. data/lib/chef/resource/windows_service.rb +46 -32
  329. data/lib/chef/resource/windows_share.rb +22 -6
  330. data/lib/chef/resource/windows_shortcut.rb +13 -3
  331. data/lib/chef/resource/windows_task.rb +129 -16
  332. data/lib/chef/resource/windows_uac.rb +20 -2
  333. data/lib/chef/resource/windows_user_privilege.rb +199 -0
  334. data/lib/chef/resource/windows_workgroup.rb +19 -4
  335. data/lib/chef/resource/yum_package.rb +91 -7
  336. data/lib/chef/resource/yum_repository.rb +30 -12
  337. data/lib/chef/resource/zypper_package.rb +32 -5
  338. data/lib/chef/resource/zypper_repository.rb +19 -6
  339. data/lib/chef/resource_builder.rb +8 -0
  340. data/lib/chef/resource_inspector.rb +3 -2
  341. data/lib/chef/resource_resolver.rb +7 -14
  342. data/lib/chef/resources.rb +11 -3
  343. data/lib/chef/run_context/cookbook_compiler.rb +29 -5
  344. data/lib/chef/scan_access_control.rb +1 -1
  345. data/lib/chef/shell.rb +22 -0
  346. data/lib/chef/shell/ext.rb +1 -1
  347. data/lib/chef/version.rb +1 -1
  348. data/lib/chef/win32/api.rb +2 -2
  349. data/lib/chef/win32/api/error.rb +3 -1
  350. data/lib/chef/win32/api/file.rb +1 -1
  351. data/lib/chef/win32/api/net.rb +1 -0
  352. data/lib/chef/win32/api/security.rb +6 -0
  353. data/lib/chef/win32/file.rb +1 -9
  354. data/lib/chef/win32/mutex.rb +1 -1
  355. data/lib/chef/win32/net.rb +1 -0
  356. data/lib/chef/win32/security.rb +40 -2
  357. data/lib/chef/win32/security/sid.rb +4 -4
  358. data/spec/functional/assets/inittest +8 -7
  359. data/spec/functional/knife/ssh_spec.rb +23 -19
  360. data/spec/functional/resource/cron_spec.rb +10 -29
  361. data/spec/functional/resource/dnf_package_spec.rb +441 -156
  362. data/spec/functional/resource/git_spec.rb +184 -134
  363. data/spec/functional/resource/insserv_spec.rb +1 -1
  364. data/spec/functional/resource/launchd_spec.rb +232 -0
  365. data/spec/functional/resource/link_spec.rb +3 -3
  366. data/spec/functional/resource/locale_spec.rb +13 -2
  367. data/spec/functional/resource/msu_package_spec.rb +5 -2
  368. data/spec/functional/resource/powershell_script_spec.rb +7 -68
  369. data/spec/functional/resource/remote_file_spec.rb +1 -1
  370. data/spec/functional/resource/windows_security_policy_spec.rb +90 -0
  371. data/spec/functional/resource/windows_task_spec.rb +4 -4
  372. data/spec/functional/resource/windows_user_privilege_spec.rb +193 -0
  373. data/spec/functional/run_lock_spec.rb +1 -1
  374. data/spec/functional/shell_spec.rb +1 -1
  375. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  376. data/spec/functional/version_spec.rb +1 -1
  377. data/spec/functional/win32/registry_spec.rb +0 -6
  378. data/spec/functional/win32/security_spec.rb +22 -0
  379. data/spec/integration/client/client_spec.rb +123 -2
  380. data/spec/integration/knife/cookbook_show_spec.rb +28 -26
  381. data/spec/integration/knife/data_bag_show_spec.rb +1 -1
  382. data/spec/integration/knife/raw_spec.rb +34 -6
  383. data/spec/integration/knife/redirection_spec.rb +2 -2
  384. data/spec/integration/knife/show_spec.rb +32 -3
  385. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +3 -3
  386. data/spec/integration/recipes/noop_resource_spec.rb +1 -1
  387. data/spec/integration/recipes/notifies_spec.rb +49 -20
  388. data/spec/integration/recipes/notifying_block_spec.rb +8 -5
  389. data/spec/integration/recipes/provider_choice.rb +2 -0
  390. data/spec/integration/recipes/recipe_dsl_spec.rb +45 -143
  391. data/spec/integration/recipes/resource_action_spec.rb +16 -11
  392. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +1 -1
  393. data/spec/integration/recipes/resource_load_spec.rb +133 -12
  394. data/spec/integration/recipes/use_partial_spec.rb +112 -0
  395. data/spec/integration/solo/solo_spec.rb +3 -3
  396. data/spec/spec_helper.rb +18 -3
  397. data/spec/support/chef_helpers.rb +2 -2
  398. data/spec/support/lib/chef/resource/zen_follower.rb +2 -0
  399. data/spec/support/platform_helpers.rb +2 -20
  400. data/spec/support/recipe_dsl_helper.rb +83 -0
  401. data/spec/support/shared/functional/http.rb +2 -2
  402. data/spec/support/shared/functional/windows_script.rb +3 -16
  403. data/spec/support/shared/integration/knife_support.rb +9 -6
  404. data/spec/support/shared/unit/mock_shellout.rb +1 -1
  405. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +4 -4
  406. data/spec/unit/application/apply_spec.rb +3 -0
  407. data/spec/unit/application/client_spec.rb +5 -1
  408. data/spec/unit/application_spec.rb +1 -2
  409. data/spec/unit/client_spec.rb +7 -5
  410. data/spec/unit/cookbook/gem_installer_spec.rb +2 -2
  411. data/spec/unit/cookbook/metadata_spec.rb +38 -19
  412. data/spec/unit/data_collector_spec.rb +39 -18
  413. data/spec/unit/file_access_control_spec.rb +1 -1
  414. data/spec/unit/json_compat_spec.rb +1 -1
  415. data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +15 -15
  416. data/spec/unit/knife/bootstrap/client_builder_spec.rb +9 -9
  417. data/spec/unit/knife/bootstrap_spec.rb +20 -38
  418. data/spec/unit/knife/cookbook_show_spec.rb +1 -0
  419. data/spec/unit/knife/core/bootstrap_context_spec.rb +23 -43
  420. data/spec/unit/knife/core/ui_spec.rb +16 -0
  421. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +9 -63
  422. data/spec/unit/knife/data_bag_secret_options_spec.rb +22 -14
  423. data/spec/unit/knife/ssh_spec.rb +8 -111
  424. data/spec/unit/knife/status_spec.rb +1 -1
  425. data/spec/unit/knife_spec.rb +18 -0
  426. data/spec/unit/mixin/openssl_helper_spec.rb +4 -4
  427. data/spec/unit/mixin/powershell_exec_spec.rb +10 -0
  428. data/spec/unit/mixin/shell_out_spec.rb +25 -31
  429. data/spec/unit/node/attribute_spec.rb +3 -3
  430. data/spec/unit/node_spec.rb +24 -0
  431. data/spec/unit/platform/query_helpers_spec.rb +0 -143
  432. data/spec/unit/property/state_spec.rb +12 -7
  433. data/spec/unit/property/validation_spec.rb +25 -1
  434. data/spec/unit/property_spec.rb +12 -9
  435. data/spec/unit/provider/apt_preference_spec.rb +14 -10
  436. data/spec/unit/provider/apt_repository_spec.rb +34 -36
  437. data/spec/unit/provider/apt_update_spec.rb +12 -11
  438. data/spec/unit/provider/cookbook_file_spec.rb +4 -4
  439. data/spec/unit/provider/cron_spec.rb +2 -2
  440. data/spec/unit/provider/directory_spec.rb +4 -15
  441. data/spec/unit/provider/file_spec.rb +4 -4
  442. data/spec/unit/provider/git_spec.rb +41 -1
  443. data/spec/unit/provider/group/groupadd_spec.rb +1 -1
  444. data/spec/unit/provider/launchd_spec.rb +8 -50
  445. data/spec/unit/provider/link_spec.rb +0 -1
  446. data/spec/unit/provider/log_spec.rb +3 -3
  447. data/spec/unit/provider/mdadm_spec.rb +3 -3
  448. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  449. data/spec/unit/provider/package/homebrew_spec.rb +280 -174
  450. data/spec/unit/provider/package/pacman_spec.rb +65 -147
  451. data/spec/unit/provider/package/portage_spec.rb +2 -2
  452. data/spec/unit/provider/package/powershell_spec.rb +3 -2
  453. data/spec/unit/provider/package/rubygems_spec.rb +211 -26
  454. data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
  455. data/spec/unit/provider/powershell_script_spec.rb +21 -61
  456. data/spec/unit/provider/remote_file_spec.rb +3 -4
  457. data/spec/unit/provider/service/debian_service_spec.rb +34 -13
  458. data/spec/unit/provider/service/macosx_spec.rb +210 -214
  459. data/spec/unit/provider/service/systemd_service_spec.rb +23 -23
  460. data/spec/unit/provider/subversion_spec.rb +4 -2
  461. data/spec/unit/provider/template_spec.rb +3 -4
  462. data/spec/unit/provider/zypper_repository_spec.rb +17 -17
  463. data/spec/unit/provider_resolver_spec.rb +4 -4
  464. data/spec/unit/recipe_spec.rb +68 -0
  465. data/spec/unit/resource/alternatives_spec.rb +120 -0
  466. data/spec/unit/resource/apt_preference_spec.rb +0 -18
  467. data/spec/unit/resource/apt_repository_spec.rb +0 -18
  468. data/spec/unit/resource/apt_update_spec.rb +0 -18
  469. data/spec/unit/resource/chef_client_cron_spec.rb +119 -0
  470. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +102 -0
  471. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +70 -0
  472. data/spec/unit/resource/chef_vault_secret_spec.rb +40 -0
  473. data/spec/unit/resource/chocolatey_source_spec.rb +2 -1
  474. data/spec/unit/resource/cron_d_spec.rb +6 -48
  475. data/spec/unit/resource/cron_spec.rb +4 -10
  476. data/spec/unit/resource/gem_package_spec.rb +3 -3
  477. data/spec/unit/resource/helpers/cron_validations_spec.rb +77 -0
  478. data/spec/unit/resource/link_spec.rb +0 -4
  479. data/spec/unit/resource/locale_spec.rb +0 -34
  480. data/spec/unit/resource/msu_package_spec.rb +4 -0
  481. data/spec/unit/resource/ohai_spec.rb +56 -2
  482. data/spec/unit/resource/plist_spec.rb +130 -0
  483. data/spec/unit/resource/powershell_script_spec.rb +0 -5
  484. data/spec/unit/resource/{git_spec.rb → scm/git_spec.rb} +50 -2
  485. data/spec/unit/resource/{scm_spec.rb → scm/scm.rb} +1 -52
  486. data/spec/unit/resource/{subversion_spec.rb → scm/subversion_spec.rb} +2 -3
  487. data/spec/unit/resource/service_spec.rb +4 -0
  488. data/spec/unit/resource/user_spec.rb +2 -2
  489. data/spec/unit/resource/user_ulimit_spec.rb +53 -0
  490. data/spec/unit/resource/windows_feature_dism_spec.rb +2 -17
  491. data/spec/unit/resource/windows_feature_powershell_spec.rb +2 -17
  492. data/spec/unit/resource/windows_firewall_rule_spec.rb +88 -41
  493. data/spec/unit/resource/windows_package_spec.rb +14 -0
  494. data/spec/unit/resource/windows_service_spec.rb +9 -0
  495. data/spec/unit/resource_reporter_spec.rb +2 -6
  496. data/spec/unit/resource_spec.rb +10 -3
  497. data/spec/unit/run_lock_spec.rb +1 -1
  498. data/spec/unit/scan_access_control_spec.rb +1 -1
  499. data/spec/unit/search/query_spec.rb +1 -1
  500. data/spec/unit/win32/registry_spec.rb +1 -1
  501. data/tasks/rspec.rb +6 -14
  502. metadata +92 -37
  503. data/lib/chef/dsl/core.rb +0 -52
  504. data/lib/chef/knife/cookbook_site_share.rb +0 -41
  505. data/lib/chef/knife/cookbook_site_unshare.rb +0 -41
  506. data/lib/chef/provider/apt_preference.rb +0 -93
  507. data/lib/chef/provider/apt_repository.rb +0 -358
  508. data/lib/chef/provider/apt_update.rb +0 -79
  509. data/lib/chef/provider/log.rb +0 -43
  510. data/lib/chef/provider/mdadm.rb +0 -85
  511. data/lib/chef/provider/ohai.rb +0 -45
  512. data/lib/chef/resource/git.rb +0 -37
  513. data/spec/unit/provider/ohai_spec.rb +0 -84
@@ -50,8 +50,8 @@ describe Chef::Knife::Ssh do
50
50
  describe "identity file" do
51
51
  context "when knife[:ssh_identity_file] is set" do
52
52
  before do
53
- setup_knife(["*:*", "uptime"])
54
53
  Chef::Config[:knife][:ssh_identity_file] = "~/.ssh/aws.rsa"
54
+ setup_knife(["*:*", "uptime"])
55
55
  end
56
56
 
57
57
  it "uses the ssh_identity_file" do
@@ -62,8 +62,8 @@ describe Chef::Knife::Ssh do
62
62
 
63
63
  context "when knife[:ssh_identity_file] is set and frozen" do
64
64
  before do
65
- setup_knife(["*:*", "uptime"])
66
65
  Chef::Config[:knife][:ssh_identity_file] = "~/.ssh/aws.rsa".freeze
66
+ setup_knife(["*:*", "uptime"])
67
67
  end
68
68
 
69
69
  it "uses the ssh_identity_file" do
@@ -74,8 +74,8 @@ describe Chef::Knife::Ssh do
74
74
 
75
75
  context "when -i is provided" do
76
76
  before do
77
- setup_knife(["-i ~/.ssh/aws.rsa", "*:*", "uptime"])
78
77
  Chef::Config[:knife][:ssh_identity_file] = nil
78
+ setup_knife(["-i ~/.ssh/aws.rsa", "*:*", "uptime"])
79
79
  end
80
80
 
81
81
  it "should use the value on the command line" do
@@ -85,6 +85,7 @@ describe Chef::Knife::Ssh do
85
85
 
86
86
  it "should override what is set in knife.rb" do
87
87
  Chef::Config[:knife][:ssh_identity_file] = "~/.ssh/other.rsa"
88
+ @knife.merge_configs
88
89
  @knife.run
89
90
  expect(@knife.config[:ssh_identity_file]).to eq("~/.ssh/aws.rsa")
90
91
  end
@@ -92,8 +93,8 @@ describe Chef::Knife::Ssh do
92
93
 
93
94
  context "when knife[:ssh_identity_file] is not provided]" do
94
95
  before do
95
- setup_knife(["*:*", "uptime"])
96
96
  Chef::Config[:knife][:ssh_identity_file] = nil
97
+ setup_knife(["*:*", "uptime"])
97
98
  end
98
99
 
99
100
  it "uses the default" do
@@ -119,8 +120,8 @@ describe Chef::Knife::Ssh do
119
120
  describe "user" do
120
121
  context "when knife[:ssh_user] is set" do
121
122
  before do
122
- setup_knife(["*:*", "uptime"])
123
123
  Chef::Config[:knife][:ssh_user] = "ubuntu"
124
+ setup_knife(["*:*", "uptime"])
124
125
  end
125
126
 
126
127
  it "uses the ssh_user" do
@@ -131,8 +132,8 @@ describe Chef::Knife::Ssh do
131
132
 
132
133
  context "when knife[:ssh_user] is set and frozen" do
133
134
  before do
134
- setup_knife(["*:*", "uptime"])
135
135
  Chef::Config[:knife][:ssh_user] = "ubuntu".freeze
136
+ setup_knife(["*:*", "uptime"])
136
137
  end
137
138
 
138
139
  it "uses the ssh_user" do
@@ -143,8 +144,8 @@ describe Chef::Knife::Ssh do
143
144
 
144
145
  context "when -x is provided" do
145
146
  before do
146
- setup_knife(["-x ubuntu", "*:*", "uptime"])
147
147
  Chef::Config[:knife][:ssh_user] = nil
148
+ setup_knife(["-x ubuntu", "*:*", "uptime"])
148
149
  end
149
150
 
150
151
  it "should use the value on the command line" do
@@ -154,6 +155,7 @@ describe Chef::Knife::Ssh do
154
155
 
155
156
  it "should override what is set in knife.rb" do
156
157
  Chef::Config[:knife][:ssh_user] = "root"
158
+ @knife.merge_configs
157
159
  @knife.run
158
160
  expect(@knife.config[:ssh_user]).to eq("ubuntu")
159
161
  end
@@ -161,8 +163,8 @@ describe Chef::Knife::Ssh do
161
163
 
162
164
  context "when knife[:ssh_user] is not provided]" do
163
165
  before do
164
- setup_knife(["*:*", "uptime"])
165
166
  Chef::Config[:knife][:ssh_user] = nil
167
+ setup_knife(["*:*", "uptime"])
166
168
  end
167
169
 
168
170
  it "uses the default (current user)" do
@@ -175,8 +177,8 @@ describe Chef::Knife::Ssh do
175
177
  describe "attribute" do
176
178
  context "when knife[:ssh_attribute] is set" do
177
179
  before do
178
- setup_knife(["*:*", "uptime"])
179
180
  Chef::Config[:knife][:ssh_attribute] = "ec2.public_hostname"
181
+ setup_knife(["*:*", "uptime"])
180
182
  end
181
183
 
182
184
  it "uses the ssh_attribute" do
@@ -187,8 +189,8 @@ describe Chef::Knife::Ssh do
187
189
 
188
190
  context "when knife[:ssh_attribute] is not provided" do
189
191
  before do
190
- setup_knife(["*:*", "uptime"])
191
192
  Chef::Config[:knife][:ssh_attribute] = nil
193
+ setup_knife(["*:*", "uptime"])
192
194
  end
193
195
 
194
196
  it "uses the default" do
@@ -199,8 +201,8 @@ describe Chef::Knife::Ssh do
199
201
 
200
202
  context "when -a ec2.public_public_hostname is provided" do
201
203
  before do
202
- setup_knife(["-a", "ec2.public_hostname", "*:*", "uptime"])
203
204
  Chef::Config[:knife][:ssh_attribute] = nil
205
+ setup_knife(["-a", "ec2.public_hostname", "*:*", "uptime"])
204
206
  end
205
207
 
206
208
  it "should use the value on the command line" do
@@ -211,6 +213,7 @@ describe Chef::Knife::Ssh do
211
213
  it "should override what is set in knife.rb" do
212
214
  # This is the setting imported from knife.rb
213
215
  Chef::Config[:knife][:ssh_attribute] = "fqdn"
216
+ @knife.merge_configs
214
217
  # Then we run knife with the -a flag, which sets the above variable
215
218
  setup_knife(["-a", "ec2.public_hostname", "*:*", "uptime"])
216
219
  @knife.run
@@ -222,8 +225,8 @@ describe Chef::Knife::Ssh do
222
225
  describe "prefix" do
223
226
  context "when knife[:prefix_attribute] is set" do
224
227
  before do
225
- setup_knife(["*:*", "uptime"])
226
228
  Chef::Config[:knife][:prefix_attribute] = "name"
229
+ setup_knife(["*:*", "uptime"])
227
230
  end
228
231
 
229
232
  it "uses the prefix_attribute" do
@@ -234,8 +237,8 @@ describe Chef::Knife::Ssh do
234
237
 
235
238
  context "when knife[:prefix_attribute] is not provided" do
236
239
  before do
237
- setup_knife(["*:*", "uptime"])
238
240
  Chef::Config[:knife][:prefix_attribute] = nil
241
+ setup_knife(["*:*", "uptime"])
239
242
  end
240
243
 
241
244
  it "falls back to nil" do
@@ -246,8 +249,8 @@ describe Chef::Knife::Ssh do
246
249
 
247
250
  context "when --prefix-attribute ec2.public_public_hostname is provided" do
248
251
  before do
249
- setup_knife(["--prefix-attribute", "ec2.public_hostname", "*:*", "uptime"])
250
252
  Chef::Config[:knife][:prefix_attribute] = nil
253
+ setup_knife(["--prefix-attribute", "ec2.public_hostname", "*:*", "uptime"])
251
254
  end
252
255
 
253
256
  it "should use the value on the command line" do
@@ -258,6 +261,7 @@ describe Chef::Knife::Ssh do
258
261
  it "should override what is set in knife.rb" do
259
262
  # This is the setting imported from knife.rb
260
263
  Chef::Config[:knife][:prefix_attribute] = "fqdn"
264
+ @knife.merge_configs
261
265
  # Then we run knife with the -b flag, which sets the above variable
262
266
  setup_knife(["--prefix-attribute", "ec2.public_hostname", "*:*", "uptime"])
263
267
  @knife.run
@@ -269,8 +273,8 @@ describe Chef::Knife::Ssh do
269
273
  describe "gateway" do
270
274
  context "when knife[:ssh_gateway] is set" do
271
275
  before do
272
- setup_knife(["*:*", "uptime"])
273
276
  Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname"
277
+ setup_knife(["*:*", "uptime"])
274
278
  end
275
279
 
276
280
  it "uses the ssh_gateway" do
@@ -282,8 +286,8 @@ describe Chef::Knife::Ssh do
282
286
 
283
287
  context "when -G user@ec2.public_hostname is provided" do
284
288
  before do
285
- setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"])
286
289
  Chef::Config[:knife][:ssh_gateway] = nil
290
+ setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"])
287
291
  end
288
292
 
289
293
  it "uses the ssh_gateway" do
@@ -295,9 +299,9 @@ describe Chef::Knife::Ssh do
295
299
 
296
300
  context "when knife[:ssh_gateway_identity] is set" do
297
301
  before do
298
- setup_knife(["*:*", "uptime"])
299
302
  Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname"
300
303
  Chef::Config[:knife][:ssh_gateway_identity] = "~/.ssh/aws-gateway.rsa"
304
+ setup_knife(["*:*", "uptime"])
301
305
  end
302
306
 
303
307
  it "uses the ssh_gateway_identity file" do
@@ -309,9 +313,9 @@ describe Chef::Knife::Ssh do
309
313
 
310
314
  context "when -ssh-gateway-identity is provided and knife[:ssh_gateway] is set" do
311
315
  before do
312
- setup_knife(["--ssh-gateway-identity", "~/.ssh/aws-gateway.rsa", "*:*", "uptime"])
313
316
  Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname"
314
317
  Chef::Config[:knife][:ssh_gateway_identity] = nil
318
+ setup_knife(["--ssh-gateway-identity", "~/.ssh/aws-gateway.rsa", "*:*", "uptime"])
315
319
  end
316
320
 
317
321
  it "uses the ssh_gateway_identity file" do
@@ -323,8 +327,8 @@ describe Chef::Knife::Ssh do
323
327
 
324
328
  context "when the gateway requires a password" do
325
329
  before do
326
- setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"])
327
330
  Chef::Config[:knife][:ssh_gateway] = nil
331
+ setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"])
328
332
  allow(@knife.session).to receive(:via) do |host, user, options|
329
333
  raise Net::SSH::AuthenticationFailed unless options[:password]
330
334
  end
@@ -55,17 +55,8 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
55
55
  # Actual tests
56
56
  let(:new_resource) do
57
57
  new_resource = Chef::Resource::Cron.new("Chef functional test cron", run_context)
58
- new_resource.user "root"
59
- # @hourly is not supported on solaris, aix
60
- if ohai[:platform] == "solaris2" || ohai[:platform] == "aix"
61
- new_resource.minute "0 * * * *"
62
- else
63
- new_resource.minute "@hourly"
64
- end
65
- new_resource.hour ""
66
- new_resource.day ""
67
- new_resource.month ""
68
- new_resource.weekday ""
58
+ new_resource.user "root"
59
+ new_resource.minute "0"
69
60
  new_resource.command "/bin/true"
70
61
  new_resource
71
62
  end
@@ -106,7 +97,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
106
97
 
107
98
  exclude_solaris = %w{solaris opensolaris solaris2 omnios}.include?(ohai[:platform])
108
99
  describe "create action with various attributes", external: exclude_solaris do
109
- def create_and_validate_with_attribute(resource, attribute, value)
100
+ def create_and_validate_with_property(resource, attribute, value)
110
101
  if ohai[:platform] == "aix"
111
102
  expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron, /Aix cron entry does not support environment variables. Please set them in script and use script in cron./)
112
103
  else
@@ -130,28 +121,28 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
130
121
 
131
122
  it "should create a crontab entry for mailto attribute" do
132
123
  new_resource.mailto "cheftest@example.com"
133
- create_and_validate_with_attribute(new_resource, "mailto", "cheftest@example.com")
124
+ create_and_validate_with_property(new_resource, "mailto", "cheftest@example.com")
134
125
  end
135
126
 
136
127
  it "should create a crontab entry for path attribute" do
137
128
  new_resource.path "/usr/local/bin"
138
- create_and_validate_with_attribute(new_resource, "path", "/usr/local/bin")
129
+ create_and_validate_with_property(new_resource, "path", "/usr/local/bin")
139
130
  end
140
131
 
141
132
  it "should create a crontab entry for shell attribute" do
142
133
  new_resource.shell "/bin/bash"
143
- create_and_validate_with_attribute(new_resource, "shell", "/bin/bash")
134
+ create_and_validate_with_property(new_resource, "shell", "/bin/bash")
144
135
  end
145
136
 
146
137
  it "should create a crontab entry for home attribute" do
147
138
  new_resource.home "/home/opscode"
148
- create_and_validate_with_attribute(new_resource, "home", "/home/opscode")
139
+ create_and_validate_with_property(new_resource, "home", "/home/opscode")
149
140
  end
150
141
 
151
142
  %i{ home mailto path shell }.each do |attr|
152
143
  it "supports an empty string for #{attr} attribute" do
153
144
  new_resource.send(attr, "")
154
- create_and_validate_with_attribute(new_resource, attr.to_s, "")
145
+ create_and_validate_with_property(new_resource, attr.to_s, "")
155
146
  end
156
147
  end
157
148
  end
@@ -161,20 +152,10 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
161
152
  new_resource.run_action(:delete)
162
153
  end
163
154
 
164
- def cron_create_should_raise_exception
165
- expect { new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron)
166
- cron_should_not_exists(new_resource.name)
167
- end
168
-
169
- it "should not create cron with invalid minute" do
170
- new_resource.minute "invalid"
171
- cron_create_should_raise_exception
172
- end
173
-
174
155
  it "should not create cron with invalid user" do
175
156
  new_resource.user "1-really-really-invalid-user-name"
176
- cron_create_should_raise_exception
157
+ expect { new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron)
158
+ cron_should_not_exists(new_resource.name)
177
159
  end
178
-
179
160
  end
180
161
  end
@@ -21,9 +21,13 @@ require "chef/mixin/shell_out"
21
21
 
22
22
  # run this test only for following platforms.
23
23
  exclude_test = !(%w{rhel fedora amazon}.include?(ohai[:platform_family]) && File.exist?("/usr/bin/dnf"))
24
- describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
24
+ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
25
25
  include Chef::Mixin::ShellOut
26
26
 
27
+ # NOTE: every single test here either needs to explicitly call flush_cache or needs to explicitly
28
+ # call preinstall (which explicitly calls flush_cache). It is your responsibility to do one or the
29
+ # other in order to minimize calling flush_cache a half dozen times per test.
30
+
27
31
  def flush_cache
28
32
  # needed on at least fc23/fc24 sometimes to deal with the dnf cache getting out of sync with the rpm db
29
33
  FileUtils.rm_f "/var/cache/dnf/@System.solv"
@@ -37,6 +41,10 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
37
41
  flush_cache
38
42
  end
39
43
 
44
+ before(:all) do
45
+ shell_out!("dnf -y install dnf-plugins-core")
46
+ end
47
+
40
48
  before(:each) do
41
49
  File.open("/etc/yum.repos.d/chef-dnf-localtesting.repo", "w+") do |f|
42
50
  f.write <<~EOF
@@ -47,17 +55,24 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
47
55
  gpgcheck=0
48
56
  EOF
49
57
  end
50
- shell_out!("rpm -qa | grep chef_rpm | xargs -r rpm -e")
58
+ shell_out!("rpm -qa --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | grep chef_rpm | xargs -r rpm -e")
59
+ # next line is useful cleanup if you happen to have been testing both yum + dnf func tests on the same box and
60
+ # have some yum garbage left around
61
+ FileUtils.rm_f "/etc/yum.repos.d/chef-yum-localtesting.repo"
51
62
  end
52
63
 
53
64
  after(:all) do
54
- shell_out!("rpm -qa | grep chef_rpm | xargs -r rpm -e")
65
+ shell_out!("rpm -qa --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | grep chef_rpm | xargs -r rpm -e")
55
66
  FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
56
67
  end
57
68
 
58
69
  let(:package_name) { "chef_rpm" }
59
70
  let(:dnf_package) { Chef::Resource::DnfPackage.new(package_name, run_context) }
60
71
 
72
+ def pkg_arch
73
+ ohai[:kernel][:machine]
74
+ end
75
+
61
76
  describe ":install" do
62
77
  context "vanilla use case" do
63
78
  let(:package_name) { "chef_rpm" }
@@ -66,47 +81,47 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
66
81
  flush_cache
67
82
  dnf_package.run_action(:install)
68
83
  expect(dnf_package.updated_by_last_action?).to be true
69
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
84
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
70
85
  end
71
86
 
72
87
  it "does not install if the package is installed" do
73
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
88
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
74
89
  dnf_package.run_action(:install)
75
90
  expect(dnf_package.updated_by_last_action?).to be false
76
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
91
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
77
92
  end
78
93
 
79
94
  it "does not install twice" do
80
95
  flush_cache
81
96
  dnf_package.run_action(:install)
82
97
  expect(dnf_package.updated_by_last_action?).to be true
83
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
98
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
84
99
  dnf_package.run_action(:install)
85
100
  expect(dnf_package.updated_by_last_action?).to be false
86
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
101
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
87
102
  end
88
103
 
89
104
  it "does not install if the prior version package is installed" do
90
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
105
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
91
106
  dnf_package.run_action(:install)
92
107
  expect(dnf_package.updated_by_last_action?).to be false
93
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
108
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
94
109
  end
95
110
 
96
- it "does not install if the i686 package is installed" do
97
- skip "FIXME: do nothing, or install the x86_64 version?"
111
+ it "does not install if the i686 package is installed", :intel_64bit do
112
+ skip "FIXME: do nothing, or install the #{pkg_arch} version?"
98
113
  preinstall("chef_rpm-1.10-1.i686.rpm")
99
114
  dnf_package.run_action(:install)
100
115
  expect(dnf_package.updated_by_last_action?).to be false
101
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.i686")
116
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
102
117
  end
103
118
 
104
- it "does not install if the prior version i686 package is installed" do
105
- skip "FIXME: do nothing, or install the x86_64 version?"
119
+ it "does not install if the prior version i686 package is installed", :intel_64bit do
120
+ skip "FIXME: do nothing, or install the #{pkg_arch} version?"
106
121
  preinstall("chef_rpm-1.2-1.i686.rpm")
107
122
  dnf_package.run_action(:install)
108
123
  expect(dnf_package.updated_by_last_action?).to be false
109
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.i686")
124
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.i686$")
110
125
  end
111
126
  end
112
127
 
@@ -116,7 +131,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
116
131
  dnf_package.package_name("chef_rpm-1.10")
117
132
  dnf_package.run_action(:install)
118
133
  expect(dnf_package.updated_by_last_action?).to be true
119
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
134
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
120
135
  end
121
136
 
122
137
  it "works with an older version" do
@@ -124,15 +139,23 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
124
139
  dnf_package.package_name("chef_rpm-1.2")
125
140
  dnf_package.run_action(:install)
126
141
  expect(dnf_package.updated_by_last_action?).to be true
127
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
142
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
143
+ end
144
+
145
+ it "works with an evra" do
146
+ flush_cache
147
+ dnf_package.package_name("chef_rpm-0:1.2-1.#{pkg_arch}")
148
+ dnf_package.run_action(:install)
149
+ expect(dnf_package.updated_by_last_action?).to be true
150
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
128
151
  end
129
152
 
130
- it "works with an evr" do
153
+ it "works with version and release" do
131
154
  flush_cache
132
- dnf_package.package_name("chef_rpm-0:1.2-1")
155
+ dnf_package.package_name("chef_rpm-1.2-1")
133
156
  dnf_package.run_action(:install)
134
157
  expect(dnf_package.updated_by_last_action?).to be true
135
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
158
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
136
159
  end
137
160
 
138
161
  it "works with a version glob" do
@@ -140,7 +163,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
140
163
  dnf_package.package_name("chef_rpm-1*")
141
164
  dnf_package.run_action(:install)
142
165
  expect(dnf_package.updated_by_last_action?).to be true
143
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
166
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
144
167
  end
145
168
 
146
169
  it "works with a name glob + version glob" do
@@ -148,7 +171,23 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
148
171
  dnf_package.package_name("chef_rp*-1*")
149
172
  dnf_package.run_action(:install)
150
173
  expect(dnf_package.updated_by_last_action?).to be true
151
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
174
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
175
+ end
176
+
177
+ it "upgrades when the installed version does not match the version string" do
178
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
179
+ dnf_package.package_name("chef_rpm-1.10")
180
+ dnf_package.run_action(:install)
181
+ expect(dnf_package.updated_by_last_action?).to be true
182
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}")
183
+ end
184
+
185
+ it "downgrades when the installed version is higher than the package_name version" do
186
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
187
+ dnf_package.package_name("chef_rpm-1.2")
188
+ dnf_package.run_action(:install)
189
+ expect(dnf_package.updated_by_last_action?).to be true
190
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
152
191
  end
153
192
  end
154
193
 
@@ -160,7 +199,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
160
199
  dnf_package.version("1.10")
161
200
  dnf_package.run_action(:install)
162
201
  expect(dnf_package.updated_by_last_action?).to be true
163
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
202
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
164
203
  end
165
204
 
166
205
  it "matches with a glob" do
@@ -169,7 +208,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
169
208
  dnf_package.version("1*")
170
209
  dnf_package.run_action(:install)
171
210
  expect(dnf_package.updated_by_last_action?).to be true
172
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
211
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
173
212
  end
174
213
 
175
214
  it "matches the vr" do
@@ -178,7 +217,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
178
217
  dnf_package.version("1.10-1")
179
218
  dnf_package.run_action(:install)
180
219
  expect(dnf_package.updated_by_last_action?).to be true
181
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
220
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
182
221
  end
183
222
 
184
223
  it "matches the evr" do
@@ -187,58 +226,47 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
187
226
  dnf_package.version("0:1.10-1")
188
227
  dnf_package.run_action(:install)
189
228
  expect(dnf_package.updated_by_last_action?).to be true
190
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
229
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
191
230
  end
192
231
 
193
- # only works on rhel >= 8, was broken on old dnf
194
232
  it "matches with a vr glob", :rhel_gte_8 do
195
233
  flush_cache
196
234
  dnf_package.package_name("chef_rpm")
197
235
  dnf_package.version("1.10-1*")
198
236
  dnf_package.run_action(:install)
199
237
  expect(dnf_package.updated_by_last_action?).to be true
200
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
238
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
201
239
  end
202
240
 
203
- # only works on rhel >= 8, was broken on old dnf
204
241
  it "matches with an evr glob", :rhel_gte_8 do
205
242
  flush_cache
206
243
  dnf_package.package_name("chef_rpm")
207
244
  dnf_package.version("0:1.10-1*")
208
245
  dnf_package.run_action(:install)
209
246
  expect(dnf_package.updated_by_last_action?).to be true
210
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
247
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
211
248
  end
212
249
  end
213
250
 
214
251
  context "downgrades" do
215
- it "just work with DNF" do
216
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
217
- dnf_package.version("1.2")
218
- dnf_package.run_action(:install)
219
- expect(dnf_package.updated_by_last_action?).to be true
220
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
221
- end
222
-
223
- it "throws a deprecation warning with allow_downgrade" do
224
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
225
- expect(Chef).to receive(:deprecated).with(:dnf_package_allow_downgrade, /^the allow_downgrade property on the dnf_package provider is not used/)
226
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
227
- dnf_package.version("1.2")
252
+ it "downgrades the package when allow_downgrade" do
253
+ flush_cache
254
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
255
+ dnf_package.package_name("chef_rpm")
256
+ dnf_package.version("1.2-1")
228
257
  dnf_package.run_action(:install)
229
- dnf_package.allow_downgrade true
230
258
  expect(dnf_package.updated_by_last_action?).to be true
231
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
259
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
232
260
  end
233
261
  end
234
262
 
235
- context "with arches" do
263
+ context "with arches", :intel_64bit do
236
264
  it "installs with 64-bit arch in the name" do
237
265
  flush_cache
238
- dnf_package.package_name("chef_rpm.x86_64")
266
+ dnf_package.package_name("chef_rpm.#{pkg_arch}")
239
267
  dnf_package.run_action(:install)
240
268
  expect(dnf_package.updated_by_last_action?).to be true
241
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
269
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
242
270
  end
243
271
 
244
272
  it "installs with 32-bit arch in the name" do
@@ -246,16 +274,16 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
246
274
  dnf_package.package_name("chef_rpm.i686")
247
275
  dnf_package.run_action(:install)
248
276
  expect(dnf_package.updated_by_last_action?).to be true
249
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.i686")
277
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
250
278
  end
251
279
 
252
280
  it "installs with 64-bit arch in the property" do
253
281
  flush_cache
254
282
  dnf_package.package_name("chef_rpm")
255
- dnf_package.arch("x86_64")
283
+ dnf_package.arch((pkg_arch).to_s)
256
284
  dnf_package.run_action(:install)
257
285
  expect(dnf_package.updated_by_last_action?).to be true
258
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
286
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
259
287
  end
260
288
 
261
289
  it "installs with 32-bit arch in the property" do
@@ -264,7 +292,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
264
292
  dnf_package.arch("i686")
265
293
  dnf_package.run_action(:install)
266
294
  expect(dnf_package.updated_by_last_action?).to be true
267
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.i686")
295
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
268
296
  end
269
297
  end
270
298
 
@@ -274,23 +302,23 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
274
302
  dnf_package.package_name("chef_rpm >= 1.2")
275
303
  dnf_package.run_action(:install)
276
304
  expect(dnf_package.updated_by_last_action?).to be true
277
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
305
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
278
306
  end
279
307
 
280
308
  it "when it is met, it does nothing" do
281
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
309
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
282
310
  dnf_package.package_name("chef_rpm >= 1.2")
283
311
  dnf_package.run_action(:install)
284
312
  expect(dnf_package.updated_by_last_action?).to be false
285
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
313
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
286
314
  end
287
315
 
288
316
  it "when it is met, it does nothing" do
289
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
317
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
290
318
  dnf_package.package_name("chef_rpm >= 1.2")
291
319
  dnf_package.run_action(:install)
292
320
  expect(dnf_package.updated_by_last_action?).to be false
293
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
321
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
294
322
  end
295
323
 
296
324
  it "with nothing installed, it installs the latest version" do
@@ -298,23 +326,39 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
298
326
  dnf_package.package_name("chef_rpm > 1.2")
299
327
  dnf_package.run_action(:install)
300
328
  expect(dnf_package.updated_by_last_action?).to be true
301
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
329
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
302
330
  end
303
331
 
304
332
  it "when it is not met by an installed rpm, it upgrades" do
305
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
333
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
306
334
  dnf_package.package_name("chef_rpm > 1.2")
307
335
  dnf_package.run_action(:install)
308
336
  expect(dnf_package.updated_by_last_action?).to be true
309
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
337
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
338
+ end
339
+
340
+ it "with an equality constraint, when it is not met by an installed rpm, it upgrades" do
341
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
342
+ dnf_package.package_name("chef_rpm = 1.10")
343
+ dnf_package.run_action(:install)
344
+ expect(dnf_package.updated_by_last_action?).to be true
345
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
346
+ end
347
+
348
+ it "with an equality constraint, when it is met by an installed rpm, it does nothing" do
349
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
350
+ dnf_package.package_name("chef_rpm = 1.2")
351
+ dnf_package.run_action(:install)
352
+ expect(dnf_package.updated_by_last_action?).to be false
353
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
310
354
  end
311
355
 
312
356
  it "when it is met by an installed rpm, it does nothing" do
313
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
357
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
314
358
  dnf_package.package_name("chef_rpm > 1.2")
315
359
  dnf_package.run_action(:install)
316
360
  expect(dnf_package.updated_by_last_action?).to be false
317
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
361
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
318
362
  end
319
363
 
320
364
  it "when there is no solution to the contraint" do
@@ -324,10 +368,34 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
324
368
  end
325
369
 
326
370
  it "when there is no solution to the contraint but an rpm is preinstalled" do
327
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
371
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
328
372
  dnf_package.package_name("chef_rpm > 2.0")
329
373
  expect { dnf_package.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
330
374
  end
375
+
376
+ it "with a less than constraint, when nothing is installed, it installs" do
377
+ flush_cache
378
+ dnf_package.package_name("chef_rpm < 1.10")
379
+ dnf_package.run_action(:install)
380
+ expect(dnf_package.updated_by_last_action?).to be true
381
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
382
+ end
383
+
384
+ it "with a less than constraint, when the install version matches, it does nothing" do
385
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
386
+ dnf_package.package_name("chef_rpm < 1.10")
387
+ dnf_package.run_action(:install)
388
+ expect(dnf_package.updated_by_last_action?).to be false
389
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
390
+ end
391
+
392
+ it "with a less than constraint, when the install version fails, it should downgrade" do
393
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
394
+ dnf_package.package_name("chef_rpm < 1.10")
395
+ dnf_package.run_action(:install)
396
+ expect(dnf_package.updated_by_last_action?).to be true
397
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
398
+ end
331
399
  end
332
400
 
333
401
  context "with source arguments" do
@@ -349,163 +417,237 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
349
417
  flush_cache
350
418
  dnf_package.name "something"
351
419
  dnf_package.package_name "somethingelse"
352
- dnf_package.source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.x86_64.rpm")
420
+ dnf_package.source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
353
421
  dnf_package.run_action(:install)
354
422
  expect(dnf_package.updated_by_last_action?).to be true
355
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
423
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
356
424
  end
357
425
 
358
426
  it "installs the package when the name is a path to a file" do
359
427
  flush_cache
360
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.x86_64.rpm")
428
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
361
429
  dnf_package.run_action(:install)
362
430
  expect(dnf_package.updated_by_last_action?).to be true
363
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
431
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
432
+ end
433
+
434
+ it "downgrade on a local file with allow_downgrade true works" do
435
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
436
+ dnf_package.version "1.2-1"
437
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
438
+ dnf_package.run_action(:install)
439
+ expect(dnf_package.updated_by_last_action?).to be true
440
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
364
441
  end
365
442
 
366
443
  it "does not downgrade the package with :install" do
367
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
368
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.x86_64.rpm")
444
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
445
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
369
446
  dnf_package.run_action(:install)
370
447
  expect(dnf_package.updated_by_last_action?).to be false
371
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
448
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
372
449
  end
373
450
 
374
451
  it "does not upgrade the package with :install" do
375
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
376
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.x86_64.rpm")
452
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
453
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.#{pkg_arch}.rpm")
377
454
  dnf_package.run_action(:install)
378
455
  expect(dnf_package.updated_by_last_action?).to be false
379
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
456
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
380
457
  end
381
458
 
382
459
  it "is idempotent when the package is already installed" do
383
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
384
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.x86_64.rpm")
460
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
461
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
385
462
  dnf_package.run_action(:install)
386
463
  expect(dnf_package.updated_by_last_action?).to be false
387
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
464
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
465
+ end
466
+
467
+ it "is idempotent when the package is already installed and there is a version string" do
468
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
469
+ dnf_package.version "1.2-1"
470
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
471
+ dnf_package.run_action(:install)
472
+ expect(dnf_package.updated_by_last_action?).to be false
473
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
474
+ end
475
+
476
+ it "is idempotent when the package is already installed and there is a version string with arch" do
477
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
478
+ dnf_package.version "1.2-1.#{pkg_arch}"
479
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
480
+ dnf_package.run_action(:install)
481
+ expect(dnf_package.updated_by_last_action?).to be false
482
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
388
483
  end
389
484
  end
390
485
 
391
486
  context "with no available version" do
392
487
  it "works when a package is installed" do
393
488
  FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
394
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
489
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
395
490
  dnf_package.run_action(:install)
396
491
  expect(dnf_package.updated_by_last_action?).to be false
397
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
492
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
398
493
  end
399
494
 
400
495
  it "works with a local source" do
401
496
  FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
402
497
  flush_cache
403
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.x86_64.rpm")
498
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
404
499
  dnf_package.run_action(:install)
405
500
  expect(dnf_package.updated_by_last_action?).to be true
406
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
501
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
407
502
  end
408
503
  end
409
504
 
410
- context "multipackage with arches" do
505
+ context "multipackage with arches", :intel_64bit do
411
506
  it "installs two rpms" do
412
507
  flush_cache
413
- dnf_package.package_name([ "chef_rpm.x86_64", "chef_rpm.i686" ] )
508
+ dnf_package.package_name([ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] )
414
509
  dnf_package.run_action(:install)
415
510
  expect(dnf_package.updated_by_last_action?).to be true
416
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.x86_64/)
417
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.i686/)
511
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
512
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
418
513
  end
419
514
 
420
515
  it "does nothing if both are installed" do
421
- preinstall("chef_rpm-1.10-1.x86_64.rpm", "chef_rpm-1.10-1.i686.rpm")
516
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm", "chef_rpm-1.10-1.i686.rpm")
422
517
  flush_cache
423
- dnf_package.package_name([ "chef_rpm.x86_64", "chef_rpm.i686" ] )
518
+ dnf_package.package_name([ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] )
424
519
  dnf_package.run_action(:install)
425
520
  expect(dnf_package.updated_by_last_action?).to be false
426
521
  end
427
522
 
428
523
  it "installs the second rpm if the first is installed" do
429
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
430
- dnf_package.package_name([ "chef_rpm.x86_64", "chef_rpm.i686" ] )
524
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
525
+ dnf_package.package_name([ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] )
431
526
  dnf_package.run_action(:install)
432
527
  expect(dnf_package.updated_by_last_action?).to be true
433
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.x86_64/)
434
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.i686/)
528
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
529
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
435
530
  end
436
531
 
437
532
  it "installs the first rpm if the second is installed" do
438
533
  preinstall("chef_rpm-1.10-1.i686.rpm")
439
- dnf_package.package_name([ "chef_rpm.x86_64", "chef_rpm.i686" ] )
534
+ dnf_package.package_name([ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] )
440
535
  dnf_package.run_action(:install)
441
536
  expect(dnf_package.updated_by_last_action?).to be true
442
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.x86_64/)
443
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.i686/)
537
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
538
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
444
539
  end
445
540
 
446
541
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
447
542
  it "installs two rpms with multi-arch" do
448
543
  flush_cache
449
544
  dnf_package.package_name(%w{chef_rpm chef_rpm} )
450
- dnf_package.arch(%w{x86_64 i686})
545
+ dnf_package.arch([pkg_arch, "i686"])
451
546
  dnf_package.run_action(:install)
452
547
  expect(dnf_package.updated_by_last_action?).to be true
453
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.x86_64/)
454
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.i686/)
548
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
549
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
455
550
  end
456
551
 
457
552
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
458
553
  it "installs the second rpm if the first is installed (muti-arch)" do
459
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
554
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
460
555
  dnf_package.package_name(%w{chef_rpm chef_rpm} )
461
- dnf_package.arch(%w{x86_64 i686})
556
+ dnf_package.arch([pkg_arch, "i686"])
462
557
  dnf_package.run_action(:install)
463
558
  expect(dnf_package.updated_by_last_action?).to be true
464
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.x86_64/)
465
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.i686/)
559
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
560
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
466
561
  end
467
562
 
468
563
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
469
564
  it "installs the first rpm if the second is installed (muti-arch)" do
470
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
565
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
471
566
  dnf_package.package_name(%w{chef_rpm chef_rpm} )
472
- dnf_package.arch(%w{x86_64 i686})
567
+ dnf_package.arch([pkg_arch, "i686"])
473
568
  dnf_package.run_action(:install)
474
569
  expect(dnf_package.updated_by_last_action?).to be true
475
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.x86_64/)
476
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(/chef_rpm-1.10-1.i686/)
570
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
571
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
477
572
  end
478
573
 
479
574
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
480
575
  it "does nothing if both are installed (muti-arch)" do
481
- preinstall("chef_rpm-1.10-1.x86_64.rpm", "chef_rpm-1.10-1.i686.rpm")
576
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm", "chef_rpm-1.10-1.i686.rpm")
482
577
  dnf_package.package_name(%w{chef_rpm chef_rpm} )
483
- dnf_package.arch(%w{x86_64 i686})
578
+ dnf_package.arch([pkg_arch, "i686"])
484
579
  dnf_package.run_action(:install)
485
580
  expect(dnf_package.updated_by_last_action?).to be false
486
581
  end
487
582
  end
583
+
584
+ context "repo controls" do
585
+ it "should fail with the repo disabled" do
586
+ flush_cache
587
+ dnf_package.options("--disablerepo=chef-dnf-localtesting")
588
+ expect { dnf_package.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
589
+ end
590
+
591
+ it "should work with disablerepo first" do
592
+ flush_cache
593
+ dnf_package.options(["--disablerepo=*", "--enablerepo=chef-dnf-localtesting"])
594
+ dnf_package.run_action(:install)
595
+ expect(dnf_package.updated_by_last_action?).to be true
596
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
597
+ end
598
+
599
+ it "should work to enable a disabled repo" do
600
+ shell_out!("dnf config-manager --set-disabled chef-dnf-localtesting")
601
+ flush_cache
602
+ expect { dnf_package.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
603
+ flush_cache
604
+ dnf_package.options("--enablerepo=chef-dnf-localtesting")
605
+ dnf_package.run_action(:install)
606
+ expect(dnf_package.updated_by_last_action?).to be true
607
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
608
+ end
609
+
610
+ it "when an idempotent install action is run, does not leave repos disabled" do
611
+ flush_cache
612
+ # this is a bit tricky -- we need this action to be idempotent, so that it doesn't recycle any
613
+ # caches, but need it to hit whatavailable with the repo disabled. using :upgrade like this
614
+ # accomplishes both those goals (it would be easier if we had other rpms in this repo, but with
615
+ # one rpm we need to do this).
616
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
617
+ dnf_package.options("--disablerepo=chef-dnf-localtesting")
618
+ dnf_package.run_action(:upgrade)
619
+ expect(dnf_package.updated_by_last_action?).to be false
620
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
621
+ # now we're still using the same cache in the dnf_helper.py cache and we test to see if the
622
+ # repo that we temporarily disabled is enabled on this pass.
623
+ dnf_package.package_name("chef_rpm-1.10-1.#{pkg_arch}")
624
+ dnf_package.options(nil)
625
+ dnf_package.run_action(:install)
626
+ expect(dnf_package.updated_by_last_action?).to be true
627
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
628
+ end
629
+ end
488
630
  end
489
631
 
490
632
  describe ":upgrade" do
491
633
  context "downgrades" do
492
634
  it "just work with DNF" do
493
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
635
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
494
636
  dnf_package.version("1.2")
495
637
  dnf_package.run_action(:install)
496
638
  expect(dnf_package.updated_by_last_action?).to be true
497
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
639
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}")
498
640
  end
499
641
 
500
642
  it "throws a deprecation warning with allow_downgrade" do
501
643
  Chef::Config[:treat_deprecation_warnings_as_errors] = false
502
644
  expect(Chef).to receive(:deprecated).with(:dnf_package_allow_downgrade, /^the allow_downgrade property on the dnf_package provider is not used/)
503
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
645
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
504
646
  dnf_package.version("1.2")
505
647
  dnf_package.run_action(:install)
506
648
  dnf_package.allow_downgrade true
507
649
  expect(dnf_package.updated_by_last_action?).to be true
508
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
650
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}")
509
651
  end
510
652
  end
511
653
 
@@ -514,62 +656,144 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
514
656
  flush_cache
515
657
  dnf_package.name "something"
516
658
  dnf_package.package_name "somethingelse"
517
- dnf_package.source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.x86_64.rpm")
659
+ dnf_package.source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
518
660
  dnf_package.run_action(:upgrade)
519
661
  expect(dnf_package.updated_by_last_action?).to be true
520
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
662
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
521
663
  end
522
664
 
523
665
  it "installs the package when the name is a path to a file" do
524
666
  flush_cache
525
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.x86_64.rpm")
667
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
526
668
  dnf_package.run_action(:upgrade)
527
669
  expect(dnf_package.updated_by_last_action?).to be true
528
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
670
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
529
671
  end
530
672
 
531
- it "downgrades the package" do
532
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
533
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.x86_64.rpm")
673
+ it "downgrades the package when allow_downgrade is true" do
674
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
675
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
534
676
  dnf_package.run_action(:upgrade)
535
677
  expect(dnf_package.updated_by_last_action?).to be true
536
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
678
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
537
679
  end
538
680
 
539
681
  it "upgrades the package" do
540
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
541
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.x86_64.rpm")
682
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
683
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.#{pkg_arch}.rpm")
542
684
  dnf_package.run_action(:upgrade)
543
685
  expect(dnf_package.updated_by_last_action?).to be true
544
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
686
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
545
687
  end
546
688
 
547
689
  it "is idempotent when the package is already installed" do
548
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
549
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.x86_64.rpm")
690
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
691
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
550
692
  dnf_package.run_action(:upgrade)
551
693
  expect(dnf_package.updated_by_last_action?).to be false
552
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
694
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
553
695
  end
554
696
  end
555
697
 
556
698
  context "with no available version" do
557
699
  it "works when a package is installed" do
558
700
  FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
559
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
560
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.x86_64.rpm")
701
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
702
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
561
703
  dnf_package.run_action(:upgrade)
562
704
  expect(dnf_package.updated_by_last_action?).to be false
563
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
705
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
564
706
  end
565
707
 
566
708
  it "works with a local source" do
567
709
  FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
568
710
  flush_cache
569
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.x86_64.rpm")
711
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
570
712
  dnf_package.run_action(:upgrade)
571
713
  expect(dnf_package.updated_by_last_action?).to be true
572
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
714
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
715
+ end
716
+ end
717
+
718
+ context "version pinning" do
719
+ it "with an equality pin in the name it upgrades a prior package" do
720
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
721
+ dnf_package.package_name("chef_rpm-1.10")
722
+ dnf_package.run_action(:upgrade)
723
+ expect(dnf_package.updated_by_last_action?).to be true
724
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
725
+ end
726
+
727
+ it "with a prco equality pin in the name it upgrades a prior package" do
728
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
729
+ dnf_package.package_name("chef_rpm = 1.10")
730
+ dnf_package.run_action(:upgrade)
731
+ expect(dnf_package.updated_by_last_action?).to be true
732
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
733
+ end
734
+
735
+ it "with an equality pin in the name it downgrades a later package" do
736
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
737
+ dnf_package.package_name("chef_rpm-1.2")
738
+ dnf_package.run_action(:upgrade)
739
+ expect(dnf_package.updated_by_last_action?).to be true
740
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
741
+ end
742
+
743
+ it "with a prco equality pin in the name it downgrades a later package" do
744
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
745
+ dnf_package.package_name("chef_rpm = 1.2")
746
+ dnf_package.run_action(:upgrade)
747
+ expect(dnf_package.updated_by_last_action?).to be true
748
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
749
+ end
750
+
751
+ it "with a > pin in the name and no rpm installed it installs" do
752
+ flush_cache
753
+ dnf_package.package_name("chef_rpm > 1.2")
754
+ dnf_package.run_action(:upgrade)
755
+ expect(dnf_package.updated_by_last_action?).to be true
756
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
757
+ end
758
+
759
+ it "with a < pin in the name and no rpm installed it installs" do
760
+ flush_cache
761
+ dnf_package.package_name("chef_rpm < 1.10")
762
+ dnf_package.run_action(:upgrade)
763
+ expect(dnf_package.updated_by_last_action?).to be true
764
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
765
+ end
766
+
767
+ it "with a > pin in the name and matching rpm installed it does nothing" do
768
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
769
+ dnf_package.package_name("chef_rpm > 1.2")
770
+ dnf_package.run_action(:upgrade)
771
+ expect(dnf_package.updated_by_last_action?).to be false
772
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
773
+ end
774
+
775
+ it "with a < pin in the name and no rpm installed it installs" do
776
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
777
+ dnf_package.package_name("chef_rpm < 1.10")
778
+ dnf_package.run_action(:upgrade)
779
+ expect(dnf_package.updated_by_last_action?).to be false
780
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
781
+ end
782
+
783
+ it "with a > pin in the name and non-matching rpm installed it upgrades" do
784
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
785
+ dnf_package.package_name("chef_rpm > 1.2")
786
+ dnf_package.run_action(:upgrade)
787
+ expect(dnf_package.updated_by_last_action?).to be true
788
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
789
+ end
790
+
791
+ it "with a < pin in the name and non-matching rpm installed it downgrades" do
792
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
793
+ dnf_package.package_name("chef_rpm < 1.10")
794
+ dnf_package.run_action(:upgrade)
795
+ expect(dnf_package.updated_by_last_action?).to be true
796
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
573
797
  end
574
798
  end
575
799
  end
@@ -581,106 +805,167 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
581
805
  flush_cache
582
806
  dnf_package.run_action(:remove)
583
807
  expect(dnf_package.updated_by_last_action?).to be false
584
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
808
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
585
809
  end
586
810
 
587
811
  it "removes the package if the package is installed" do
588
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
812
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
589
813
  dnf_package.run_action(:remove)
590
814
  expect(dnf_package.updated_by_last_action?).to be true
591
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
815
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
592
816
  end
593
817
 
594
818
  it "does not remove the package twice" do
595
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
819
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
596
820
  dnf_package.run_action(:remove)
597
821
  expect(dnf_package.updated_by_last_action?).to be true
598
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
822
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
599
823
  dnf_package.run_action(:remove)
600
824
  expect(dnf_package.updated_by_last_action?).to be false
601
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
825
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
602
826
  end
603
827
 
604
828
  it "removes the package if the prior version package is installed" do
605
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
829
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
606
830
  dnf_package.run_action(:remove)
607
831
  expect(dnf_package.updated_by_last_action?).to be true
608
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
832
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
609
833
  end
610
834
 
611
- it "removes the package if the i686 package is installed" do
835
+ it "removes the package if the i686 package is installed", :intel_64bit do
612
836
  skip "FIXME: should this be fixed or is the current behavior correct?"
613
837
  preinstall("chef_rpm-1.10-1.i686.rpm")
614
838
  dnf_package.run_action(:remove)
615
839
  expect(dnf_package.updated_by_last_action?).to be true
616
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
840
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
617
841
  end
618
842
 
619
- it "removes the package if the prior version i686 package is installed" do
843
+ it "removes the package if the prior version i686 package is installed", :intel_64bit do
620
844
  skip "FIXME: should this be fixed or is the current behavior correct?"
621
845
  preinstall("chef_rpm-1.2-1.i686.rpm")
622
846
  dnf_package.run_action(:remove)
623
847
  expect(dnf_package.updated_by_last_action?).to be true
624
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
848
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
625
849
  end
626
850
  end
627
851
 
628
- context "with 64-bit arch" do
629
- let(:package_name) { "chef_rpm.x86_64" }
852
+ context "with 64-bit arch", :intel_64bit do
853
+ let(:package_name) { "chef_rpm.#{pkg_arch}" }
630
854
  it "does nothing if the package is not installed" do
631
855
  flush_cache
632
856
  dnf_package.run_action(:remove)
633
857
  expect(dnf_package.updated_by_last_action?).to be false
634
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
858
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
635
859
  end
636
860
 
637
861
  it "removes the package if the package is installed" do
638
- preinstall("chef_rpm-1.10-1.x86_64.rpm")
862
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
639
863
  dnf_package.run_action(:remove)
640
864
  expect(dnf_package.updated_by_last_action?).to be true
641
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
865
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
642
866
  end
643
867
 
644
868
  it "removes the package if the prior version package is installed" do
645
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
869
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
646
870
  dnf_package.run_action(:remove)
647
871
  expect(dnf_package.updated_by_last_action?).to be true
648
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
872
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
649
873
  end
650
874
 
651
875
  it "does nothing if the i686 package is installed" do
652
876
  preinstall("chef_rpm-1.10-1.i686.rpm")
653
877
  dnf_package.run_action(:remove)
654
878
  expect(dnf_package.updated_by_last_action?).to be false
655
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.i686")
879
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
656
880
  end
657
881
 
658
882
  it "does nothing if the prior version i686 package is installed" do
659
883
  preinstall("chef_rpm-1.2-1.i686.rpm")
660
884
  dnf_package.run_action(:remove)
661
885
  expect(dnf_package.updated_by_last_action?).to be false
662
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.i686")
886
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.i686$")
663
887
  end
664
888
  end
665
889
 
666
- context "with 32-bit arch" do
890
+ context "with 32-bit arch", :intel_64bit do
667
891
  let(:package_name) { "chef_rpm.i686" }
668
892
  it "removes only the 32-bit arch if both are installed" do
669
- preinstall("chef_rpm-1.10-1.x86_64.rpm", "chef_rpm-1.10-1.i686.rpm")
893
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm", "chef_rpm-1.10-1.i686.rpm")
670
894
  dnf_package.run_action(:remove)
671
895
  expect(dnf_package.updated_by_last_action?).to be true
672
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.x86_64")
896
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
673
897
  end
674
898
  end
675
899
 
676
900
  context "with no available version" do
677
901
  it "works when a package is installed" do
678
902
  FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
679
- preinstall("chef_rpm-1.2-1.x86_64.rpm")
903
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
680
904
  dnf_package.run_action(:remove)
681
905
  expect(dnf_package.updated_by_last_action?).to be true
682
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
906
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
683
907
  end
684
908
  end
685
909
  end
910
+
911
+ describe ":lock and :unlock" do
912
+ before(:all) do
913
+ shell_out("dnf -y install python3-dnf-plugin-versionlock")
914
+ end
915
+
916
+ before(:each) do
917
+ shell_out("dnf versionlock delete 'chef_rpm-*'") # will exit with error when nothing is locked, we don't care
918
+ end
919
+
920
+ it "locks an rpm" do
921
+ flush_cache
922
+ dnf_package.package_name("chef_rpm")
923
+ dnf_package.run_action(:lock)
924
+ expect(dnf_package.updated_by_last_action?).to be true
925
+ expect(shell_out("dnf versionlock list").stdout.chomp).to match("^chef_rpm-0:")
926
+ end
927
+
928
+ it "does not lock if its already locked" do
929
+ flush_cache
930
+ shell_out!("dnf versionlock add chef_rpm")
931
+ dnf_package.package_name("chef_rpm")
932
+ dnf_package.run_action(:lock)
933
+ expect(dnf_package.updated_by_last_action?).to be false
934
+ expect(shell_out("dnf versionlock list").stdout.chomp).to match("^chef_rpm-0:")
935
+ end
936
+
937
+ it "unlocks an rpm" do
938
+ flush_cache
939
+ shell_out!("dnf versionlock add chef_rpm")
940
+ dnf_package.package_name("chef_rpm")
941
+ dnf_package.run_action(:unlock)
942
+ expect(dnf_package.updated_by_last_action?).to be true
943
+ expect(shell_out("dnf versionlock list").stdout.chomp).not_to match("^chef_rpm-0:")
944
+ end
945
+
946
+ it "does not unlock an already locked rpm" do
947
+ flush_cache
948
+ dnf_package.package_name("chef_rpm")
949
+ dnf_package.run_action(:unlock)
950
+ expect(dnf_package.updated_by_last_action?).to be false
951
+ expect(shell_out("dnf versionlock list").stdout.chomp).not_to match("^chef_rpm-0:")
952
+ end
953
+
954
+ it "check that we can lock based on provides" do
955
+ flush_cache
956
+ dnf_package.package_name("chef_rpm_provides")
957
+ dnf_package.run_action(:lock)
958
+ expect(dnf_package.updated_by_last_action?).to be true
959
+ expect(shell_out("dnf versionlock list").stdout.chomp).to match("^chef_rpm-0:")
960
+ end
961
+
962
+ it "check that we can unlock based on provides" do
963
+ flush_cache
964
+ shell_out!("dnf versionlock add chef_rpm")
965
+ dnf_package.package_name("chef_rpm_provides")
966
+ dnf_package.run_action(:unlock)
967
+ expect(dnf_package.updated_by_last_action?).to be true
968
+ expect(shell_out("dnf versionlock list").stdout.chomp).not_to match("^chef_rpm-0:")
969
+ end
970
+ end
686
971
  end