chef 17.10.163 → 18.0.185

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) 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 +16 -14
  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/homebrew_user.rb +5 -15
  22. data/lib/chef/mixin/openssl_helper.rb +13 -17
  23. data/lib/chef/mixin/powershell_exec.rb +5 -28
  24. data/lib/chef/node/mixin/immutablize_array.rb +1 -0
  25. data/lib/chef/property.rb +5 -3
  26. data/lib/chef/provider/group/windows.rb +1 -1
  27. data/lib/chef/provider/http_request.rb +11 -9
  28. data/lib/chef/provider/mount/linux.rb +5 -0
  29. data/lib/chef/provider/mount/mount.rb +8 -0
  30. data/lib/chef/provider/mount/windows.rb +1 -1
  31. data/lib/chef/provider/package/chocolatey.rb +1 -14
  32. data/lib/chef/provider/package/rubygems.rb +1 -1
  33. data/lib/chef/provider/package/snap.rb +1 -1
  34. data/lib/chef/provider/package/windows/msi.rb +2 -2
  35. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
  36. data/lib/chef/provider/package/yum/yum_helper.py +14 -2
  37. data/lib/chef/provider/package/zypper/version.rb +60 -0
  38. data/lib/chef/provider/package/zypper.rb +47 -8
  39. data/lib/chef/provider/service/windows.rb +1 -1
  40. data/lib/chef/provider/user/aix.rb +5 -0
  41. data/lib/chef/provider/user/linux.rb +29 -0
  42. data/lib/chef/provider/user/mac.rb +1 -1
  43. data/lib/chef/provider/user.rb +46 -14
  44. data/lib/chef/provider.rb +1 -1
  45. data/lib/chef/recipe.rb +1 -1
  46. data/lib/chef/resource/_rest_resource.rb +389 -0
  47. data/lib/chef/resource/alternatives.rb +0 -1
  48. data/lib/chef/resource/apt_package.rb +2 -1
  49. data/lib/chef/resource/apt_preference.rb +0 -1
  50. data/lib/chef/resource/apt_repository.rb +0 -1
  51. data/lib/chef/resource/apt_update.rb +0 -1
  52. data/lib/chef/resource/archive_file.rb +0 -1
  53. data/lib/chef/resource/bash.rb +0 -1
  54. data/lib/chef/resource/batch.rb +0 -1
  55. data/lib/chef/resource/bff_package.rb +0 -1
  56. data/lib/chef/resource/breakpoint.rb +0 -1
  57. data/lib/chef/resource/build_essential.rb +0 -1
  58. data/lib/chef/resource/cab_package.rb +0 -1
  59. data/lib/chef/resource/chef_client_config.rb +14 -18
  60. data/lib/chef/resource/chef_client_cron.rb +1 -2
  61. data/lib/chef/resource/chef_client_launchd.rb +2 -2
  62. data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
  63. data/lib/chef/resource/chef_client_systemd_timer.rb +1 -2
  64. data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
  65. data/lib/chef/resource/chef_gem.rb +0 -1
  66. data/lib/chef/resource/chef_handler.rb +0 -1
  67. data/lib/chef/resource/chef_sleep.rb +1 -3
  68. data/lib/chef/resource/chef_vault_secret.rb +0 -1
  69. data/lib/chef/resource/chocolatey_config.rb +0 -1
  70. data/lib/chef/resource/chocolatey_feature.rb +0 -1
  71. data/lib/chef/resource/chocolatey_package.rb +0 -1
  72. data/lib/chef/resource/chocolatey_source.rb +0 -1
  73. data/lib/chef/resource/cookbook_file.rb +0 -1
  74. data/lib/chef/resource/cron/_cron_shared.rb +0 -1
  75. data/lib/chef/resource/cron/cron.rb +0 -1
  76. data/lib/chef/resource/cron/cron_d.rb +15 -1
  77. data/lib/chef/resource/cron_access.rb +0 -1
  78. data/lib/chef/resource/csh.rb +0 -1
  79. data/lib/chef/resource/directory.rb +0 -1
  80. data/lib/chef/resource/dmg_package.rb +2 -1
  81. data/lib/chef/resource/dnf_package.rb +0 -1
  82. data/lib/chef/resource/dpkg_package.rb +0 -1
  83. data/lib/chef/resource/dsc_resource.rb +0 -1
  84. data/lib/chef/resource/dsc_script.rb +0 -1
  85. data/lib/chef/resource/execute.rb +0 -1
  86. data/lib/chef/resource/file.rb +0 -1
  87. data/lib/chef/resource/freebsd_package.rb +2 -1
  88. data/lib/chef/resource/gem_package.rb +2 -1
  89. data/lib/chef/resource/group.rb +25 -2
  90. data/lib/chef/resource/habitat/habitat_package.rb +0 -1
  91. data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
  92. data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
  93. data/lib/chef/resource/habitat_config.rb +0 -1
  94. data/lib/chef/resource/habitat_install.rb +0 -1
  95. data/lib/chef/resource/habitat_service.rb +0 -1
  96. data/lib/chef/resource/habitat_user_toml.rb +0 -1
  97. data/lib/chef/resource/homebrew_cask.rb +8 -8
  98. data/lib/chef/resource/homebrew_package.rb +3 -2
  99. data/lib/chef/resource/homebrew_tap.rb +5 -6
  100. data/lib/chef/resource/homebrew_update.rb +0 -2
  101. data/lib/chef/resource/hostname.rb +0 -1
  102. data/lib/chef/resource/http_request.rb +0 -1
  103. data/lib/chef/resource/ifconfig.rb +0 -1
  104. data/lib/chef/resource/inspec_input.rb +0 -1
  105. data/lib/chef/resource/inspec_waiver.rb +0 -1
  106. data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
  107. data/lib/chef/resource/ips_package.rb +0 -1
  108. data/lib/chef/resource/kernel_module.rb +0 -1
  109. data/lib/chef/resource/ksh.rb +0 -1
  110. data/lib/chef/resource/launchd.rb +0 -1
  111. data/lib/chef/resource/link.rb +0 -1
  112. data/lib/chef/resource/locale.rb +2 -6
  113. data/lib/chef/resource/log.rb +0 -1
  114. data/lib/chef/resource/lwrp_base.rb +0 -4
  115. data/lib/chef/resource/macos_userdefaults.rb +5 -10
  116. data/lib/chef/resource/macosx_service.rb +0 -1
  117. data/lib/chef/resource/macports_package.rb +2 -1
  118. data/lib/chef/resource/mdadm.rb +0 -1
  119. data/lib/chef/resource/mount.rb +0 -1
  120. data/lib/chef/resource/msu_package.rb +0 -1
  121. data/lib/chef/resource/notify_group.rb +0 -2
  122. data/lib/chef/resource/ohai.rb +0 -1
  123. data/lib/chef/resource/ohai_hint.rb +0 -1
  124. data/lib/chef/resource/openbsd_package.rb +2 -1
  125. data/lib/chef/resource/openssl_dhparam.rb +0 -2
  126. data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
  127. data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
  128. data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
  129. data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
  130. data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
  131. data/lib/chef/resource/openssl_x509_crl.rb +0 -2
  132. data/lib/chef/resource/openssl_x509_request.rb +0 -2
  133. data/lib/chef/resource/osx_profile.rb +0 -1
  134. data/lib/chef/resource/package.rb +0 -1
  135. data/lib/chef/resource/pacman_package.rb +2 -1
  136. data/lib/chef/resource/paludis_package.rb +0 -1
  137. data/lib/chef/resource/perl.rb +0 -1
  138. data/lib/chef/resource/plist.rb +7 -3
  139. data/lib/chef/resource/portage_package.rb +2 -1
  140. data/lib/chef/resource/powershell_package.rb +0 -1
  141. data/lib/chef/resource/powershell_package_source.rb +0 -1
  142. data/lib/chef/resource/powershell_script.rb +0 -1
  143. data/lib/chef/resource/python.rb +0 -1
  144. data/lib/chef/resource/reboot.rb +0 -1
  145. data/lib/chef/resource/registry_key.rb +0 -1
  146. data/lib/chef/resource/remote_directory.rb +0 -1
  147. data/lib/chef/resource/remote_file.rb +0 -1
  148. data/lib/chef/resource/rhsm_errata.rb +0 -1
  149. data/lib/chef/resource/rhsm_errata_level.rb +0 -1
  150. data/lib/chef/resource/rhsm_register.rb +0 -3
  151. data/lib/chef/resource/rhsm_repo.rb +0 -1
  152. data/lib/chef/resource/rhsm_subscription.rb +0 -1
  153. data/lib/chef/resource/route.rb +0 -1
  154. data/lib/chef/resource/rpm_package.rb +2 -1
  155. data/lib/chef/resource/ruby.rb +0 -1
  156. data/lib/chef/resource/ruby_block.rb +0 -1
  157. data/lib/chef/resource/scm/_scm.rb +0 -2
  158. data/lib/chef/resource/scm/git.rb +0 -2
  159. data/lib/chef/resource/scm/subversion.rb +0 -2
  160. data/lib/chef/resource/script.rb +0 -1
  161. data/lib/chef/resource/selinux/common_helpers.rb +47 -0
  162. data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
  163. data/lib/chef/resource/selinux/selinux_default.erb +15 -0
  164. data/lib/chef/resource/selinux_boolean.rb +101 -0
  165. data/lib/chef/resource/selinux_fcontext.rb +160 -0
  166. data/lib/chef/resource/selinux_install.rb +107 -0
  167. data/lib/chef/resource/selinux_module.rb +143 -0
  168. data/lib/chef/resource/selinux_permissive.rb +64 -0
  169. data/lib/chef/resource/selinux_port.rb +118 -0
  170. data/lib/chef/resource/selinux_state.rb +166 -0
  171. data/lib/chef/resource/service.rb +0 -1
  172. data/lib/chef/resource/smartos_package.rb +2 -1
  173. data/lib/chef/resource/snap_package.rb +2 -1
  174. data/lib/chef/resource/solaris_package.rb +2 -1
  175. data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
  176. data/lib/chef/resource/sudo.rb +0 -1
  177. data/lib/chef/resource/support/client.erb +5 -6
  178. data/lib/chef/resource/swap_file.rb +0 -1
  179. data/lib/chef/resource/sysctl.rb +1 -2
  180. data/lib/chef/resource/systemd_unit.rb +0 -1
  181. data/lib/chef/resource/template.rb +0 -1
  182. data/lib/chef/resource/timezone.rb +0 -1
  183. data/lib/chef/resource/user/aix_user.rb +0 -1
  184. data/lib/chef/resource/user/linux_user.rb +0 -1
  185. data/lib/chef/resource/user/mac_user.rb +0 -1
  186. data/lib/chef/resource/user/pw_user.rb +0 -1
  187. data/lib/chef/resource/user/solaris_user.rb +0 -1
  188. data/lib/chef/resource/user/windows_user.rb +0 -1
  189. data/lib/chef/resource/user.rb +10 -1
  190. data/lib/chef/resource/user_ulimit.rb +0 -1
  191. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
  192. data/lib/chef/resource/windows_ad_join.rb +0 -2
  193. data/lib/chef/resource/windows_audit_policy.rb +0 -2
  194. data/lib/chef/resource/windows_auto_run.rb +0 -1
  195. data/lib/chef/resource/windows_defender.rb +0 -1
  196. data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
  197. data/lib/chef/resource/windows_dfs_folder.rb +0 -1
  198. data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
  199. data/lib/chef/resource/windows_dfs_server.rb +0 -1
  200. data/lib/chef/resource/windows_dns_record.rb +0 -1
  201. data/lib/chef/resource/windows_dns_zone.rb +0 -1
  202. data/lib/chef/resource/windows_env.rb +0 -1
  203. data/lib/chef/resource/windows_feature.rb +0 -1
  204. data/lib/chef/resource/windows_feature_dism.rb +0 -1
  205. data/lib/chef/resource/windows_feature_powershell.rb +0 -1
  206. data/lib/chef/resource/windows_firewall_profile.rb +0 -2
  207. data/lib/chef/resource/windows_firewall_rule.rb +0 -1
  208. data/lib/chef/resource/windows_font.rb +2 -3
  209. data/lib/chef/resource/windows_package.rb +3 -4
  210. data/lib/chef/resource/windows_pagefile.rb +0 -2
  211. data/lib/chef/resource/windows_path.rb +0 -1
  212. data/lib/chef/resource/windows_printer.rb +0 -1
  213. data/lib/chef/resource/windows_printer_port.rb +0 -1
  214. data/lib/chef/resource/windows_script.rb +0 -2
  215. data/lib/chef/resource/windows_security_policy.rb +0 -1
  216. data/lib/chef/resource/windows_service.rb +0 -1
  217. data/lib/chef/resource/windows_share.rb +0 -1
  218. data/lib/chef/resource/windows_shortcut.rb +1 -2
  219. data/lib/chef/resource/windows_task.rb +0 -1
  220. data/lib/chef/resource/windows_uac.rb +0 -1
  221. data/lib/chef/resource/windows_update_settings.rb +0 -1
  222. data/lib/chef/resource/windows_user_privilege.rb +0 -1
  223. data/lib/chef/resource/windows_workgroup.rb +0 -1
  224. data/lib/chef/resource/yum_package.rb +2 -1
  225. data/lib/chef/resource/yum_repository.rb +0 -1
  226. data/lib/chef/resource/zypper_package.rb +2 -1
  227. data/lib/chef/resource/zypper_repository.rb +0 -1
  228. data/lib/chef/resource.rb +12 -5
  229. data/lib/chef/resources.rb +7 -0
  230. data/lib/chef/run_context.rb +3 -3
  231. data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
  232. data/lib/chef/version.rb +1 -1
  233. data/lib/chef/win32/handle.rb +6 -7
  234. data/lib/chef/win32/registry.rb +7 -3
  235. data/spec/data/rubygems.org/sexp_processor-info +2 -1
  236. data/spec/data/trusted_certs/example.crt +20 -29
  237. data/spec/data/trusted_certs/example_no_cn.crt +34 -30
  238. data/spec/data/trusted_certs/opscode.pem +54 -33
  239. data/spec/functional/resource/chocolatey_package_spec.rb +20 -32
  240. data/spec/functional/resource/dsc_script_spec.rb +1 -1
  241. data/spec/functional/resource/group_spec.rb +26 -42
  242. data/spec/functional/resource/link_spec.rb +8 -8
  243. data/spec/functional/resource/macos_userdefaults_spec.rb +4 -4
  244. data/spec/functional/resource/plist_spec.rb +25 -0
  245. data/spec/functional/resource/user/linux_user_spec.rb +127 -0
  246. data/spec/functional/resource/windows_certificate_spec.rb +1 -26
  247. data/spec/functional/resource/windows_font_spec.rb +12 -9
  248. data/spec/functional/resource/yum_package_spec.rb +1 -17
  249. data/spec/functional/resource/zypper_package_spec.rb +12 -10
  250. data/spec/functional/shell_spec.rb +1 -2
  251. data/spec/functional/version_spec.rb +1 -1
  252. data/spec/functional/win32/registry_spec.rb +0 -3
  253. data/spec/integration/client/client_spec.rb +82 -3
  254. data/spec/integration/client/exit_code_spec.rb +1 -1
  255. data/spec/integration/client/ipv6_spec.rb +1 -1
  256. data/spec/integration/compliance/compliance_spec.rb +1 -1
  257. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  258. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  259. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  260. data/spec/integration/recipes/notifies_spec.rb +1 -1
  261. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  262. data/spec/integration/recipes/remote_directory.rb +1 -1
  263. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  264. data/spec/integration/recipes/use_partial_spec.rb +2 -1
  265. data/spec/integration/solo/solo_spec.rb +2 -2
  266. data/spec/spec_helper.rb +1 -5
  267. data/spec/support/platform_helpers.rb +0 -4
  268. data/spec/support/ruby_installer.rb +1 -1
  269. data/spec/support/shared/functional/windows_script.rb +2 -2
  270. data/spec/unit/application/client_spec.rb +0 -10
  271. data/spec/unit/client_spec.rb +70 -2
  272. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
  273. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  274. data/spec/unit/http/authenticator_spec.rb +68 -0
  275. data/spec/unit/mixin/homebrew_user_spec.rb +7 -30
  276. data/spec/unit/mixin/openssl_helper_spec.rb +1 -1
  277. data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
  278. data/spec/unit/platform/query_helpers_spec.rb +2 -17
  279. data/spec/unit/provider/cron_spec.rb +2 -0
  280. data/spec/unit/provider/http_request_spec.rb +60 -72
  281. data/spec/unit/provider/mount/linux_spec.rb +10 -0
  282. data/spec/unit/provider/package/chocolatey_spec.rb +3 -20
  283. data/spec/unit/provider/package/rubygems_spec.rb +1 -1
  284. data/spec/unit/provider/package/zypper_spec.rb +32 -0
  285. data/spec/unit/provider/user/linux_spec.rb +51 -11
  286. data/spec/unit/provider/user_spec.rb +24 -6
  287. data/spec/unit/resource/archive_file_spec.rb +1 -1
  288. data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
  289. data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
  290. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
  291. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +2 -2
  292. data/spec/unit/resource/cron_d_spec.rb +37 -1
  293. data/spec/unit/resource/macos_user_defaults_spec.rb +4 -4
  294. data/spec/unit/resource/rest_resource_spec.rb +381 -0
  295. data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
  296. data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
  297. data/spec/unit/resource/selinux_install_spec.rb +60 -0
  298. data/spec/unit/resource/selinux_module_spec.rb +55 -0
  299. data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
  300. data/spec/unit/resource/selinux_port_spec.rb +42 -0
  301. data/spec/unit/resource/selinux_state_spec.rb +46 -0
  302. data/spec/unit/resource/sysctl_spec.rb +2 -2
  303. data/spec/unit/resource/user/linux_user_spec.rb +42 -0
  304. data/spec/unit/resource_spec.rb +8 -2
  305. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
  306. data/tasks/rspec.rb +1 -1
  307. metadata +100 -55
  308. data/spec/functional/assets/yumrepo-empty/repodata/01a3b-filelists.sqlite.bz2 +0 -0
  309. data/spec/functional/assets/yumrepo-empty/repodata/401dc-filelists.xml.gz +0 -0
  310. data/spec/functional/assets/yumrepo-empty/repodata/5dc1e-primary.sqlite.bz2 +0 -0
  311. data/spec/functional/assets/yumrepo-empty/repodata/6bf96-other.xml.gz +0 -0
  312. data/spec/functional/assets/yumrepo-empty/repodata/7c365-other.sqlite.bz2 +0 -0
  313. data/spec/functional/assets/yumrepo-empty/repodata/dabe2-primary.xml.gz +0 -0
  314. data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +0 -55
  315. data/spec/integration/client/fips_spec.rb +0 -29
  316. data/spec/integration/client/open_ssl_spec.rb +0 -20
  317. /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.0.nupkg → test-A.1.0.nupkg} +0 -0
  318. /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.0.nupkg → test-A.1.5.nupkg} +0 -0
  319. /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.0.nupkg → test-A.2.0.nupkg} +0 -0
  320. /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.0.nupkg → test-B.1.0.nupkg} +0 -0
  321. /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
  322. /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
  323. /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
  324. /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
  325. /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
  326. /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
@@ -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|
@@ -4,6 +4,10 @@ require "chef/mixin/shell_out"
4
4
  require "tiny_server"
5
5
  require "tmpdir"
6
6
  require "chef-utils/dist"
7
+ require "chef/mixin/powershell_exec"
8
+
9
+ # cspell:disable-next-line
10
+ SOME_CHARS = "~!@#%^&*_-+=`|\\(){}[<]:;'>,.?/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".each_char.to_a.freeze
7
11
 
8
12
  describe "chef-client" do
9
13
 
@@ -31,8 +35,56 @@ describe "chef-client" do
31
35
  @server = @api = nil
32
36
  end
33
37
 
38
+ def install_certificate_in_store(client_name)
39
+ if ChefUtils.windows?
40
+ powershell_exec! <<~EOH
41
+ if (-not (($PSVersionTable.PSVersion.Major -ge 5) -and ($PSVersionTable.PSVersion.Build -ge 22000)) ) {
42
+ New-SelfSignedCertificate -CertStoreLocation Cert:\\LocalMachine\\My -DnsName "#{client_name}"
43
+ }
44
+ else {
45
+ New-SelfSignedCertificate -CertStoreLocation Cert:\\LocalMachine\\My -Subject "#{client_name}" -FriendlyName "#{client_name}" -KeyExportPolicy Exportable
46
+ }
47
+ EOH
48
+ end
49
+ end
50
+
51
+ def create_registry_key
52
+ ::Chef::HTTP::Authenticator.get_cert_password
53
+ # @win32registry = Chef::Win32::Registry.new
54
+ # path = "HKEY_LOCAL_MACHINE\\Software\\Progress\\Authentication"
55
+ # unless @win32registry.key_exists?(path)
56
+ # @win32registry.create_key(path, true)
57
+ # end
58
+ # password = SOME_CHARS.sample(1 + rand(SOME_CHARS.count)).join[0...14]
59
+ # values = { name: "PfxPass", type: :string, data: password }
60
+ # @win32registry.set_value(path, values)
61
+ end
62
+
63
+ def remove_certificate_from_store
64
+ powershell_exec! <<~EOH
65
+ Get-ChildItem -path cert:\\LocalMachine\\My -Recurse -Force | Where-Object { $_.Subject -Match "#{client_name}" } -ErrorAction Stop | Remove-Item
66
+ EOH
67
+ end
68
+
69
+ def remove_registry_key
70
+ powershell_exec!("Remove-ItemProperty -Path HKLM:\\SOFTWARE\\Progress\\Authentication -Name 'PfxPass' ")
71
+ end
72
+
73
+ def verify_export_password_exists
74
+ powershell_exec! <<~EOH
75
+ Try {
76
+ $response = Get-ItemProperty -Path "HKLM:\\Software\\Progress\\Authentication" -Name "PfxPass" -ErrorAction Stop
77
+ if ($response) {return $true}
78
+ }
79
+ Catch {
80
+ return $false
81
+ }
82
+ EOH
83
+ end
84
+
34
85
  include IntegrationSupport
35
86
  include Chef::Mixin::ShellOut
87
+ include Chef::Mixin::PowershellExec
36
88
 
37
89
  let(:chef_dir) { File.join(__dir__, "..", "..", "..") }
38
90
 
@@ -45,8 +97,10 @@ describe "chef-client" do
45
97
  # machine that has omnibus chef installed. In that case we need to ensure
46
98
  # we're running `chef-client` from the source tree and not the external one.
47
99
  # cf. CHEF-4914
48
- let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai" }
49
- let(:chef_solo) { "bundle exec #{ChefUtils::Dist::Solo::EXEC} --legacy-mode --minimal-ohai" }
100
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai --always-dump-stacktrace" }
101
+ let(:chef_solo) { "bundle exec #{ChefUtils::Dist::Solo::EXEC} --legacy-mode --minimal-ohai --always-dump-stacktrace" }
102
+ let(:client_name) { "chef-973334" }
103
+ let(:hostname) { "973334" }
50
104
 
51
105
  context "when validation.pem in current Directory" do
52
106
  let(:validation_path) { "" }
@@ -133,7 +187,6 @@ describe "chef-client" do
133
187
  # FATAL: Configuration error NoMethodError: undefined method `xxx' for nil:NilClass
134
188
  expect(result.stdout).to include("xxx")
135
189
  end
136
-
137
190
  end
138
191
 
139
192
  it "should complete with success" do
@@ -146,6 +199,32 @@ describe "chef-client" do
146
199
  result.error!
147
200
  end
148
201
 
202
+ if ChefUtils.windows?
203
+ context "and the private key is in the Windows CertStore" do
204
+ before do
205
+ install_certificate_in_store(client_name)
206
+ create_registry_key
207
+ end
208
+
209
+ after do
210
+ remove_certificate_from_store
211
+ remove_registry_key
212
+ end
213
+
214
+ it "should verify that the cert is loaded in the LocalMachine\\My" do
215
+ expect(Chef::HTTP::Authenticator.check_certstore_for_key(hostname)).to eq(true)
216
+ end
217
+
218
+ it "should verify that the export password for the pfx is loaded in the Registry" do
219
+ expect(verify_export_password_exists.result).to eq(true)
220
+ end
221
+
222
+ it "should verify that a private key is returned to me" do
223
+ expect(Chef::HTTP::Authenticator.retrieve_certificate_key(client_name)).not_to be nil
224
+ end
225
+ end
226
+ end
227
+
149
228
  context "and a private key" do
150
229
  before do
151
230
  file "mykey.pem", <<~EOM
@@ -23,7 +23,7 @@ describe "chef-client" do
23
23
  # machine that has omnibus chef installed. In that case we need to ensure
24
24
  # we're running `chef-client` from the source tree and not the external one.
25
25
  # cf. CHEF-4914
26
- let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --no-fork --minimal-ohai" }
26
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --no-fork --minimal-ohai --always-dump-stacktrace" }
27
27
 
28
28
  let(:critical_env_vars) { %w{PATH RUBYOPT BUNDLE_GEMFILE GEM_PATH}.map { |o| "#{o}=#{ENV[o]}" } .join(" ") }
29
29
 
@@ -76,7 +76,7 @@ describe "chef-client" do
76
76
 
77
77
  let(:chef_dir) { File.join(__dir__, "..", "..", "..") }
78
78
 
79
- let(:chef_client_cmd) { %Q{bundle exec chef-client --minimal-ohai -c "#{path_to("config/client.rb")}" -lwarn} }
79
+ let(:chef_client_cmd) { %Q{bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai -c "#{path_to("config/client.rb")}" -lwarn --always-dump-stacktrace} }
80
80
 
81
81
  after do
82
82
  FileUtils.rm_rf(cache_path)
@@ -20,7 +20,7 @@ describe "chef-client with compliance phase" do
20
20
  # machine that has omnibus chef installed. In that case we need to ensure
21
21
  # we're running `chef-client` from the source tree and not the external one.
22
22
  # cf. CHEF-4914
23
- let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai" }
23
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai --always-dump-stacktrace" }
24
24
 
25
25
  when_the_repository "has a custom profile" do
26
26
  let(:report_file) { path_to("report_file.json") }
@@ -17,7 +17,7 @@ describe "Accumulators" do
17
17
  # machine that has omnibus chef installed. In that case we need to ensure
18
18
  # we're running `chef-client` from the source tree and not the external one.
19
19
  # cf. CHEF-4914
20
- let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
20
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai --always-dump-stacktrace" }
21
21
 
22
22
  let(:aliases_temppath) do
23
23
  t = Tempfile.new("chef_accumulator_test")
@@ -17,7 +17,7 @@ describe "LWRPs with inline resources" do
17
17
  # machine that has omnibus chef installed. In that case we need to ensure
18
18
  # we're running `chef-client` from the source tree and not the external one.
19
19
  # cf. CHEF-4914
20
- let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
20
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai --always-dump-stacktrace" }
21
21
 
22
22
  context "with a use_inline_resources provider with 'def action_a' instead of action :a" do
23
23
  class LwrpInlineResourcesTest < Chef::Resource
@@ -17,7 +17,7 @@ describe "LWRPs" do
17
17
  # machine that has omnibus chef installed. In that case we need to ensure
18
18
  # we're running `chef-client` from the source tree and not the external one.
19
19
  # cf. CHEF-4914
20
- let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
20
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai --always-dump-stacktrace" }
21
21
 
22
22
  when_the_repository "has a cookbook named l-w-r-p" do
23
23
  before do
@@ -23,7 +23,7 @@ describe "notifications" do
23
23
  include Chef::Mixin::ShellOut
24
24
 
25
25
  let(:chef_dir) { File.expand_path("../../..", __dir__) }
26
- let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
26
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai --always-dump-stacktrace" }
27
27
 
28
28
  when_the_repository "notifies a nameless resource" do
29
29
  before do
@@ -24,7 +24,7 @@ describe "notifying_block" do
24
24
  include Chef::Mixin::ShellOut
25
25
 
26
26
  let(:chef_dir) { File.expand_path("../../..", __dir__) }
27
- let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
27
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai --always-dump-stacktrace" }
28
28
 
29
29
  when_the_repository "notifying_block test one" do
30
30
  before do
@@ -16,7 +16,7 @@ describe Chef::Resource::RemoteDirectory do
16
16
  # machine that has omnibus chef installed. In that case we need to ensure
17
17
  # we're running `chef-client` from the source tree and not the external one.
18
18
  # cf. CHEF-4914
19
- let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
19
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai --always-dump-stacktrace" }
20
20
 
21
21
  when_the_repository "has a cookbook with a source_dir with two subdirectories, each with one file and subdir in a different alphabetical order" do
22
22
  before do
@@ -8,7 +8,7 @@ describe "Unified Mode" do
8
8
 
9
9
  let(:chef_dir) { File.expand_path("../../..", __dir__) }
10
10
 
11
- let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
11
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai --always-dump-stacktrace" }
12
12
 
13
13
  when_the_repository "has a cookbook with a unified_mode resource with a delayed notification from the second block to the first block" do
14
14
  before do
@@ -23,10 +23,11 @@ describe "notifying_block" do
23
23
  include Chef::Mixin::ShellOut
24
24
 
25
25
  let(:chef_dir) { File.expand_path("../../..", __dir__) }
26
- let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
26
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai --always-dump-stacktrace" }
27
27
 
28
28
  when_the_repository "has a cookbook with partial resources" do
29
29
  before do
30
+ ::Chef::HTTP::Authenticator.get_cert_password if windows?
30
31
  directory "cookbooks/x" do
31
32
  file "resources/_shared_properties.rb", <<-EOM
32
33
  property :content, String
@@ -18,7 +18,7 @@ describe ChefUtils::Dist::Solo::EXEC do
18
18
 
19
19
  let(:cookbook_ancient_100_metadata_rb) { cb_metadata("ancient", "1.0.0") }
20
20
 
21
- let(:chef_solo) { "bundle exec #{ChefUtils::Dist::Solo::EXEC} --legacy-mode --minimal-ohai" }
21
+ let(:chef_solo) { "bundle exec #{ChefUtils::Dist::Solo::EXEC} --legacy-mode --minimal-ohai --always-dump-stacktrace" }
22
22
 
23
23
  when_the_repository "creates nodes" do
24
24
  let(:nodes_dir) { File.join(@repository_dir, "nodes") }
@@ -28,7 +28,7 @@ describe ChefUtils::Dist::Solo::EXEC do
28
28
  file "config/solo.rb", <<~EOM
29
29
  chef_repo_path "#{@repository_dir}"
30
30
  EOM
31
- result = shell_out("bundle exec chef-solo -c \"#{path_to("config/solo.rb")}\" -l debug", cwd: chef_dir)
31
+ result = shell_out("bundle exec #{ChefUtils::Dist::Solo::EXEC} --minimal-ohai --always-dump-stacktrace -c \"#{path_to("config/solo.rb")}\" -l debug", cwd: chef_dir)
32
32
  result.error!
33
33
  end
34
34
 
data/spec/spec_helper.rb CHANGED
@@ -138,15 +138,13 @@ RSpec.configure do |config|
138
138
 
139
139
  config.filter_run_excluding skip_buildkite: true if ENV["BUILDKITE"]
140
140
 
141
- config.filter_run_excluding fips_mode: !fips_mode_build?
142
-
143
- config.filter_run_excluding not_supported_on_freebsd_gte_12_3: true if freebsd_gte_12_3?
144
141
  config.filter_run_excluding windows_only: true unless windows?
145
142
  config.filter_run_excluding not_supported_on_windows: true if windows?
146
143
  config.filter_run_excluding not_supported_on_macos: true if macos?
147
144
  config.filter_run_excluding macos_only: true unless macos?
148
145
  config.filter_run_excluding not_macos_gte_11: true if macos_gte_11?
149
146
  config.filter_run_excluding not_supported_on_aix: true if aix?
147
+ config.filter_run_excluding not_supported_on_freebsd_gte_12_3: true if freebsd_gte_12_3?
150
148
  config.filter_run_excluding not_supported_on_solaris: true if solaris?
151
149
  config.filter_run_excluding not_supported_on_gce: true if gce?
152
150
  config.filter_run_excluding win2012r2_only: true unless windows_2012r2?
@@ -166,8 +164,6 @@ RSpec.configure do |config|
166
164
  config.filter_run_excluding linux_only: true unless linux?
167
165
  config.filter_run_excluding aix_only: true unless aix?
168
166
  config.filter_run_excluding suse_only: true unless suse?
169
- # These aren't valid on verify pipeline because the docker container brings its own OpenSSL
170
- config.filter_run_excluding openssl_version_check: true if ENV["BUILDKITE_PIPELINE_SLUG"] =~ /verify/
171
167
  config.filter_run_excluding opensuse: true unless opensuse?
172
168
  config.filter_run_excluding debian_family_only: true unless debian_family?
173
169
  config.filter_run_excluding supports_cloexec: true unless supports_cloexec?
@@ -223,10 +223,6 @@ def aes_256_gcm?
223
223
  OpenSSL::Cipher.ciphers.include?("aes-256-gcm")
224
224
  end
225
225
 
226
- def fips_mode_build?
227
- OpenSSL::OPENSSL_FIPS
228
- end
229
-
230
226
  def fips?
231
227
  ENV["CHEF_FIPS"] == "1"
232
228
  end
@@ -48,4 +48,4 @@ rescue LoadError
48
48
  $stderr.puts "Failed to load ruby_installer. Assuming Ruby Installer is not being used."
49
49
  end
50
50
 
51
- add_libarchive_dll_directory if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
51
+ add_libarchive_dll_directory if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
@@ -163,7 +163,7 @@ shared_context Chef::Resource::WindowsScript do
163
163
 
164
164
  describe "when the run action is invoked on Windows" do
165
165
  it "executes the script code" do
166
- resource.code("whoami > \"#{script_output_path}\"")
166
+ resource.code("chcp > \"#{script_output_path}\"")
167
167
  resource.returns(0)
168
168
  resource.run_action(:run)
169
169
  end
@@ -199,7 +199,7 @@ shared_context Chef::Resource::WindowsScript do
199
199
  end
200
200
 
201
201
  it "executes the script code" do
202
- resource.code("whoami > \"#{script_output_path}\"")
202
+ resource.code("chcp > \"#{script_output_path}\"")
203
203
  resource.returns(0)
204
204
  resource.run_action(:run)
205
205
  end
@@ -564,16 +564,6 @@ describe Chef::Application::Client, "run_application", :unix_only do
564
564
  expect(IO.select([@pipe[0]], nil, nil, 0)).not_to be_nil
565
565
  expect(@pipe[0].gets).to eq("finished\n")
566
566
  end
567
-
568
- it "should exit hard when sent before converge" do
569
- pid = fork do
570
- sleep 3
571
- @app.run_application
572
- end
573
- Process.kill("TERM", pid)
574
- _pid, result = Process.waitpid2(pid)
575
- expect(result.exitstatus).to eq(3)
576
- end
577
567
  end
578
568
  end
579
569
 
@@ -23,6 +23,11 @@ require "chef/run_context"
23
23
  require "chef/server_api"
24
24
  require "rbconfig"
25
25
 
26
+ begin
27
+ require "chef-powershell"
28
+ rescue LoadError
29
+ end
30
+
26
31
  class FooError < RuntimeError
27
32
  end
28
33
 
@@ -113,6 +118,7 @@ shared_context "a client run" do
113
118
  # --Client.register
114
119
  # Make sure Client#register thinks the client key doesn't
115
120
  # exist, so it tries to register and create one.
121
+ allow(Chef::HTTP::Authenticator).to receive(:detect_certificate_key).with(fqdn).and_return(false)
116
122
  allow(File).to receive(:exists?).and_call_original
117
123
  expect(File).to receive(:exists?)
118
124
  .with(Chef::Config[:client_key])
@@ -201,7 +207,6 @@ shared_context "a client run" do
201
207
 
202
208
  # Post conditions: check that node has been filled in correctly
203
209
  expect(client).to receive(:run_started)
204
-
205
210
  stub_for_run
206
211
  end
207
212
  end
@@ -262,7 +267,7 @@ end
262
267
 
263
268
  # requires platform and platform_version be defined
264
269
  shared_examples "a completed run" do
265
- include_context "run completed"
270
+ include_context "run completed" # should receive run_completed_successfully
266
271
 
267
272
  it "runs ohai, sets up authentication, loads node state, synchronizes policy, converges" do
268
273
  # This is what we're testing.
@@ -282,6 +287,53 @@ shared_examples "a failed run" do
282
287
  end
283
288
  end
284
289
 
290
+ describe Chef::Client, :windows_only do
291
+ let(:hostname) { "test" }
292
+ let(:my_client) { Chef::Client.new }
293
+ let(:cert_name) { "chef-#{hostname}" }
294
+ let(:node_name) { "#{hostname}" }
295
+ let(:end_date) do
296
+ d = Time.now
297
+ if d.month == 10 || d.month == 11 || d.month == 12
298
+ end_date = Time.new(d.year + 1, d.month - 9, d.day, d.hour, d.min, d.sec).utc.iso8601
299
+ else
300
+ end_date = Time.new(d.year, d.month + 3, d.day, d.hour, d.min, d.sec).utc.iso8601
301
+ end
302
+ end
303
+ # include_context "client"
304
+ before(:each) do
305
+ Chef::Config[:migrate_key_to_keystore] = true
306
+ end
307
+
308
+ after(:each) do
309
+ delete_certificate(cert_name)
310
+ end
311
+
312
+ context "when the client intially boots the first time" do
313
+ it "verfies that a certificate was correctly created and exists in the Cert Store" do
314
+ new_pfx = my_client.generate_pfx_package(cert_name, end_date)
315
+ my_client.import_pfx_to_store(new_pfx)
316
+ expect(my_client.check_certstore_for_key(cert_name)).not_to be false
317
+ end
318
+
319
+ it "correctly returns a new Publc Key" do
320
+ new_pfx = my_client.generate_pfx_package(cert_name, end_date)
321
+ cert_object = new_pfx.certificate.public_key.to_pem
322
+ expect(cert_object.to_s).to match(/PUBLIC KEY/)
323
+ end
324
+
325
+ end
326
+
327
+ def delete_certificate(cert_name)
328
+ require "chef/mixin/powershell_exec"
329
+ extend Chef::Mixin::PowershellExec
330
+ powershell_code = <<~CODE
331
+ Get-ChildItem -path cert:\\LocalMachine\\My -Recurse -Force | Where-Object { $_.Subject -Match "#{cert_name}" } | Remove-item
332
+ CODE
333
+ powershell_exec!(powershell_code)
334
+ end
335
+ end
336
+
285
337
  describe Chef::Client do
286
338
  include_context "client"
287
339
 
@@ -308,6 +360,22 @@ describe Chef::Client do
308
360
  end
309
361
  end
310
362
 
363
+ describe "eol release warning" do
364
+ it "warns when running an EOL release" do
365
+ stub_const("Chef::VERSION", 15)
366
+ allow(Time).to receive(:now).and_return(Time.new(2021, 5, 1, 5))
367
+ expect(logger).to receive(:warn).with(/This release of.*became end of life \(EOL\) on May 1st 2021/)
368
+ client.warn_if_eol
369
+ end
370
+
371
+ it "does not warn when running an non-EOL release" do
372
+ stub_const("Chef::VERSION", 15)
373
+ allow(Time).to receive(:now).and_return(Time.new(2021, 4, 31))
374
+ expect(logger).to_not receive(:warn).with(/became end of life/)
375
+ client.warn_if_eol
376
+ end
377
+ end
378
+
311
379
  describe "authentication protocol selection" do
312
380
  context "when FIPS is disabled" do
313
381
  before do
@@ -170,7 +170,7 @@ describe Chef::Compliance::Reporter::ChefServerAutomate do
170
170
  "X-Ops-Userid" => "spec-node",
171
171
  "X-Remote-Request-Id" => /.+/,
172
172
  }
173
- ).to_return(status: 200, body: "OK")
173
+ ).to_return(status: 200)
174
174
 
175
175
  expect(reporter.send_report(inspec_report)).to eq(true)
176
176
 
@@ -159,12 +159,15 @@ describe Chef::Cookbook::SyntaxCheck do
159
159
  end
160
160
 
161
161
  describe "and a file has a syntax error" do
162
+
162
163
  before do
163
164
  cookbook_path = File.join(CHEF_SPEC_DATA, "cookbooks", "borken")
164
165
  syntax_check.cookbook_path.replace(cookbook_path)
165
166
  end
166
167
 
167
168
  it "it indicates that a ruby file has a syntax error" do
169
+ expect(Chef::Log).to receive(:fatal).with("Cookbook file borken/recipes/default.rb has a ruby syntax error.")
170
+ allow(Chef::Log).to receive(:fatal)
168
171
  expect(syntax_check.validate_ruby_files).to be_falsey
169
172
  end
170
173