chef 17.10.163 → 18.0.169

Sign up to get free protection for your applications and to get access to all the features.
Files changed (330) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +19 -20
  3. data/README.md +7 -7
  4. data/Rakefile +3 -22
  5. data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +8 -7
  6. data/chef.gemspec +17 -15
  7. data/lib/chef/api_client_v1.rb +9 -1
  8. data/lib/chef/application/exit_code.rb +3 -3
  9. data/lib/chef/client.rb +182 -0
  10. data/lib/chef/compliance/input.rb +1 -1
  11. data/lib/chef/compliance/profile.rb +1 -1
  12. data/lib/chef/compliance/profile_collection.rb +0 -1
  13. data/lib/chef/compliance/waiver.rb +1 -1
  14. data/lib/chef/cookbook/syntax_check.rb +2 -2
  15. data/lib/chef/dsl/reader_helpers.rb +1 -1
  16. data/lib/chef/dsl/rest_resource.rb +77 -0
  17. data/lib/chef/event_dispatch/base.rb +3 -0
  18. data/lib/chef/exceptions.rb +8 -0
  19. data/lib/chef/http/authenticator.rb +170 -3
  20. data/lib/chef/http/ssl_policies.rb +4 -4
  21. data/lib/chef/mixin/checksum.rb +0 -6
  22. data/lib/chef/mixin/homebrew_user.rb +5 -15
  23. data/lib/chef/mixin/openssl_helper.rb +13 -17
  24. data/lib/chef/mixin/powershell_exec.rb +5 -28
  25. data/lib/chef/node/mixin/immutablize_array.rb +1 -0
  26. data/lib/chef/property.rb +5 -3
  27. data/lib/chef/provider/cron.rb +1 -5
  28. data/lib/chef/provider/file.rb +2 -2
  29. data/lib/chef/provider/group/windows.rb +1 -1
  30. data/lib/chef/provider/http_request.rb +11 -9
  31. data/lib/chef/provider/mount/linux.rb +5 -0
  32. data/lib/chef/provider/mount/mount.rb +8 -0
  33. data/lib/chef/provider/mount/windows.rb +1 -1
  34. data/lib/chef/provider/package/chocolatey.rb +1 -14
  35. data/lib/chef/provider/package/rubygems.rb +1 -1
  36. data/lib/chef/provider/package/windows/msi.rb +2 -2
  37. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
  38. data/lib/chef/provider/package/windows.rb +1 -1
  39. data/lib/chef/provider/package/yum/yum_helper.py +14 -2
  40. data/lib/chef/provider/package/zypper/version.rb +60 -0
  41. data/lib/chef/provider/package/zypper.rb +47 -8
  42. data/lib/chef/provider/service/windows.rb +1 -1
  43. data/lib/chef/provider/user/aix.rb +5 -0
  44. data/lib/chef/provider/user/linux.rb +29 -0
  45. data/lib/chef/provider/user/mac.rb +1 -1
  46. data/lib/chef/provider/user.rb +46 -14
  47. data/lib/chef/provider.rb +1 -1
  48. data/lib/chef/recipe.rb +1 -1
  49. data/lib/chef/resource/_rest_resource.rb +389 -0
  50. data/lib/chef/resource/alternatives.rb +0 -1
  51. data/lib/chef/resource/apt_package.rb +0 -1
  52. data/lib/chef/resource/apt_preference.rb +0 -1
  53. data/lib/chef/resource/apt_repository.rb +0 -1
  54. data/lib/chef/resource/apt_update.rb +0 -1
  55. data/lib/chef/resource/archive_file.rb +0 -1
  56. data/lib/chef/resource/bash.rb +0 -1
  57. data/lib/chef/resource/batch.rb +0 -1
  58. data/lib/chef/resource/bff_package.rb +0 -1
  59. data/lib/chef/resource/breakpoint.rb +0 -1
  60. data/lib/chef/resource/build_essential.rb +0 -1
  61. data/lib/chef/resource/cab_package.rb +0 -1
  62. data/lib/chef/resource/chef_client_config.rb +14 -18
  63. data/lib/chef/resource/chef_client_cron.rb +1 -2
  64. data/lib/chef/resource/chef_client_launchd.rb +2 -2
  65. data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
  66. data/lib/chef/resource/chef_client_systemd_timer.rb +1 -2
  67. data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
  68. data/lib/chef/resource/chef_gem.rb +0 -1
  69. data/lib/chef/resource/chef_handler.rb +0 -1
  70. data/lib/chef/resource/chef_sleep.rb +1 -3
  71. data/lib/chef/resource/chef_vault_secret.rb +0 -1
  72. data/lib/chef/resource/chocolatey_config.rb +0 -1
  73. data/lib/chef/resource/chocolatey_feature.rb +0 -1
  74. data/lib/chef/resource/chocolatey_package.rb +0 -1
  75. data/lib/chef/resource/chocolatey_source.rb +0 -1
  76. data/lib/chef/resource/cookbook_file.rb +0 -1
  77. data/lib/chef/resource/cron/_cron_shared.rb +0 -1
  78. data/lib/chef/resource/cron/cron.rb +0 -1
  79. data/lib/chef/resource/cron/cron_d.rb +15 -1
  80. data/lib/chef/resource/cron_access.rb +0 -1
  81. data/lib/chef/resource/csh.rb +0 -1
  82. data/lib/chef/resource/directory.rb +0 -1
  83. data/lib/chef/resource/dmg_package.rb +0 -1
  84. data/lib/chef/resource/dnf_package.rb +0 -1
  85. data/lib/chef/resource/dpkg_package.rb +0 -1
  86. data/lib/chef/resource/dsc_resource.rb +0 -1
  87. data/lib/chef/resource/dsc_script.rb +0 -1
  88. data/lib/chef/resource/execute.rb +0 -1
  89. data/lib/chef/resource/file.rb +0 -1
  90. data/lib/chef/resource/freebsd_package.rb +0 -1
  91. data/lib/chef/resource/gem_package.rb +0 -1
  92. data/lib/chef/resource/group.rb +25 -2
  93. data/lib/chef/resource/habitat/habitat_package.rb +0 -1
  94. data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
  95. data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
  96. data/lib/chef/resource/habitat_config.rb +0 -1
  97. data/lib/chef/resource/habitat_install.rb +0 -1
  98. data/lib/chef/resource/habitat_service.rb +0 -1
  99. data/lib/chef/resource/habitat_user_toml.rb +0 -1
  100. data/lib/chef/resource/homebrew_cask.rb +8 -8
  101. data/lib/chef/resource/homebrew_package.rb +1 -2
  102. data/lib/chef/resource/homebrew_tap.rb +5 -6
  103. data/lib/chef/resource/homebrew_update.rb +0 -2
  104. data/lib/chef/resource/hostname.rb +0 -1
  105. data/lib/chef/resource/http_request.rb +0 -1
  106. data/lib/chef/resource/ifconfig.rb +0 -1
  107. data/lib/chef/resource/inspec_input.rb +0 -1
  108. data/lib/chef/resource/inspec_waiver.rb +0 -1
  109. data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
  110. data/lib/chef/resource/ips_package.rb +0 -1
  111. data/lib/chef/resource/kernel_module.rb +0 -1
  112. data/lib/chef/resource/ksh.rb +0 -1
  113. data/lib/chef/resource/launchd.rb +0 -1
  114. data/lib/chef/resource/link.rb +0 -1
  115. data/lib/chef/resource/locale.rb +2 -6
  116. data/lib/chef/resource/log.rb +0 -1
  117. data/lib/chef/resource/lwrp_base.rb +0 -4
  118. data/lib/chef/resource/macos_userdefaults.rb +5 -10
  119. data/lib/chef/resource/macosx_service.rb +0 -1
  120. data/lib/chef/resource/macports_package.rb +0 -1
  121. data/lib/chef/resource/mdadm.rb +0 -1
  122. data/lib/chef/resource/mount.rb +0 -1
  123. data/lib/chef/resource/msu_package.rb +0 -1
  124. data/lib/chef/resource/notify_group.rb +0 -2
  125. data/lib/chef/resource/ohai.rb +0 -1
  126. data/lib/chef/resource/ohai_hint.rb +0 -1
  127. data/lib/chef/resource/openbsd_package.rb +0 -1
  128. data/lib/chef/resource/openssl_dhparam.rb +0 -2
  129. data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
  130. data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
  131. data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
  132. data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
  133. data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
  134. data/lib/chef/resource/openssl_x509_crl.rb +0 -2
  135. data/lib/chef/resource/openssl_x509_request.rb +0 -2
  136. data/lib/chef/resource/osx_profile.rb +0 -1
  137. data/lib/chef/resource/package.rb +0 -1
  138. data/lib/chef/resource/pacman_package.rb +0 -1
  139. data/lib/chef/resource/paludis_package.rb +0 -1
  140. data/lib/chef/resource/perl.rb +0 -1
  141. data/lib/chef/resource/plist.rb +7 -3
  142. data/lib/chef/resource/portage_package.rb +0 -1
  143. data/lib/chef/resource/powershell_package.rb +0 -1
  144. data/lib/chef/resource/powershell_package_source.rb +0 -1
  145. data/lib/chef/resource/powershell_script.rb +0 -1
  146. data/lib/chef/resource/python.rb +0 -1
  147. data/lib/chef/resource/reboot.rb +0 -1
  148. data/lib/chef/resource/registry_key.rb +0 -1
  149. data/lib/chef/resource/remote_directory.rb +0 -1
  150. data/lib/chef/resource/remote_file.rb +0 -1
  151. data/lib/chef/resource/rhsm_errata.rb +0 -1
  152. data/lib/chef/resource/rhsm_errata_level.rb +0 -1
  153. data/lib/chef/resource/rhsm_register.rb +0 -3
  154. data/lib/chef/resource/rhsm_repo.rb +0 -1
  155. data/lib/chef/resource/rhsm_subscription.rb +0 -1
  156. data/lib/chef/resource/route.rb +0 -1
  157. data/lib/chef/resource/rpm_package.rb +0 -1
  158. data/lib/chef/resource/ruby.rb +0 -1
  159. data/lib/chef/resource/ruby_block.rb +0 -1
  160. data/lib/chef/resource/scm/_scm.rb +0 -2
  161. data/lib/chef/resource/scm/git.rb +0 -2
  162. data/lib/chef/resource/scm/subversion.rb +0 -2
  163. data/lib/chef/resource/script.rb +0 -1
  164. data/lib/chef/resource/selinux/common_helpers.rb +47 -0
  165. data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
  166. data/lib/chef/resource/selinux/selinux_default.erb +15 -0
  167. data/lib/chef/resource/selinux_boolean.rb +101 -0
  168. data/lib/chef/resource/selinux_fcontext.rb +160 -0
  169. data/lib/chef/resource/selinux_install.rb +107 -0
  170. data/lib/chef/resource/selinux_module.rb +143 -0
  171. data/lib/chef/resource/selinux_permissive.rb +64 -0
  172. data/lib/chef/resource/selinux_port.rb +118 -0
  173. data/lib/chef/resource/selinux_state.rb +166 -0
  174. data/lib/chef/resource/service.rb +0 -1
  175. data/lib/chef/resource/smartos_package.rb +0 -1
  176. data/lib/chef/resource/snap_package.rb +0 -1
  177. data/lib/chef/resource/solaris_package.rb +0 -1
  178. data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
  179. data/lib/chef/resource/sudo.rb +0 -1
  180. data/lib/chef/resource/support/client.erb +5 -6
  181. data/lib/chef/resource/swap_file.rb +0 -1
  182. data/lib/chef/resource/sysctl.rb +1 -2
  183. data/lib/chef/resource/systemd_unit.rb +0 -1
  184. data/lib/chef/resource/template.rb +0 -1
  185. data/lib/chef/resource/timezone.rb +0 -1
  186. data/lib/chef/resource/user/aix_user.rb +0 -1
  187. data/lib/chef/resource/user/linux_user.rb +0 -1
  188. data/lib/chef/resource/user/mac_user.rb +0 -1
  189. data/lib/chef/resource/user/pw_user.rb +0 -1
  190. data/lib/chef/resource/user/solaris_user.rb +0 -1
  191. data/lib/chef/resource/user/windows_user.rb +0 -1
  192. data/lib/chef/resource/user.rb +10 -1
  193. data/lib/chef/resource/user_ulimit.rb +0 -1
  194. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
  195. data/lib/chef/resource/windows_ad_join.rb +0 -2
  196. data/lib/chef/resource/windows_audit_policy.rb +0 -2
  197. data/lib/chef/resource/windows_auto_run.rb +0 -1
  198. data/lib/chef/resource/windows_defender.rb +0 -1
  199. data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
  200. data/lib/chef/resource/windows_dfs_folder.rb +0 -1
  201. data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
  202. data/lib/chef/resource/windows_dfs_server.rb +0 -1
  203. data/lib/chef/resource/windows_dns_record.rb +0 -1
  204. data/lib/chef/resource/windows_dns_zone.rb +0 -1
  205. data/lib/chef/resource/windows_env.rb +0 -1
  206. data/lib/chef/resource/windows_feature.rb +0 -1
  207. data/lib/chef/resource/windows_feature_dism.rb +0 -1
  208. data/lib/chef/resource/windows_feature_powershell.rb +0 -1
  209. data/lib/chef/resource/windows_firewall_profile.rb +0 -2
  210. data/lib/chef/resource/windows_firewall_rule.rb +0 -1
  211. data/lib/chef/resource/windows_font.rb +2 -3
  212. data/lib/chef/resource/windows_package.rb +0 -1
  213. data/lib/chef/resource/windows_pagefile.rb +0 -2
  214. data/lib/chef/resource/windows_path.rb +0 -1
  215. data/lib/chef/resource/windows_printer.rb +0 -1
  216. data/lib/chef/resource/windows_printer_port.rb +0 -1
  217. data/lib/chef/resource/windows_script.rb +0 -2
  218. data/lib/chef/resource/windows_security_policy.rb +0 -1
  219. data/lib/chef/resource/windows_service.rb +0 -1
  220. data/lib/chef/resource/windows_share.rb +0 -1
  221. data/lib/chef/resource/windows_shortcut.rb +1 -2
  222. data/lib/chef/resource/windows_task.rb +0 -1
  223. data/lib/chef/resource/windows_uac.rb +0 -1
  224. data/lib/chef/resource/windows_update_settings.rb +0 -1
  225. data/lib/chef/resource/windows_user_privilege.rb +0 -1
  226. data/lib/chef/resource/windows_workgroup.rb +0 -1
  227. data/lib/chef/resource/yum_package.rb +0 -1
  228. data/lib/chef/resource/yum_repository.rb +0 -1
  229. data/lib/chef/resource/zypper_package.rb +0 -1
  230. data/lib/chef/resource/zypper_repository.rb +0 -1
  231. data/lib/chef/resource.rb +12 -5
  232. data/lib/chef/resources.rb +7 -0
  233. data/lib/chef/run_context.rb +3 -3
  234. data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
  235. data/lib/chef/version.rb +1 -1
  236. data/lib/chef/win32/handle.rb +6 -7
  237. data/lib/chef/win32/registry.rb +7 -3
  238. data/spec/data/rubygems.org/sexp_processor-info +2 -1
  239. data/spec/data/trusted_certs/example.crt +20 -29
  240. data/spec/data/trusted_certs/example_no_cn.crt +34 -30
  241. data/spec/data/trusted_certs/opscode.pem +54 -33
  242. data/spec/functional/resource/chocolatey_package_spec.rb +20 -32
  243. data/spec/functional/resource/dsc_script_spec.rb +1 -1
  244. data/spec/functional/resource/group_spec.rb +26 -42
  245. data/spec/functional/resource/link_spec.rb +8 -8
  246. data/spec/functional/resource/macos_userdefaults_spec.rb +4 -4
  247. data/spec/functional/resource/plist_spec.rb +25 -0
  248. data/spec/functional/resource/user/linux_user_spec.rb +127 -0
  249. data/spec/functional/resource/windows_certificate_spec.rb +1 -26
  250. data/spec/functional/resource/windows_font_spec.rb +12 -9
  251. data/spec/functional/resource/yum_package_spec.rb +1 -17
  252. data/spec/functional/resource/zypper_package_spec.rb +12 -10
  253. data/spec/functional/shell_spec.rb +1 -2
  254. data/spec/functional/version_spec.rb +1 -1
  255. data/spec/functional/win32/registry_spec.rb +0 -3
  256. data/spec/integration/client/client_spec.rb +82 -3
  257. data/spec/integration/client/exit_code_spec.rb +1 -1
  258. data/spec/integration/client/ipv6_spec.rb +1 -1
  259. data/spec/integration/compliance/compliance_spec.rb +1 -1
  260. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  261. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  262. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  263. data/spec/integration/recipes/notifies_spec.rb +1 -1
  264. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  265. data/spec/integration/recipes/remote_directory.rb +1 -1
  266. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  267. data/spec/integration/recipes/use_partial_spec.rb +2 -1
  268. data/spec/integration/solo/solo_spec.rb +2 -2
  269. data/spec/spec_helper.rb +1 -5
  270. data/spec/support/platform_helpers.rb +0 -4
  271. data/spec/support/ruby_installer.rb +1 -1
  272. data/spec/support/shared/functional/windows_script.rb +2 -2
  273. data/spec/unit/application/client_spec.rb +0 -10
  274. data/spec/unit/client_spec.rb +70 -2
  275. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
  276. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  277. data/spec/unit/http/authenticator_spec.rb +68 -0
  278. data/spec/unit/mixin/checksum_spec.rb +0 -28
  279. data/spec/unit/mixin/homebrew_user_spec.rb +7 -30
  280. data/spec/unit/mixin/openssl_helper_spec.rb +1 -1
  281. data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
  282. data/spec/unit/platform/query_helpers_spec.rb +2 -17
  283. data/spec/unit/provider/cron_spec.rb +0 -34
  284. data/spec/unit/provider/http_request_spec.rb +60 -72
  285. data/spec/unit/provider/mount/linux_spec.rb +10 -0
  286. data/spec/unit/provider/package/chocolatey_spec.rb +3 -20
  287. data/spec/unit/provider/package/rubygems_spec.rb +1 -1
  288. data/spec/unit/provider/package/zypper_spec.rb +32 -0
  289. data/spec/unit/provider/user/linux_spec.rb +51 -11
  290. data/spec/unit/provider/user_spec.rb +24 -6
  291. data/spec/unit/resource/archive_file_spec.rb +1 -1
  292. data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
  293. data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
  294. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
  295. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +2 -2
  296. data/spec/unit/resource/cron_d_spec.rb +37 -1
  297. data/spec/unit/resource/macos_user_defaults_spec.rb +4 -4
  298. data/spec/unit/resource/rest_resource_spec.rb +381 -0
  299. data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
  300. data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
  301. data/spec/unit/resource/selinux_install_spec.rb +60 -0
  302. data/spec/unit/resource/selinux_module_spec.rb +55 -0
  303. data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
  304. data/spec/unit/resource/selinux_port_spec.rb +42 -0
  305. data/spec/unit/resource/selinux_state_spec.rb +46 -0
  306. data/spec/unit/resource/sysctl_spec.rb +2 -2
  307. data/spec/unit/resource/user/linux_user_spec.rb +42 -0
  308. data/spec/unit/resource_spec.rb +8 -2
  309. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
  310. data/tasks/rspec.rb +1 -1
  311. metadata +106 -55
  312. data/spec/functional/assets/yumrepo-empty/repodata/01a3b-filelists.sqlite.bz2 +0 -0
  313. data/spec/functional/assets/yumrepo-empty/repodata/401dc-filelists.xml.gz +0 -0
  314. data/spec/functional/assets/yumrepo-empty/repodata/5dc1e-primary.sqlite.bz2 +0 -0
  315. data/spec/functional/assets/yumrepo-empty/repodata/6bf96-other.xml.gz +0 -0
  316. data/spec/functional/assets/yumrepo-empty/repodata/7c365-other.sqlite.bz2 +0 -0
  317. data/spec/functional/assets/yumrepo-empty/repodata/dabe2-primary.xml.gz +0 -0
  318. data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +0 -55
  319. data/spec/integration/client/fips_spec.rb +0 -29
  320. data/spec/integration/client/open_ssl_spec.rb +0 -20
  321. /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.0.nupkg → test-A.1.0.nupkg} +0 -0
  322. /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.0.nupkg → test-A.1.5.nupkg} +0 -0
  323. /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.0.nupkg → test-A.2.0.nupkg} +0 -0
  324. /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.0.nupkg → test-B.1.0.nupkg} +0 -0
  325. /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
  326. /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
  327. /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
  328. /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
  329. /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
  330. /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
@@ -25,50 +25,39 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
25
25
 
26
26
  def group_should_exist(group)
27
27
  case ohai[:os]
28
- when "freebsd"
29
- expect(shell_out("pw groupshow -n #{group}").exitstatus).to eq(0)
30
- when "windows"
31
- expect { Chef::Util::Windows::NetGroup.new(group).local_get_members }.not_to raise_error
32
- else
28
+ when "linux"
33
29
  expect { Etc.getgrnam(group) }.not_to raise_error
34
30
  expect(group).to eq(Etc.getgrnam(group).name)
31
+ when "windows"
32
+ expect { Chef::Util::Windows::NetGroup.new(group).local_get_members }.not_to raise_error
35
33
  end
36
34
  end
37
35
 
38
36
  def user_exist_in_group?(user)
39
37
  case ohai[:platform_family]
40
- when "freebsd"
41
- cmd = Mixlib::ShellOut.new("getent group #{group_name} #{user}").run_command.stdout
42
- if cmd.include? user
43
- true
44
- else
45
- false
46
- end
38
+ when "windows"
39
+ user_sid = sid_string_from_user(user)
40
+ user_sid.nil? ? false : Chef::Util::Windows::NetGroup.new(group_name).local_get_members.include?(user_sid)
47
41
  when "mac_os_x"
48
42
  membership_info = shell_out("dscl . -read /Groups/#{group_name}").stdout
49
43
  members = membership_info.split(" ")
50
44
  members.shift # Get rid of GroupMembership: string
51
45
  members.include?(user)
52
- when "windows"
53
- user_sid = sid_string_from_user(user)
54
- user_sid.nil? ? false : Chef::Util::Windows::NetGroup.new(group_name).local_get_members.include?(user_sid)
55
46
  else
56
- # TODO For some reason our temporary AIX 7.2 system does not correctly report group membership immediately after changes have been made.
57
- # Adding a 2 second delay for this platform is enough to get correct results.
58
- # We hope to remove this delay after we get more permanent AIX 7.2 systems in our CI pipeline. reference: https://github.com/chef/release-engineering/issues/1617
59
- sleep 2 if aix? && (ohai[:platform_version] == "7.2")
47
+ # NOTE: For some reason our temporary AIX 7.x systems do not correctly report group membership immediately after changes have been made.
48
+ # Adding a delay for this platform is enough to get correct results.
49
+ # reference: https://github.com/chef/release-engineering/issues/1617
50
+ sleep 3 if aix?
60
51
  Etc.getgrnam(group_name).mem.include?(user)
61
52
  end
62
53
  end
63
54
 
64
55
  def group_should_not_exist(group)
65
56
  case ohai[:os]
66
- when "freebsd"
67
- expect(shell_out("pw groupshow -n #{group}").exitstatus).to eq(65)
57
+ when "linux"
58
+ expect { Etc.getgrnam(group) }.to raise_error(ArgumentError, "can't find group for #{group}")
68
59
  when "windows"
69
60
  expect { Chef::Util::Windows::NetGroup.new(group).local_get_members }.to raise_error(ArgumentError, /The group name could not be found./)
70
- else
71
- expect { Etc.getgrnam(group) }.to raise_error(ArgumentError, "can't find group for #{group}")
72
61
  end
73
62
  end
74
63
 
@@ -144,6 +133,10 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
144
133
  temp_resource.append(true)
145
134
  temp_resource.run_action(:modify)
146
135
  members.each do |member|
136
+ # NOTE For some reason our temporary AIX 7.x systems do not correctly report group membership immediately after changes have been made.
137
+ # Adding a delay for this platform is enough to get correct results.
138
+ # reference: https://github.com/chef/release-engineering/issues/1617
139
+ sleep 3 if aix?
147
140
  expect(user_exist_in_group?(member)).to eq(true)
148
141
  end
149
142
  end
@@ -169,7 +162,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
169
162
  end
170
163
 
171
164
  # dscl doesn't perform any error checking and will let you add users that don't exist.
172
- describe "when no users exist", :not_supported_on_macos, :not_supported_on_freebsd_gte_12_3 do
165
+ describe "when no users exist", :not_supported_on_macos do
173
166
  describe "when append is not set" do
174
167
  # excluded_members can only be used when append is set. It is ignored otherwise.
175
168
  let(:excluded_members) { [] }
@@ -210,14 +203,13 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
210
203
  end
211
204
  end
212
205
 
213
- describe "when append is not set", :not_supported_on_freebsd_gte_12_3 do
206
+ describe "when append is not set" do
214
207
  it "should set the group to to contain given members" do
215
208
  group_resource.run_action(tested_action)
216
209
 
217
210
  included_members.each do |member|
218
211
  expect(user_exist_in_group?(member)).to eq(true)
219
212
  end
220
-
221
213
  (spec_members - included_members).each do |member|
222
214
  expect(user_exist_in_group?(member)).to eq(false)
223
215
  end
@@ -235,16 +227,14 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
235
227
  included_members.each do |member|
236
228
  expect(user_exist_in_group?(member)).to eq(true)
237
229
  end
238
- unless freebsd?
239
- (spec_members - included_members).each do |member|
240
- expect(user_exist_in_group?(member)).to eq(false)
241
- end
230
+ (spec_members - included_members).each do |member|
231
+ expect(user_exist_in_group?(member)).to eq(false)
242
232
  end
243
233
  end
244
234
  end
245
235
  end
246
236
 
247
- describe "when append is set", :not_supported_on_freebsd_gte_12_3 do
237
+ describe "when append is set" do
248
238
  before(:each) do
249
239
  group_resource.append(true)
250
240
  end
@@ -255,7 +245,6 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
255
245
  included_members.each do |member|
256
246
  expect(user_exist_in_group?(member)).to eq(true)
257
247
  end
258
-
259
248
  excluded_members.each do |member|
260
249
  expect(user_exist_in_group?(member)).to eq(false)
261
250
  end
@@ -272,7 +261,6 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
272
261
  included_members.each do |member|
273
262
  expect(user_exist_in_group?(member)).to eq(true)
274
263
  end
275
-
276
264
  excluded_members.each do |member|
277
265
  expect(user_exist_in_group?(member)).to eq(false)
278
266
  end
@@ -352,7 +340,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
352
340
  expect(group_resource.append).to eq(false)
353
341
  end
354
342
 
355
- describe "group create action", :not_supported_on_freebsd_gte_12_3, :not_supported_on_macos, :not_supported_on_aix do
343
+ describe "group create action" do
356
344
  after(:each) do
357
345
  group_resource.run_action(:remove)
358
346
  group_should_not_exist(group_name)
@@ -409,7 +397,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
409
397
  end
410
398
 
411
399
  describe "group remove action" do
412
- describe "when there is a group", :not_supported_on_freebsd_gte_12_3, :not_supported_on_macos, :not_supported_on_aix do
400
+ describe "when there is a group" do
413
401
  before do
414
402
  group_resource.run_action(:create)
415
403
  group_should_exist(group_name)
@@ -441,7 +429,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
441
429
  end
442
430
  end
443
431
 
444
- describe "when there is a group", :not_supported_on_macos, :not_supported_on_aix do
432
+ describe "when there is a group", :not_supported_on_freebsd_gte_12_3 do
445
433
  it_behaves_like "correct group management"
446
434
  end
447
435
 
@@ -474,16 +462,12 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
474
462
  end
475
463
 
476
464
  it "does not raise an error on manage" do
477
- if freebsd?
478
- allow(shell_out).to receive("pw user show").and_return(double("User"))
479
- else
480
- allow(Etc).to receive(:getpwnam).and_return(double("User"))
481
- end
465
+ allow(Etc).to receive(:getpwnam).and_return(double("User"))
482
466
  expect { group_resource.run_action(:manage) }.not_to raise_error
483
467
  end
484
468
  end
485
469
 
486
- describe "when there is a group", :not_supported_on_macos, :not_supported_on_aix do
470
+ describe "when there is a group", :not_supported_on_freebsd_gte_12_3 do
487
471
  it_behaves_like "correct group management"
488
472
  end
489
473
 
@@ -345,17 +345,17 @@ describe Chef::Resource::Link do
345
345
  let(:test_user) { "test-link-user" }
346
346
  before do
347
347
  user(test_user).run_action(:create)
348
- # TODO For some reason our temporary AIX 7.2 system does not correctly report user existence immediately after changes have been made.
349
- # Adding a 2 second delay for this platform is enough to get correct results.
350
- # We hope to remove this delay after we get more permanent AIX 7.2 systems in our CI pipeline. reference: https://github.com/chef/release-engineering/issues/1617
351
- sleep 2 if aix? && (ohai[:platform_version] == "7.2")
348
+ # NOTE: For some reason our temporary AIX 7.x systems do not correctly report user existence immediately after changes have been made.
349
+ # Adding a delay for this platform is enough to get correct results.
350
+ # reference: https://github.com/chef/release-engineering/issues/1617
351
+ sleep 3 if aix?
352
352
  end
353
353
  after do
354
354
  user(test_user).run_action(:remove)
355
- # TODO For some reason our temporary AIX 7.2 system does not correctly report user existence immediately after changes have been made.
356
- # Adding a 2 second delay for this platform is enough to get correct results.
357
- # We hope to remove this delay after we get more permanent AIX 7.2 systems in our CI pipeline. reference: https://github.com/chef/release-engineering/issues/1617
358
- sleep 2 if aix? && (ohai[:platform_version] == "7.2")
355
+ # TODO For some reason our temporary AIX 7.x systems do not correctly report user existence immediately after changes have been made.
356
+ # Adding a delay for this platform is enough to get correct results.
357
+ # reference: https://github.com/chef/release-engineering/issues/1617
358
+ sleep 3 if aix?
359
359
  end
360
360
  before(:each) do
361
361
  resource.owner(test_user)
@@ -38,12 +38,12 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
38
38
  expect(resource.domain).to eq("NSGlobalDomain")
39
39
  end
40
40
 
41
- it ":all for the host property" do
42
- expect(resource.host).to eq(:all)
41
+ it "nil for the host property" do
42
+ expect(resource.host).to be_nil
43
43
  end
44
44
 
45
- it ":current for the user property" do
46
- expect(resource.user).to eq(:current)
45
+ it "nil for the user property" do
46
+ expect(resource.user).to be_nil
47
47
  end
48
48
 
49
49
  it ":write for resource action" do
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+ require "plist"
3
+
4
+ describe Chef::Resource::PlistResource, :macos_only, requires_root: true do
5
+ include RecipeDSLHelper
6
+
7
+ let(:global_prefs) do
8
+ File.join(Dir.mktmpdir, ".GlobalPreferences.plist")
9
+ end
10
+
11
+ before(:each) do
12
+ FileUtils.rm_f global_prefs
13
+ end
14
+
15
+ context "make Monday the first DOW" do
16
+ it "creates a new plist with a hash value" do
17
+ plist global_prefs do
18
+ entry "AppleFirstWeekday"
19
+ value(gregorian: 4)
20
+ end
21
+ expect(File.exist?(global_prefs))
22
+ expect(shell_out!("/usr/libexec/PlistBuddy -c 'Print :\"AppleFirstWeekday\":gregorian' \"#{global_prefs}\"").stdout.to_i).to eq(4)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,127 @@
1
+ #
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+ require "chef/mixin/shell_out"
20
+
21
+ metadata = {
22
+ requires_root: true,
23
+ linux_only: true,
24
+ }
25
+
26
+ describe "Chef::Resource::User with Chef::Provider::User::LinuxUser provider", metadata do
27
+ include Chef::Mixin::ShellOut
28
+
29
+ def clean_user
30
+ shell_out!("/usr/sbin/userdel #{username}")
31
+ rescue Mixlib::ShellOut::ShellCommandFailed
32
+ # Raised when the user is already cleaned
33
+ end
34
+
35
+ def ensure_file_cache_path_exists
36
+ path = Chef::Config["file_cache_path"]
37
+ FileUtils.mkdir_p(path) unless File.directory?(path)
38
+ end
39
+
40
+ def user_should_exist
41
+ expect(shell_out("grep -q #{username} /etc/passwd").error?).to be(false)
42
+ end
43
+
44
+ def check_password(pass, user)
45
+ expect(shell_out("grep ^#{user}: /etc/shadow | cut -d: -f2 | grep ^#{pass}$").exitstatus).to eq(0)
46
+ end
47
+
48
+ let(:node) do
49
+ n = Chef::Node.new
50
+ n.consume_external_attrs(OHAI_SYSTEM.data.dup, {})
51
+ n
52
+ end
53
+
54
+ let(:events) do
55
+ Chef::EventDispatch::Dispatcher.new
56
+ end
57
+
58
+ let(:run_context) do
59
+ Chef::RunContext.new(node, {}, events)
60
+ end
61
+
62
+ let(:username) do
63
+ "greatchef"
64
+ end
65
+
66
+ let(:uid) { nil }
67
+ let(:gid) do
68
+ # SLES 15 doesn't have the "20" group and
69
+ # so lets just pick the last group... no,
70
+ # Etc.group.map(&:gid).last does not work
71
+ Etc.enum_for(:group).map(&:gid).last
72
+ end
73
+ let(:home) { nil }
74
+ let(:manage_home) { false }
75
+ let(:password) { "XXXYYYZZZ" }
76
+ let(:comment) { "Great Chef" }
77
+ let(:shell) { "/bin/bash" }
78
+ let(:salt) { nil }
79
+
80
+ let(:user_resource) do
81
+ r = Chef::Resource::User::LinuxUser.new("TEST USER RESOURCE", run_context)
82
+ r.username(username)
83
+ r.uid(uid)
84
+ r.gid(gid)
85
+
86
+ r.home(home)
87
+ r.shell(shell)
88
+ r.comment(comment)
89
+ r.manage_home(manage_home)
90
+ r.password(password)
91
+ r.salt(salt)
92
+ r
93
+ end
94
+
95
+ before do
96
+ clean_user
97
+ ensure_file_cache_path_exists
98
+ end
99
+
100
+ after(:each) do
101
+ clean_user
102
+ end
103
+
104
+ describe "action :create" do
105
+ it "should create the user" do
106
+ user_resource.run_action(:create)
107
+ user_should_exist
108
+ check_password(password, username)
109
+ end
110
+ end
111
+
112
+ describe "when user exists" do
113
+ before do
114
+ existing_resource = user_resource.dup
115
+ existing_resource.run_action(:create)
116
+ user_should_exist
117
+ end
118
+
119
+ describe "when password is updated" do
120
+ it "should update the password of the user" do
121
+ user_resource.password("mykitchen")
122
+ user_resource.run_action(:create)
123
+ check_password("mykitchen", username)
124
+ end
125
+ end
126
+ end
127
+ end
@@ -56,34 +56,10 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
56
56
  let(:store) { "Chef-Functional-Test" }
57
57
  let(:store_name) { "MY" }
58
58
  let(:store_location) { "LocalMachine" }
59
- let(:test_cert_body) do
60
- <<~CERT
61
- -----BEGIN CERTIFICATE-----
62
- MIIDQTCCAimgAwIBAgIQX3zqNCJbsKlEvzCz3Z9aNDANBgkqhkiG9w0BAQsFADAh
63
- MR8wHQYDVQQDDBZ3d3cuZHVtbXljaGVmdGVzdHMuY29tMCAXDTIwMDMwNTEwMjcw
64
- NVoYDzIxMjAwMzA1MTAzNzA2WjAhMR8wHQYDVQQDDBZ3d3cuZHVtbXljaGVmdGVz
65
- dHMuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtuYKDb6woWIH
66
- HPPOrcVpgJFVxbkjgk+tsYwbIiqR9jtRaKE6nM/awOgn9/dFF4k8KB8Em0sUx7Vq
67
- J3YhK2N2cAacgP2Frqqf5znpNBBOg968RoZzGx0EiXFvLsqC4y8ggApWTbMXPRk4
68
- 1a7GlpUpSqI3y5cLeEbzwGQKu8I1I+v7P2fTlnJPHarM7sBbL8bieukkFHYu78iV
69
- u1wpKOCCfs5DTmJu8WN+z1Mar9vyrWMBlt2wBBgNHPz5mcXUzJHTzaI/D9RGgBgF
70
- V0IkNqISx/IzR62jjj2g6MgTH4G/0mM6O5sxduM4yGmWZNZpVzh0yMLgH619MZlj
71
- SMQIN3U/SQIDAQABo3MwcTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYB
72
- BQUHAwIGCCsGAQUFBwMBMCEGA1UdEQQaMBiCFnd3dy5kdW1teWNoZWZ0ZXN0cy5j
73
- b20wHQYDVR0OBBYEFHwS3gs03m6RcpR+66u4OqGiZdYnMA0GCSqGSIb3DQEBCwUA
74
- A4IBAQCFHqMjHUfBZahIsKHQIcFCbC1NFh1ZHlJKZzrRBRwRzX19OttHGMyLpDd6
75
- tM9Ac6LLR8S4QIWg+HF3IrkN+vfTRDZAccj+tIwBRstmdsEz/rAJ79Vb/00mXZQx
76
- 0FPiBDR3hE7On2oo24DU8kJP3v6TrunwtIomVGqrrkwZzvxqyW+WJMB2shGNFw5J
77
- mKYBiiXsHl4Bi7V4zhXssrLp877sqpNLeXloXBmAlT39SwQTP9ImZaV5R6udqlvo
78
- Gfgm5PH/WeK6MV3n5ik0v1rS0LwR2o82WlIB6a4iSEbzY3qSLsWOwt8o5QjAVzCR
79
- tNdbdS3U8nrG73iA2clmF57ARQWC
80
- -----END CERTIFICATE-----
81
- CERT
82
- end
59
+ let(:download_cert_url) { "https://testingchef.blob.core.windows.net/files/test.cer" }
83
60
  let(:cert_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.cer") }
84
61
  let(:pfx_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.pfx") }
85
62
  let(:key_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.key") }
86
- let(:download_cert_url) { "https://testingchef.blob.core.windows.net/files/test.cer" }
87
63
  let(:cer_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "test.cer") }
88
64
  let(:base64_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "base64_test.cer") }
89
65
  let(:pem_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "test.pem") }
@@ -152,7 +128,6 @@ tNdbdS3U8nrG73iA2clmF57ARQWC
152
128
  end
153
129
 
154
130
  it "can add a certificate from a valid url" do
155
- stub_request(:get, download_cert_url).to_return(body: test_cert_body)
156
131
  resource.source = download_cert_url
157
132
  resource.run_action(:create)
158
133
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  require "spec_helper"
20
20
 
21
- describe Chef::Resource::WindowsFont, :windows_only, :broken do # these tests hang on Chef-16 and Chef-17 in the verify-pipline.
21
+ describe Chef::Resource::WindowsFont, :windows_only do
22
22
  let(:resource_name) { "Playmaker.ttf" }
23
23
  let(:resource_source) { "https://www.wfonts.com/download/data/2020/05/06/playmaker/Playmaker.ttf" }
24
24
 
@@ -37,13 +37,16 @@ describe Chef::Resource::WindowsFont, :windows_only, :broken do # these tests ha
37
37
  resource
38
38
  end
39
39
 
40
- it "installs font on first install" do
41
- subject.run_action(:install)
42
- expect(subject).to be_updated_by_last_action
43
- end
40
+ ## these were commented out because testing hangs in the verify pipeline with them enabled. WEIRD
41
+ ## that needs to be addressed
44
42
 
45
- it "does not install font when already installed" do
46
- subject.run_action(:install)
47
- expect(subject).not_to be_updated_by_last_action
48
- end
43
+ # it "installs font on first install" do
44
+ # subject.run_action(:install)
45
+ # expect(subject).to be_updated_by_last_action
46
+ # end
47
+
48
+ # it "does not install font when already installed" do
49
+ # subject.run_action(:install)
50
+ # expect(subject).not_to be_updated_by_last_action
51
+ # end
49
52
  end
@@ -20,7 +20,7 @@ require "chef/mixin/shell_out"
20
20
 
21
21
  # run this test only for following platforms.
22
22
  exclude_test = !(%w{rhel fedora amazon}.include?(OHAI_SYSTEM[:platform_family]) && !File.exist?("/usr/bin/dnf"))
23
- describe Chef::Resource::YumPackage, :requires_root, external: exclude_test, not_rhel6: true do
23
+ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
24
24
  include RecipeDSLHelper
25
25
  include Chef::Mixin::ShellOut
26
26
 
@@ -57,12 +57,6 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test, not
57
57
  baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo
58
58
  enable=1
59
59
  gpgcheck=0
60
- [chef-yum-empty]
61
- name=Chef DNF spec empty repo
62
- baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo-empty
63
- enable=1
64
- gpgcheck=0
65
-
66
60
  EOF
67
61
  end
68
62
  # ensure we don't have any stray chef_rpms installed
@@ -1101,16 +1095,6 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test, not
1101
1095
  end.should_not_be_updated
1102
1096
  end
1103
1097
 
1104
- it "should work to disable a repo" do
1105
- flush_cache
1106
- expect {
1107
- yum_package "chef_rpm" do
1108
- options "--disablerepo=chef-yum-localtesting --enablerepo=chef-yum-empty"
1109
- action :install
1110
- end
1111
- }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
1112
- end
1113
-
1114
1098
  it "when an idempotent install action is run, does not leave repos disabled" do
1115
1099
  flush_cache
1116
1100
  # this is a bit tricky -- we need this action to be idempotent, so that it doesn't recycle any
@@ -74,6 +74,18 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
74
74
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
75
75
  end
76
76
 
77
+ it "install package with source argument" do
78
+ zypper_package.source = "#{CHEF_SPEC_ASSETS}/zypprepo/chef_rpm-1.10-1.#{pkg_arch}.rpm"
79
+ zypper_package.run_action(:install)
80
+ expect(zypper_package.updated_by_last_action?).to be true
81
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
82
+ end
83
+
84
+ it "raises an error when passed a source that does not exist" do
85
+ zypper_package.source = "#{CHEF_SPEC_ASSETS}/false/zypprepo/chef_rpm-1.10-1.#{pkg_arch}.rpm"
86
+ expect { zypper_package.run_action(:install) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
87
+ end
88
+
77
89
  it "does not install if the package is installed" do
78
90
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
79
91
  zypper_package.run_action(:install)
@@ -177,15 +189,6 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
177
189
  expect(zypper_package.updated_by_last_action?).to be true
178
190
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
179
191
  end
180
-
181
- context "Package doesn't exist" do
182
- let(:package_name) { "nonexistent_repo" }
183
- it "does nothing if the package is not installed" do
184
- zypper_package.run_action(:remove)
185
- expect(zypper_package.updated_by_last_action?).to be false
186
- end
187
-
188
- end
189
192
  end
190
193
 
191
194
  context "with no available version" do
@@ -256,7 +259,6 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
256
259
  expect(shell_out("zypper locks | grep chef_rpm_provides").stdout.chomp).not_to match("chef_rpm_provides")
257
260
  end
258
261
  end
259
-
260
262
  def remove_package
261
263
  pkg_to_remove = Chef::Resource::ZypperPackage.new(package_name, run_context)
262
264
  pkg_to_remove.run_action(:remove)
@@ -78,7 +78,6 @@ describe Shell do
78
78
  def run_chef_shell_with(options)
79
79
  # Windows ruby installs don't (always?) have PTY,
80
80
  # so hide the require here
81
-
82
81
  require "pty"
83
82
 
84
83
  # FIXME this is temporary... Solaris envs have TERM set to unknown
@@ -87,7 +86,7 @@ describe Shell do
87
86
  ENV["TERM"] = "vt100" if ["", "unknown"].include?(ENV["TERM"].to_s)
88
87
 
89
88
  config = File.expand_path("shef-config.rb", CHEF_SPEC_DATA)
90
- reader, writer, pid = PTY.spawn("bundle exec chef-shell --no-multiline --no-singleline --no-colorize -c #{config} #{options}")
89
+ reader, writer, pid = PTY.spawn("bundle exec #{ChefUtils::Dist::Infra::SHELL} --no-multiline --no-singleline --no-colorize -c #{config} #{options}")
91
90
  read_until(reader, "chef (#{Chef::VERSION})>")
92
91
  yield reader, writer if block_given?
93
92
  writer.puts('"done"')
@@ -25,7 +25,7 @@ describe "Chef Versions", :executables do
25
25
  include Chef::Mixin::ShellOut
26
26
  let(:chef_dir) { File.join(__dir__, "..", "..") }
27
27
 
28
- binaries = [ ChefUtils::Dist::Infra::CLIENT, "chef-shell", "chef-apply", ChefUtils::Dist::Solo::EXEC ]
28
+ binaries = [ ChefUtils::Dist::Infra::CLIENT, ChefUtils::Dist::Infra::SHELL, "chef-apply", ChefUtils::Dist::Solo::EXEC ]
29
29
 
30
30
  binaries.each do |binary|
31
31
  it "#{binary} version should be sane" do
@@ -395,9 +395,6 @@ describe "Chef::Win32::Registry", :windows_only do
395
395
  expect { @registry.get_subkeys("JKLM\\Software\\Root") }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
396
396
  end
397
397
  it "returns the array of subkeys for a given key" do
398
- ::Win32::Registry.define_method :export_string do |str, enc = (Encoding.default_internal || "utf-8")|
399
- str.encode(enc)
400
- end
401
398
  subkeys = @registry.get_subkeys("HKCU\\Software\\Root")
402
399
  reg_subkeys = []
403
400
  ::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root", Win32::Registry::KEY_ALL_ACCESS) do |reg|