chef 17.10.163 → 18.7.10

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 (400) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +25 -21
  3. data/README.md +7 -7
  4. data/Rakefile +3 -22
  5. data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +7 -6
  6. data/chef.gemspec +33 -27
  7. data/lib/chef/api_client_v1.rb +9 -1
  8. data/lib/chef/application/base.rb +20 -2
  9. data/lib/chef/application/exit_code.rb +3 -3
  10. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  11. data/lib/chef/chef_fs/file_system.rb +21 -7
  12. data/lib/chef/chef_fs/path_utils.rb +7 -9
  13. data/lib/chef/client.rb +186 -2
  14. data/lib/chef/compliance/default_attributes.rb +2 -2
  15. data/lib/chef/compliance/input.rb +1 -1
  16. data/lib/chef/compliance/profile.rb +1 -1
  17. data/lib/chef/compliance/profile_collection.rb +0 -1
  18. data/lib/chef/compliance/runner.rb +6 -1
  19. data/lib/chef/compliance/waiver.rb +1 -1
  20. data/lib/chef/cookbook/chefignore.rb +4 -1
  21. data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
  22. data/lib/chef/cookbook/metadata.rb +1 -1
  23. data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
  24. data/lib/chef/cookbook/synchronizer.rb +21 -3
  25. data/lib/chef/cookbook/syntax_check.rb +2 -2
  26. data/lib/chef/cookbook_manifest.rb +2 -2
  27. data/lib/chef/cookbook_version.rb +1 -1
  28. data/lib/chef/data_collector.rb +14 -0
  29. data/lib/chef/delayed_evaluator.rb +4 -0
  30. data/lib/chef/dsl/reader_helpers.rb +1 -1
  31. data/lib/chef/dsl/rest_resource.rb +77 -0
  32. data/lib/chef/event_dispatch/base.rb +3 -0
  33. data/lib/chef/event_dispatch/dispatcher.rb +0 -1
  34. data/lib/chef/exceptions.rb +9 -1
  35. data/lib/chef/file_access_control/windows.rb +4 -1
  36. data/lib/chef/file_cache.rb +17 -2
  37. data/lib/chef/formatters/doc.rb +1 -1
  38. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -0
  39. data/lib/chef/http/authenticator.rb +253 -3
  40. data/lib/chef/http/ssl_policies.rb +2 -2
  41. data/lib/chef/mixin/{homebrew_user.rb → homebrew.rb} +13 -16
  42. data/lib/chef/mixin/openssl_helper.rb +1 -16
  43. data/lib/chef/mixin/powershell_exec.rb +5 -28
  44. data/lib/chef/monkey_patches/net-http.rb +127 -0
  45. data/lib/chef/node/attribute.rb +3 -11
  46. data/lib/chef/node/attribute_collections.rb +10 -1
  47. data/lib/chef/node/immutable_collections.rb +17 -6
  48. data/lib/chef/node/mixin/immutablize_array.rb +1 -0
  49. data/lib/chef/node/mixin/state_tracking.rb +7 -4
  50. data/lib/chef/node/mixin/state_tracking_array.rb +41 -0
  51. data/lib/chef/node.rb +23 -1
  52. data/lib/chef/platform/query_helpers.rb +4 -2
  53. data/lib/chef/policy_builder/policyfile.rb +8 -0
  54. data/lib/chef/property.rb +13 -6
  55. data/lib/chef/provider/group/windows.rb +1 -1
  56. data/lib/chef/provider/http_request.rb +11 -9
  57. data/lib/chef/provider/launchd.rb +2 -1
  58. data/lib/chef/provider/mount/linux.rb +6 -1
  59. data/lib/chef/provider/mount/mount.rb +13 -5
  60. data/lib/chef/provider/mount/windows.rb +1 -1
  61. data/lib/chef/provider/package/apt.rb +11 -2
  62. data/lib/chef/provider/package/chocolatey.rb +260 -22
  63. data/lib/chef/provider/package/dnf/dnf_helper.py +7 -0
  64. data/lib/chef/provider/package/homebrew.rb +6 -9
  65. data/lib/chef/provider/package/powershell.rb +1 -0
  66. data/lib/chef/provider/package/rubygems.rb +5 -1
  67. data/lib/chef/provider/package/snap.rb +3 -2
  68. data/lib/chef/provider/package/windows/msi.rb +2 -2
  69. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
  70. data/lib/chef/provider/package/yum/yum_helper.py +3 -3
  71. data/lib/chef/provider/package/zypper/version.rb +60 -0
  72. data/lib/chef/provider/package/zypper.rb +47 -3
  73. data/lib/chef/provider/powershell_script.rb +96 -6
  74. data/lib/chef/provider/registry_key.rb +2 -0
  75. data/lib/chef/provider/remote_file/http.rb +1 -1
  76. data/lib/chef/provider/service/systemd.rb +23 -8
  77. data/lib/chef/provider/service/windows.rb +1 -1
  78. data/lib/chef/provider/service.rb +14 -0
  79. data/lib/chef/provider/user/aix.rb +5 -0
  80. data/lib/chef/provider/user/linux.rb +29 -0
  81. data/lib/chef/provider/user/mac.rb +1 -1
  82. data/lib/chef/provider/user/windows.rb +5 -0
  83. data/lib/chef/provider/user.rb +45 -9
  84. data/lib/chef/provider/yum_repository.rb +13 -1
  85. data/lib/chef/provider.rb +1 -1
  86. data/lib/chef/recipe.rb +4 -12
  87. data/lib/chef/resource/_rest_resource.rb +389 -0
  88. data/lib/chef/resource/alternatives.rb +0 -1
  89. data/lib/chef/resource/apt_package.rb +21 -1
  90. data/lib/chef/resource/apt_preference.rb +0 -1
  91. data/lib/chef/resource/apt_repository.rb +138 -18
  92. data/lib/chef/resource/apt_update.rb +0 -1
  93. data/lib/chef/resource/archive_file.rb +0 -1
  94. data/lib/chef/resource/bash.rb +13 -1
  95. data/lib/chef/resource/batch.rb +0 -1
  96. data/lib/chef/resource/bff_package.rb +0 -1
  97. data/lib/chef/resource/breakpoint.rb +0 -1
  98. data/lib/chef/resource/build_essential.rb +0 -1
  99. data/lib/chef/resource/cab_package.rb +0 -1
  100. data/lib/chef/resource/chef_client_config.rb +12 -14
  101. data/lib/chef/resource/chef_client_cron.rb +1 -2
  102. data/lib/chef/resource/chef_client_launchd.rb +2 -2
  103. data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
  104. data/lib/chef/resource/chef_client_systemd_timer.rb +5 -1
  105. data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
  106. data/lib/chef/resource/chef_gem.rb +1 -2
  107. data/lib/chef/resource/chef_handler.rb +0 -1
  108. data/lib/chef/resource/chef_sleep.rb +1 -3
  109. data/lib/chef/resource/chef_vault_secret.rb +0 -1
  110. data/lib/chef/resource/chocolatey_config.rb +0 -1
  111. data/lib/chef/resource/chocolatey_feature.rb +0 -1
  112. data/lib/chef/resource/chocolatey_installer.rb +207 -0
  113. data/lib/chef/resource/chocolatey_package.rb +8 -1
  114. data/lib/chef/resource/chocolatey_source.rb +0 -1
  115. data/lib/chef/resource/cookbook_file.rb +0 -1
  116. data/lib/chef/resource/cron/_cron_shared.rb +0 -1
  117. data/lib/chef/resource/cron/cron.rb +0 -1
  118. data/lib/chef/resource/cron/cron_d.rb +15 -1
  119. data/lib/chef/resource/cron_access.rb +0 -1
  120. data/lib/chef/resource/csh.rb +0 -1
  121. data/lib/chef/resource/directory.rb +0 -1
  122. data/lib/chef/resource/dmg_package.rb +2 -1
  123. data/lib/chef/resource/dnf_package.rb +0 -1
  124. data/lib/chef/resource/dpkg_package.rb +0 -1
  125. data/lib/chef/resource/dsc_resource.rb +0 -1
  126. data/lib/chef/resource/dsc_script.rb +1 -2
  127. data/lib/chef/resource/execute.rb +8 -7
  128. data/lib/chef/resource/file.rb +0 -1
  129. data/lib/chef/resource/freebsd_package.rb +2 -1
  130. data/lib/chef/resource/gem_package.rb +2 -1
  131. data/lib/chef/resource/group.rb +25 -2
  132. data/lib/chef/resource/habitat/habitat_package.rb +0 -1
  133. data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
  134. data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
  135. data/lib/chef/resource/habitat_config.rb +0 -1
  136. data/lib/chef/resource/habitat_install.rb +2 -2
  137. data/lib/chef/resource/habitat_service.rb +0 -1
  138. data/lib/chef/resource/habitat_user_toml.rb +0 -1
  139. data/lib/chef/resource/homebrew_cask.rb +21 -33
  140. data/lib/chef/resource/homebrew_package.rb +3 -2
  141. data/lib/chef/resource/homebrew_tap.rb +32 -18
  142. data/lib/chef/resource/homebrew_update.rb +4 -6
  143. data/lib/chef/resource/hostname.rb +0 -1
  144. data/lib/chef/resource/http_request.rb +0 -1
  145. data/lib/chef/resource/ifconfig.rb +0 -1
  146. data/lib/chef/resource/inspec_input.rb +0 -1
  147. data/lib/chef/resource/inspec_waiver.rb +0 -1
  148. data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
  149. data/lib/chef/resource/ips_package.rb +0 -1
  150. data/lib/chef/resource/kernel_module.rb +0 -1
  151. data/lib/chef/resource/ksh.rb +0 -1
  152. data/lib/chef/resource/launchd.rb +9 -3
  153. data/lib/chef/resource/link.rb +0 -1
  154. data/lib/chef/resource/locale.rb +0 -1
  155. data/lib/chef/resource/log.rb +0 -1
  156. data/lib/chef/resource/lwrp_base.rb +0 -4
  157. data/lib/chef/resource/macos_pkg.rb +111 -0
  158. data/lib/chef/resource/macos_userdefaults.rb +3 -4
  159. data/lib/chef/resource/macosx_service.rb +0 -1
  160. data/lib/chef/resource/macports_package.rb +2 -1
  161. data/lib/chef/resource/mdadm.rb +0 -1
  162. data/lib/chef/resource/mount.rb +0 -1
  163. data/lib/chef/resource/msu_package.rb +0 -1
  164. data/lib/chef/resource/notify_group.rb +0 -2
  165. data/lib/chef/resource/ohai.rb +0 -1
  166. data/lib/chef/resource/ohai_hint.rb +0 -1
  167. data/lib/chef/resource/openbsd_package.rb +2 -1
  168. data/lib/chef/resource/openssl_dhparam.rb +0 -2
  169. data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
  170. data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
  171. data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
  172. data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
  173. data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
  174. data/lib/chef/resource/openssl_x509_crl.rb +0 -2
  175. data/lib/chef/resource/openssl_x509_request.rb +0 -2
  176. data/lib/chef/resource/osx_profile.rb +0 -1
  177. data/lib/chef/resource/package.rb +0 -1
  178. data/lib/chef/resource/pacman_package.rb +2 -1
  179. data/lib/chef/resource/paludis_package.rb +0 -1
  180. data/lib/chef/resource/perl.rb +0 -1
  181. data/lib/chef/resource/plist.rb +7 -3
  182. data/lib/chef/resource/portage_package.rb +2 -1
  183. data/lib/chef/resource/powershell_package.rb +4 -1
  184. data/lib/chef/resource/powershell_package_source.rb +0 -1
  185. data/lib/chef/resource/powershell_script.rb +5 -2
  186. data/lib/chef/resource/python.rb +0 -1
  187. data/lib/chef/resource/reboot.rb +0 -1
  188. data/lib/chef/resource/registry_key.rb +6 -1
  189. data/lib/chef/resource/remote_directory.rb +0 -1
  190. data/lib/chef/resource/remote_file.rb +0 -1
  191. data/lib/chef/resource/rhsm_errata.rb +0 -1
  192. data/lib/chef/resource/rhsm_errata_level.rb +0 -1
  193. data/lib/chef/resource/rhsm_register.rb +2 -4
  194. data/lib/chef/resource/rhsm_repo.rb +0 -1
  195. data/lib/chef/resource/rhsm_subscription.rb +0 -1
  196. data/lib/chef/resource/route.rb +0 -1
  197. data/lib/chef/resource/rpm_package.rb +2 -1
  198. data/lib/chef/resource/ruby.rb +0 -1
  199. data/lib/chef/resource/ruby_block.rb +0 -1
  200. data/lib/chef/resource/scm/_scm.rb +0 -2
  201. data/lib/chef/resource/scm/git.rb +0 -2
  202. data/lib/chef/resource/scm/subversion.rb +0 -2
  203. data/lib/chef/resource/script.rb +0 -1
  204. data/lib/chef/resource/selinux/common_helpers.rb +47 -0
  205. data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
  206. data/lib/chef/resource/selinux/selinux_default.erb +15 -0
  207. data/lib/chef/resource/selinux_boolean.rb +101 -0
  208. data/lib/chef/resource/selinux_fcontext.rb +160 -0
  209. data/lib/chef/resource/selinux_install.rb +107 -0
  210. data/lib/chef/resource/selinux_login.rb +129 -0
  211. data/lib/chef/resource/selinux_module.rb +143 -0
  212. data/lib/chef/resource/selinux_permissive.rb +64 -0
  213. data/lib/chef/resource/selinux_port.rb +118 -0
  214. data/lib/chef/resource/selinux_state.rb +166 -0
  215. data/lib/chef/resource/selinux_user.rb +137 -0
  216. data/lib/chef/resource/service.rb +4 -2
  217. data/lib/chef/resource/smartos_package.rb +2 -1
  218. data/lib/chef/resource/snap_package.rb +25 -1
  219. data/lib/chef/resource/solaris_package.rb +2 -1
  220. data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
  221. data/lib/chef/resource/sudo.rb +37 -3
  222. data/lib/chef/resource/support/client.erb +2 -2
  223. data/lib/chef/resource/support/ulimit.erb +40 -0
  224. data/lib/chef/resource/swap_file.rb +0 -1
  225. data/lib/chef/resource/sysctl.rb +2 -2
  226. data/lib/chef/resource/systemd_unit.rb +0 -1
  227. data/lib/chef/resource/template.rb +0 -1
  228. data/lib/chef/resource/timezone.rb +0 -1
  229. data/lib/chef/resource/user/aix_user.rb +0 -1
  230. data/lib/chef/resource/user/linux_user.rb +0 -1
  231. data/lib/chef/resource/user/mac_user.rb +0 -1
  232. data/lib/chef/resource/user/pw_user.rb +0 -1
  233. data/lib/chef/resource/user/solaris_user.rb +0 -1
  234. data/lib/chef/resource/user/windows_user.rb +0 -1
  235. data/lib/chef/resource/user.rb +10 -1
  236. data/lib/chef/resource/user_ulimit.rb +38 -1
  237. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
  238. data/lib/chef/resource/windows_ad_join.rb +0 -2
  239. data/lib/chef/resource/windows_audit_policy.rb +0 -2
  240. data/lib/chef/resource/windows_auto_run.rb +0 -1
  241. data/lib/chef/resource/windows_certificate.rb +1 -1
  242. data/lib/chef/resource/windows_defender.rb +0 -1
  243. data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
  244. data/lib/chef/resource/windows_dfs_folder.rb +0 -1
  245. data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
  246. data/lib/chef/resource/windows_dfs_server.rb +0 -1
  247. data/lib/chef/resource/windows_dns_record.rb +0 -1
  248. data/lib/chef/resource/windows_dns_zone.rb +0 -1
  249. data/lib/chef/resource/windows_env.rb +0 -1
  250. data/lib/chef/resource/windows_feature.rb +0 -1
  251. data/lib/chef/resource/windows_feature_dism.rb +0 -1
  252. data/lib/chef/resource/windows_feature_powershell.rb +0 -1
  253. data/lib/chef/resource/windows_firewall_profile.rb +0 -2
  254. data/lib/chef/resource/windows_firewall_rule.rb +0 -1
  255. data/lib/chef/resource/windows_font.rb +2 -3
  256. data/lib/chef/resource/windows_package.rb +3 -4
  257. data/lib/chef/resource/windows_pagefile.rb +0 -2
  258. data/lib/chef/resource/windows_path.rb +0 -1
  259. data/lib/chef/resource/windows_printer.rb +0 -1
  260. data/lib/chef/resource/windows_printer_port.rb +0 -1
  261. data/lib/chef/resource/windows_script.rb +0 -2
  262. data/lib/chef/resource/windows_security_policy.rb +2 -3
  263. data/lib/chef/resource/windows_service.rb +0 -1
  264. data/lib/chef/resource/windows_share.rb +0 -1
  265. data/lib/chef/resource/windows_shortcut.rb +1 -2
  266. data/lib/chef/resource/windows_task.rb +0 -1
  267. data/lib/chef/resource/windows_uac.rb +0 -1
  268. data/lib/chef/resource/windows_update_settings.rb +0 -1
  269. data/lib/chef/resource/windows_user_privilege.rb +14 -11
  270. data/lib/chef/resource/windows_workgroup.rb +0 -1
  271. data/lib/chef/resource/yum_package.rb +2 -1
  272. data/lib/chef/resource/yum_repository.rb +4 -1
  273. data/lib/chef/resource/zypper_package.rb +2 -1
  274. data/lib/chef/resource/zypper_repository.rb +0 -1
  275. data/lib/chef/resource.rb +23 -5
  276. data/lib/chef/resource_inspector.rb +25 -7
  277. data/lib/chef/resource_reporter.rb +4 -0
  278. data/lib/chef/resources.rb +11 -0
  279. data/lib/chef/run_context.rb +3 -3
  280. data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
  281. data/lib/chef/util/powershell/ps_credential.rb +10 -0
  282. data/lib/chef/version.rb +1 -1
  283. data/lib/chef/win32/handle.rb +6 -7
  284. data/lib/chef/win32/registry.rb +12 -4
  285. data/lib/chef/win32/security.rb +16 -1
  286. data/spec/data/rubygems.org/sexp_processor-info +2 -1
  287. data/spec/data/trusted_certs/intermediate.pem +38 -27
  288. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  289. data/spec/functional/resource/dsc_script_spec.rb +1 -1
  290. data/spec/functional/resource/execute_spec.rb +1 -1
  291. data/spec/functional/resource/group_spec.rb +26 -42
  292. data/spec/functional/resource/link_spec.rb +8 -8
  293. data/spec/functional/resource/plist_spec.rb +25 -0
  294. data/spec/functional/resource/registry_spec.rb +233 -609
  295. data/spec/functional/resource/remote_file_spec.rb +1 -1
  296. data/spec/functional/resource/user/linux_user_spec.rb +127 -0
  297. data/spec/functional/resource/windows_certificate_spec.rb +1 -1
  298. data/spec/functional/resource/windows_font_spec.rb +12 -9
  299. data/spec/functional/resource/yum_package_spec.rb +1 -1
  300. data/spec/functional/resource/zypper_package_spec.rb +12 -0
  301. data/spec/functional/shell_spec.rb +1 -2
  302. data/spec/functional/version_spec.rb +1 -1
  303. data/spec/functional/win32/registry_spec.rb +0 -3
  304. data/spec/integration/client/client_spec.rb +88 -3
  305. data/spec/integration/client/exit_code_spec.rb +1 -1
  306. data/spec/integration/client/fips_spec.rb +5 -5
  307. data/spec/integration/client/ipv6_spec.rb +1 -1
  308. data/spec/integration/client/open_ssl_spec.rb +3 -3
  309. data/spec/integration/compliance/compliance_spec.rb +1 -1
  310. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  311. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  312. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  313. data/spec/integration/recipes/notifies_spec.rb +1 -1
  314. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  315. data/spec/integration/recipes/remote_directory.rb +1 -1
  316. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  317. data/spec/integration/recipes/use_partial_spec.rb +2 -1
  318. data/spec/integration/solo/solo_spec.rb +2 -2
  319. data/spec/spec_helper.rb +7 -4
  320. data/spec/support/chef_helpers.rb +2 -2
  321. data/spec/support/platform_helpers.rb +28 -7
  322. data/spec/support/ruby_installer.rb +1 -1
  323. data/spec/support/shared/functional/file_resource.rb +3 -3
  324. data/spec/support/shared/functional/windows_script.rb +2 -2
  325. data/spec/tiny_server.rb +5 -2
  326. data/spec/unit/application/client_spec.rb +0 -10
  327. data/spec/unit/chef_fs/file_system_spec.rb +2 -0
  328. data/spec/unit/client_spec.rb +80 -4
  329. data/spec/unit/compliance/runner_spec.rb +8 -0
  330. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  331. data/spec/unit/data_collector_spec.rb +106 -2
  332. data/spec/unit/delayed_evaluator_spec.rb +35 -0
  333. data/spec/unit/file_cache_spec.rb +64 -0
  334. data/spec/unit/http/authenticator_spec.rb +121 -0
  335. data/spec/unit/mixin/homebrew_spec.rb +118 -0
  336. data/spec/unit/mixin/openssl_helper_spec.rb +5 -0
  337. data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
  338. data/spec/unit/node/vivid_mash_spec.rb +42 -0
  339. data/spec/unit/node_spec.rb +6 -0
  340. data/spec/unit/platform/query_helpers_spec.rb +2 -17
  341. data/spec/unit/property/validation_spec.rb +30 -0
  342. data/spec/unit/provider/apt_repository_spec.rb +48 -12
  343. data/spec/unit/provider/cron_spec.rb +2 -0
  344. data/spec/unit/provider/http_request_spec.rb +60 -72
  345. data/spec/unit/provider/launchd_spec.rb +2 -2
  346. data/spec/unit/provider/mount/aix_spec.rb +2 -2
  347. data/spec/unit/provider/mount/linux_spec.rb +15 -4
  348. data/spec/unit/provider/mount/mount_spec.rb +8 -8
  349. data/spec/unit/provider/package/apt_spec.rb +18 -13
  350. data/spec/unit/provider/package/chocolatey_spec.rb +41 -9
  351. data/spec/unit/provider/package/homebrew_spec.rb +4 -1
  352. data/spec/unit/provider/package/rpm_spec.rb +2 -2
  353. data/spec/unit/provider/package/rubygems_spec.rb +1 -1
  354. data/spec/unit/provider/package/windows_spec.rb +5 -5
  355. data/spec/unit/provider/package/zypper_spec.rb +32 -0
  356. data/spec/unit/provider/powershell_script_spec.rb +100 -4
  357. data/spec/unit/provider/registry_key_spec.rb +17 -17
  358. data/spec/unit/provider/remote_file/http_spec.rb +4 -4
  359. data/spec/unit/provider/service/systemd_service_spec.rb +1 -0
  360. data/spec/unit/provider/user/linux_spec.rb +51 -1
  361. data/spec/unit/provider/user/windows_spec.rb +1 -0
  362. data/spec/unit/provider/user_spec.rb +24 -6
  363. data/spec/unit/resource/apt_repository_spec.rb +5 -0
  364. data/spec/unit/resource/archive_file_spec.rb +1 -1
  365. data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
  366. data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
  367. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
  368. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
  369. data/spec/unit/resource/chocolatey_installer_spec.rb +151 -0
  370. data/spec/unit/resource/cron_d_spec.rb +37 -1
  371. data/spec/unit/resource/macos_pkg_spec.rb +38 -0
  372. data/spec/unit/resource/powershell_script_spec.rb +2 -2
  373. data/spec/unit/resource/rest_resource_spec.rb +381 -0
  374. data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
  375. data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
  376. data/spec/unit/resource/selinux_install_spec.rb +60 -0
  377. data/spec/unit/resource/selinux_login_spec.rb +73 -0
  378. data/spec/unit/resource/selinux_module_spec.rb +55 -0
  379. data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
  380. data/spec/unit/resource/selinux_port_spec.rb +42 -0
  381. data/spec/unit/resource/selinux_state_spec.rb +46 -0
  382. data/spec/unit/resource/selinux_user_spec.rb +92 -0
  383. data/spec/unit/resource/sysctl_spec.rb +2 -2
  384. data/spec/unit/resource/user/linux_user_spec.rb +42 -0
  385. data/spec/unit/resource/yum_repository_spec.rb +4 -0
  386. data/spec/unit/resource_inspector_spec.rb +36 -0
  387. data/spec/unit/resource_reporter_spec.rb +57 -3
  388. data/spec/unit/resource_spec.rb +94 -2
  389. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
  390. data/spec/unit/util/powershell/ps_credential_spec.rb +6 -0
  391. data/tasks/rspec.rb +1 -1
  392. metadata +126 -44
  393. data/lib/chef/powershell.rb +0 -81
  394. data/spec/unit/mixin/homebrew_user_spec.rb +0 -119
  395. /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
  396. /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
  397. /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
  398. /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
  399. /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
  400. /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
@@ -245,7 +245,7 @@ describe Chef::Resource::RemoteFile do
245
245
  end
246
246
  end
247
247
 
248
- context "when the the file is only accessible as a specific alternate identity" do
248
+ context "when the file is only accessible as a specific alternate identity" do
249
249
  let(:windows_nonadmin_user) { "chefremfile2" }
250
250
  let(:windows_nonadmin_user_password) { "j82ajfxK3;2Xe2" }
251
251
  include_context "a non-admin Windows user"
@@ -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
@@ -80,10 +80,10 @@ tNdbdS3U8nrG73iA2clmF57ARQWC
80
80
  -----END CERTIFICATE-----
81
81
  CERT
82
82
  end
83
+ let(:download_cert_url) { "https://testingchef.blob.core.windows.net/files/test.cer" }
83
84
  let(:cert_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.cer") }
84
85
  let(:pfx_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.pfx") }
85
86
  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
87
  let(:cer_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "test.cer") }
88
88
  let(:base64_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "base64_test.cer") }
89
89
  let(:pem_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "test.pem") }
@@ -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
 
@@ -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)
@@ -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,48 @@ describe "chef-client" do
31
35
  @server = @api = nil
32
36
  end
33
37
 
38
+ def install_certificate_in_store(client_name, store_location)
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:\\#{store_location}\\My -DnsName "#{client_name}"
43
+ }
44
+ else {
45
+ New-SelfSignedCertificate -CertStoreLocation Cert:\\#{store_location}\\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
+ end
54
+
55
+ def remove_certificate_from_store
56
+ powershell_exec! <<~EOH
57
+ Get-ChildItem -path cert:\\LocalMachine\\My -Recurse -Force | Where-Object { $_.Subject -Match "#{client_name}" } -ErrorAction Stop | Remove-Item
58
+ EOH
59
+ end
60
+
61
+ def remove_registry_key
62
+ powershell_exec!("Remove-ItemProperty -Path HKLM:\\SOFTWARE\\Progress\\Authentication -Name 'PfxPass' ")
63
+ end
64
+
65
+ def verify_export_password_exists
66
+ powershell_exec! <<~EOH
67
+ Try {
68
+ $response = Get-ItemProperty -Path "HKLM:\\Software\\Progress\\Authentication" -Name "PfxPass" -ErrorAction Stop
69
+ if ($response) {return $true}
70
+ }
71
+ Catch {
72
+ return $false
73
+ }
74
+ EOH
75
+ end
76
+
34
77
  include IntegrationSupport
35
78
  include Chef::Mixin::ShellOut
79
+ include Chef::Mixin::PowershellExec
36
80
 
37
81
  let(:chef_dir) { File.join(__dir__, "..", "..", "..") }
38
82
 
@@ -45,8 +89,10 @@ describe "chef-client" do
45
89
  # machine that has omnibus chef installed. In that case we need to ensure
46
90
  # we're running `chef-client` from the source tree and not the external one.
47
91
  # 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" }
92
+ let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai --always-dump-stacktrace" }
93
+ let(:chef_solo) { "bundle exec #{ChefUtils::Dist::Solo::EXEC} --legacy-mode --minimal-ohai --always-dump-stacktrace" }
94
+ let(:client_name) { "chef-973334" }
95
+ let(:hostname) { "973334" }
50
96
 
51
97
  context "when validation.pem in current Directory" do
52
98
  let(:validation_path) { "" }
@@ -57,6 +103,9 @@ describe "chef-client" do
57
103
  tempfile.close
58
104
  @path = tempfile.path
59
105
  Chef::Config.validation_key = @path
106
+ if ChefUtils.windows?
107
+ create_registry_key
108
+ end
60
109
 
61
110
  file "config/client.rb", <<~EOM
62
111
  local_mode true
@@ -133,7 +182,6 @@ describe "chef-client" do
133
182
  # FATAL: Configuration error NoMethodError: undefined method `xxx' for nil:NilClass
134
183
  expect(result.stdout).to include("xxx")
135
184
  end
136
-
137
185
  end
138
186
 
139
187
  it "should complete with success" do
@@ -146,6 +194,43 @@ describe "chef-client" do
146
194
  result.error!
147
195
  end
148
196
 
197
+ if ChefUtils.windows?
198
+ context "and the private key is in the Windows CertStore" do
199
+
200
+ it "should verify that the cert is loaded in the \\LocalMachine\\My store" do
201
+ Chef::Config[:auth_key_registry_type] = "machine"
202
+ install_certificate_in_store(client_name, "LocalMachine")
203
+ create_registry_key
204
+ expect(Chef::HTTP::Authenticator.check_certstore_for_key(hostname)).to eq(true)
205
+ end
206
+
207
+ it "should verify that the export password for the pfx is loaded in the Registry" do
208
+ expect(verify_export_password_exists.result).to eq(true)
209
+ end
210
+
211
+ it "should verify that a private key is returned to me" do
212
+ expect(Chef::HTTP::Authenticator.retrieve_certificate_key(client_name)).not_to be nil
213
+ remove_certificate_from_store
214
+ end
215
+
216
+ it "should verify that the cert is loaded in the \\CurrentUser\\My store" do
217
+ Chef::Config[:auth_key_registry_type] = "user"
218
+ install_certificate_in_store(client_name, "CurrentUser")
219
+ create_registry_key
220
+ expect(Chef::HTTP::Authenticator.check_certstore_for_key(hostname)).to eq(true)
221
+ end
222
+
223
+ it "should verify that the export password for the pfx is loaded in the Registry" do
224
+ expect(verify_export_password_exists.result).to eq(true)
225
+ end
226
+
227
+ it "should verify that a private key is returned to me" do
228
+ expect(Chef::HTTP::Authenticator.retrieve_certificate_key(client_name)).not_to be nil
229
+ remove_certificate_from_store
230
+ end
231
+ end
232
+ end
233
+
149
234
  context "and a private key" do
150
235
  before do
151
236
  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
 
@@ -9,21 +9,21 @@ describe "chef-client fips" do
9
9
  after { OpenSSL.fips_mode = false }
10
10
 
11
11
  # For non-FIPS OSes/builds of Ruby, enabling FIPS should error
12
- example "Error enabling fips_mode if FIPS not linked", fips_mode: false do
12
+ example "Error enabling fips_mode if FIPS not linked", :fips_mode_negative_test do
13
13
  expect { enable_fips }.to raise_error(OpenSSL::OpenSSLError)
14
14
  end
15
15
 
16
- example "Do not error on MD5 if not fips_mode", fips_mode: false do
16
+ example "Do not error on MD5 if not fips_mode", :fips_mode_negative_test do
17
17
  expect { OpenSSL::Digest.new("MD5", "test string for digesting") }.not_to raise_error
18
18
  end
19
19
 
20
20
  # For FIPS OSes/builds of Ruby, enabling FIPS should not error
21
- example "Do not error enabling fips_mode if FIPS linked", fips_mode: true do
21
+ example "Do not error enabling fips_mode if FIPS linked", :fips_mode_test do
22
22
  expect { enable_fips }.not_to raise_error
23
23
  end
24
24
 
25
- example "Error on MD5 if fips_mode", fips_mode: true do
25
+ example "Error on MD5 if fips_mode", :fips_mode_test do
26
26
  enable_fips
27
27
  expect { OpenSSL::Digest.new("MD5", "test string for digesting") }.to raise_error(OpenSSL::Digest::DigestError)
28
28
  end
29
- end
29
+ end
@@ -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)
@@ -2,8 +2,8 @@ require "spec_helper"
2
2
 
3
3
  describe "openssl checks" do
4
4
  let(:openssl_version_default) do
5
- if windows? || aix?
6
- "1.0.2zi"
5
+ if windows?
6
+ "3.0.9"
7
7
  elsif macos?
8
8
  "1.1.1m"
9
9
  else
@@ -13,7 +13,7 @@ describe "openssl checks" do
13
13
 
14
14
  %w{version library_version}.each do |method|
15
15
  # macOS just picks up its own for some reason, maybe it circumvents a build step
16
- example "check #{method}", openssl_version_check: true, not_supported_on_macos: true do
16
+ example "check #{method}", not_supported_on_macos: true do
17
17
  expect(OpenSSL.const_get("OPENSSL_#{method.upcase}")).to match(openssl_version_default), "OpenSSL doesn't match omnibus_overrides.rb"
18
18
  end
19
19
  end
@@ -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,19 @@ 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?
141
+ config.filter_run_excluding fips_mode_test: true unless fips_mode_build?
142
+ config.filter_run_excluding fips_mode_negative_test: true # disable all fips_mode negative tests
143
+ # Skip fips on windows
144
+ # config.filter_run_excluding :fips_mode if windows?
142
145
 
143
- config.filter_run_excluding not_supported_on_freebsd_gte_12_3: true if freebsd_gte_12_3?
144
146
  config.filter_run_excluding windows_only: true unless windows?
145
147
  config.filter_run_excluding not_supported_on_windows: true if windows?
148
+ config.filter_run_excluding not_supported_on_windows_11: true if windows_11?
146
149
  config.filter_run_excluding not_supported_on_macos: true if macos?
147
150
  config.filter_run_excluding macos_only: true unless macos?
148
151
  config.filter_run_excluding not_macos_gte_11: true if macos_gte_11?
149
152
  config.filter_run_excluding not_supported_on_aix: true if aix?
153
+ config.filter_run_excluding not_supported_on_freebsd_gte_12_3: true if freebsd_gte_12_3?
150
154
  config.filter_run_excluding not_supported_on_solaris: true if solaris?
151
155
  config.filter_run_excluding not_supported_on_gce: true if gce?
152
156
  config.filter_run_excluding win2012r2_only: true unless windows_2012r2?
@@ -166,8 +170,6 @@ RSpec.configure do |config|
166
170
  config.filter_run_excluding linux_only: true unless linux?
167
171
  config.filter_run_excluding aix_only: true unless aix?
168
172
  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
173
  config.filter_run_excluding opensuse: true unless opensuse?
172
174
  config.filter_run_excluding debian_family_only: true unless debian_family?
173
175
  config.filter_run_excluding supports_cloexec: true unless supports_cloexec?
@@ -180,6 +182,7 @@ RSpec.configure do |config|
180
182
  config.filter_run_excluding aes_256_gcm_only: true unless aes_256_gcm?
181
183
  config.filter_run_excluding broken: true
182
184
  config.filter_run_excluding not_wpar: true unless wpar?
185
+ config.filter_run_excluding not_supported_on_s390x: true unless s390x?
183
186
  config.filter_run_excluding not_supported_under_fips: true if fips?
184
187
  config.filter_run_excluding rhel: true unless rhel?
185
188
  config.filter_run_excluding rhel6: true unless rhel6?
@@ -69,8 +69,8 @@ def make_canonical_temp_directory
69
69
  end
70
70
 
71
71
  # Check if a cmd exists on the PATH
72
- def which(cmd)
73
- paths = ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ]
72
+ def which(cmd, prepend_path: nil, extra_path: nil)
73
+ paths = Array(prepend_path) + ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ] + Array(extra_path)
74
74
  paths.each do |path|
75
75
  filename = File.join(path, cmd)
76
76
  return filename if File.executable?(filename)