chef 17.10.95 → 18.1.0

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 (329) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +16 -8
  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 +12 -5
  7. data/lib/chef/api_client_v1.rb +9 -1
  8. data/lib/chef/application/exit_code.rb +3 -3
  9. data/lib/chef/chef_fs/file_system.rb +21 -7
  10. data/lib/chef/client.rb +169 -17
  11. data/lib/chef/compliance/input.rb +1 -1
  12. data/lib/chef/compliance/profile.rb +1 -1
  13. data/lib/chef/compliance/profile_collection.rb +0 -1
  14. data/lib/chef/compliance/waiver.rb +1 -1
  15. data/lib/chef/cookbook/syntax_check.rb +2 -2
  16. data/lib/chef/dsl/reader_helpers.rb +1 -1
  17. data/lib/chef/dsl/rest_resource.rb +77 -0
  18. data/lib/chef/event_dispatch/base.rb +3 -0
  19. data/lib/chef/exceptions.rb +8 -0
  20. data/lib/chef/http/authenticator.rb +170 -3
  21. data/lib/chef/http/ssl_policies.rb +3 -3
  22. data/lib/chef/mixin/powershell_exec.rb +5 -28
  23. data/lib/chef/node/mixin/immutablize_array.rb +1 -0
  24. data/lib/chef/property.rb +13 -6
  25. data/lib/chef/provider/cron.rb +5 -1
  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/launchd.rb +1 -0
  29. data/lib/chef/provider/mount/linux.rb +5 -0
  30. data/lib/chef/provider/mount/mount.rb +8 -0
  31. data/lib/chef/provider/mount/windows.rb +1 -1
  32. data/lib/chef/provider/package/chocolatey.rb +1 -18
  33. data/lib/chef/provider/package/rubygems.rb +1 -1
  34. data/lib/chef/provider/package/snap.rb +1 -1
  35. data/lib/chef/provider/package/windows/msi.rb +2 -2
  36. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
  37. data/lib/chef/provider/package/yum/yum_helper.py +5 -17
  38. data/lib/chef/provider/package/zypper/version.rb +60 -0
  39. data/lib/chef/provider/package/zypper.rb +47 -3
  40. data/lib/chef/provider/service/windows.rb +1 -1
  41. data/lib/chef/provider/user/aix.rb +5 -0
  42. data/lib/chef/provider/user/linux.rb +29 -0
  43. data/lib/chef/provider/user/mac.rb +1 -1
  44. data/lib/chef/provider/user.rb +46 -14
  45. data/lib/chef/provider/yum_repository.rb +13 -1
  46. data/lib/chef/provider.rb +1 -1
  47. data/lib/chef/recipe.rb +1 -1
  48. data/lib/chef/resource/_rest_resource.rb +389 -0
  49. data/lib/chef/resource/alternatives.rb +0 -1
  50. data/lib/chef/resource/apt_package.rb +2 -1
  51. data/lib/chef/resource/apt_preference.rb +0 -1
  52. data/lib/chef/resource/apt_repository.rb +0 -1
  53. data/lib/chef/resource/apt_update.rb +0 -1
  54. data/lib/chef/resource/archive_file.rb +0 -1
  55. data/lib/chef/resource/bash.rb +0 -1
  56. data/lib/chef/resource/batch.rb +0 -1
  57. data/lib/chef/resource/bff_package.rb +0 -1
  58. data/lib/chef/resource/breakpoint.rb +0 -1
  59. data/lib/chef/resource/build_essential.rb +0 -1
  60. data/lib/chef/resource/cab_package.rb +0 -1
  61. data/lib/chef/resource/chef_client_config.rb +12 -14
  62. data/lib/chef/resource/chef_client_cron.rb +1 -2
  63. data/lib/chef/resource/chef_client_launchd.rb +2 -2
  64. data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
  65. data/lib/chef/resource/chef_client_systemd_timer.rb +0 -1
  66. data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
  67. data/lib/chef/resource/chef_gem.rb +0 -1
  68. data/lib/chef/resource/chef_handler.rb +0 -1
  69. data/lib/chef/resource/chef_sleep.rb +1 -3
  70. data/lib/chef/resource/chef_vault_secret.rb +0 -1
  71. data/lib/chef/resource/chocolatey_config.rb +0 -1
  72. data/lib/chef/resource/chocolatey_feature.rb +0 -1
  73. data/lib/chef/resource/chocolatey_package.rb +0 -1
  74. data/lib/chef/resource/chocolatey_source.rb +0 -1
  75. data/lib/chef/resource/cookbook_file.rb +0 -1
  76. data/lib/chef/resource/cron/_cron_shared.rb +0 -1
  77. data/lib/chef/resource/cron/cron.rb +0 -1
  78. data/lib/chef/resource/cron/cron_d.rb +15 -1
  79. data/lib/chef/resource/cron_access.rb +0 -1
  80. data/lib/chef/resource/csh.rb +0 -1
  81. data/lib/chef/resource/directory.rb +0 -1
  82. data/lib/chef/resource/dmg_package.rb +2 -1
  83. data/lib/chef/resource/dnf_package.rb +0 -1
  84. data/lib/chef/resource/dpkg_package.rb +0 -1
  85. data/lib/chef/resource/dsc_resource.rb +0 -1
  86. data/lib/chef/resource/dsc_script.rb +0 -1
  87. data/lib/chef/resource/execute.rb +0 -1
  88. data/lib/chef/resource/file.rb +0 -1
  89. data/lib/chef/resource/freebsd_package.rb +2 -1
  90. data/lib/chef/resource/gem_package.rb +2 -1
  91. data/lib/chef/resource/group.rb +25 -2
  92. data/lib/chef/resource/habitat/habitat_package.rb +0 -1
  93. data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
  94. data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
  95. data/lib/chef/resource/habitat_config.rb +0 -1
  96. data/lib/chef/resource/habitat_install.rb +0 -1
  97. data/lib/chef/resource/habitat_service.rb +0 -1
  98. data/lib/chef/resource/habitat_user_toml.rb +0 -1
  99. data/lib/chef/resource/homebrew_cask.rb +0 -1
  100. data/lib/chef/resource/homebrew_package.rb +2 -1
  101. data/lib/chef/resource/homebrew_tap.rb +0 -1
  102. data/lib/chef/resource/homebrew_update.rb +0 -2
  103. data/lib/chef/resource/hostname.rb +0 -1
  104. data/lib/chef/resource/http_request.rb +0 -1
  105. data/lib/chef/resource/ifconfig.rb +0 -1
  106. data/lib/chef/resource/inspec_input.rb +0 -1
  107. data/lib/chef/resource/inspec_waiver.rb +0 -1
  108. data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
  109. data/lib/chef/resource/ips_package.rb +0 -1
  110. data/lib/chef/resource/kernel_module.rb +0 -1
  111. data/lib/chef/resource/ksh.rb +0 -1
  112. data/lib/chef/resource/launchd.rb +3 -1
  113. data/lib/chef/resource/link.rb +0 -1
  114. data/lib/chef/resource/locale.rb +2 -6
  115. data/lib/chef/resource/log.rb +0 -1
  116. data/lib/chef/resource/lwrp_base.rb +0 -4
  117. data/lib/chef/resource/macos_userdefaults.rb +8 -13
  118. data/lib/chef/resource/macosx_service.rb +0 -1
  119. data/lib/chef/resource/macports_package.rb +2 -1
  120. data/lib/chef/resource/mdadm.rb +0 -1
  121. data/lib/chef/resource/mount.rb +0 -1
  122. data/lib/chef/resource/msu_package.rb +0 -1
  123. data/lib/chef/resource/notify_group.rb +0 -2
  124. data/lib/chef/resource/ohai.rb +0 -1
  125. data/lib/chef/resource/ohai_hint.rb +0 -1
  126. data/lib/chef/resource/openbsd_package.rb +2 -1
  127. data/lib/chef/resource/openssl_dhparam.rb +0 -2
  128. data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
  129. data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
  130. data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
  131. data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
  132. data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
  133. data/lib/chef/resource/openssl_x509_crl.rb +0 -2
  134. data/lib/chef/resource/openssl_x509_request.rb +0 -2
  135. data/lib/chef/resource/osx_profile.rb +0 -1
  136. data/lib/chef/resource/package.rb +0 -1
  137. data/lib/chef/resource/pacman_package.rb +2 -1
  138. data/lib/chef/resource/paludis_package.rb +0 -1
  139. data/lib/chef/resource/perl.rb +0 -1
  140. data/lib/chef/resource/plist.rb +7 -3
  141. data/lib/chef/resource/portage_package.rb +2 -1
  142. data/lib/chef/resource/powershell_package.rb +0 -1
  143. data/lib/chef/resource/powershell_package_source.rb +0 -1
  144. data/lib/chef/resource/powershell_script.rb +0 -1
  145. data/lib/chef/resource/python.rb +0 -1
  146. data/lib/chef/resource/reboot.rb +0 -1
  147. data/lib/chef/resource/registry_key.rb +0 -1
  148. data/lib/chef/resource/remote_directory.rb +0 -1
  149. data/lib/chef/resource/remote_file.rb +0 -1
  150. data/lib/chef/resource/rhsm_errata.rb +0 -1
  151. data/lib/chef/resource/rhsm_errata_level.rb +0 -1
  152. data/lib/chef/resource/rhsm_register.rb +2 -4
  153. data/lib/chef/resource/rhsm_repo.rb +0 -1
  154. data/lib/chef/resource/rhsm_subscription.rb +0 -1
  155. data/lib/chef/resource/route.rb +0 -1
  156. data/lib/chef/resource/rpm_package.rb +2 -1
  157. data/lib/chef/resource/ruby.rb +0 -1
  158. data/lib/chef/resource/ruby_block.rb +0 -1
  159. data/lib/chef/resource/scm/_scm.rb +0 -2
  160. data/lib/chef/resource/scm/git.rb +0 -2
  161. data/lib/chef/resource/scm/subversion.rb +0 -2
  162. data/lib/chef/resource/script.rb +0 -1
  163. data/lib/chef/resource/selinux/common_helpers.rb +47 -0
  164. data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
  165. data/lib/chef/resource/selinux/selinux_default.erb +15 -0
  166. data/lib/chef/resource/selinux_boolean.rb +101 -0
  167. data/lib/chef/resource/selinux_fcontext.rb +160 -0
  168. data/lib/chef/resource/selinux_install.rb +107 -0
  169. data/lib/chef/resource/selinux_module.rb +143 -0
  170. data/lib/chef/resource/selinux_permissive.rb +64 -0
  171. data/lib/chef/resource/selinux_port.rb +118 -0
  172. data/lib/chef/resource/selinux_state.rb +166 -0
  173. data/lib/chef/resource/service.rb +0 -1
  174. data/lib/chef/resource/smartos_package.rb +2 -1
  175. data/lib/chef/resource/snap_package.rb +2 -1
  176. data/lib/chef/resource/solaris_package.rb +2 -1
  177. data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
  178. data/lib/chef/resource/sudo.rb +0 -1
  179. data/lib/chef/resource/support/client.erb +2 -2
  180. data/lib/chef/resource/swap_file.rb +0 -1
  181. data/lib/chef/resource/sysctl.rb +1 -2
  182. data/lib/chef/resource/systemd_unit.rb +0 -1
  183. data/lib/chef/resource/template.rb +0 -1
  184. data/lib/chef/resource/timezone.rb +0 -1
  185. data/lib/chef/resource/user/aix_user.rb +0 -1
  186. data/lib/chef/resource/user/linux_user.rb +0 -1
  187. data/lib/chef/resource/user/mac_user.rb +0 -1
  188. data/lib/chef/resource/user/pw_user.rb +0 -1
  189. data/lib/chef/resource/user/solaris_user.rb +0 -1
  190. data/lib/chef/resource/user/windows_user.rb +0 -1
  191. data/lib/chef/resource/user.rb +10 -1
  192. data/lib/chef/resource/user_ulimit.rb +0 -1
  193. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
  194. data/lib/chef/resource/windows_ad_join.rb +0 -2
  195. data/lib/chef/resource/windows_audit_policy.rb +0 -2
  196. data/lib/chef/resource/windows_auto_run.rb +0 -1
  197. data/lib/chef/resource/windows_defender.rb +0 -1
  198. data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
  199. data/lib/chef/resource/windows_dfs_folder.rb +0 -1
  200. data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
  201. data/lib/chef/resource/windows_dfs_server.rb +0 -1
  202. data/lib/chef/resource/windows_dns_record.rb +0 -1
  203. data/lib/chef/resource/windows_dns_zone.rb +0 -1
  204. data/lib/chef/resource/windows_env.rb +0 -1
  205. data/lib/chef/resource/windows_feature.rb +0 -1
  206. data/lib/chef/resource/windows_feature_dism.rb +0 -1
  207. data/lib/chef/resource/windows_feature_powershell.rb +0 -1
  208. data/lib/chef/resource/windows_firewall_profile.rb +0 -2
  209. data/lib/chef/resource/windows_firewall_rule.rb +0 -1
  210. data/lib/chef/resource/windows_font.rb +2 -3
  211. data/lib/chef/resource/windows_package.rb +3 -4
  212. data/lib/chef/resource/windows_pagefile.rb +0 -2
  213. data/lib/chef/resource/windows_path.rb +0 -1
  214. data/lib/chef/resource/windows_printer.rb +0 -1
  215. data/lib/chef/resource/windows_printer_port.rb +0 -1
  216. data/lib/chef/resource/windows_script.rb +0 -2
  217. data/lib/chef/resource/windows_security_policy.rb +0 -1
  218. data/lib/chef/resource/windows_service.rb +0 -1
  219. data/lib/chef/resource/windows_share.rb +0 -1
  220. data/lib/chef/resource/windows_shortcut.rb +1 -2
  221. data/lib/chef/resource/windows_task.rb +0 -1
  222. data/lib/chef/resource/windows_uac.rb +0 -1
  223. data/lib/chef/resource/windows_update_settings.rb +0 -1
  224. data/lib/chef/resource/windows_user_privilege.rb +0 -1
  225. data/lib/chef/resource/windows_workgroup.rb +0 -1
  226. data/lib/chef/resource/yum_package.rb +2 -1
  227. data/lib/chef/resource/yum_repository.rb +4 -1
  228. data/lib/chef/resource/zypper_package.rb +2 -1
  229. data/lib/chef/resource/zypper_repository.rb +0 -1
  230. data/lib/chef/resource.rb +12 -5
  231. data/lib/chef/resources.rb +7 -0
  232. data/lib/chef/run_context.rb +3 -3
  233. data/lib/chef/secret_fetcher/azure_key_vault.rb +3 -3
  234. data/lib/chef/version.rb +1 -1
  235. data/lib/chef/win32/handle.rb +6 -7
  236. data/lib/chef/win32/registry.rb +7 -3
  237. data/spec/data/chef_guid +1 -0
  238. data/spec/data/nodes/mcwfhpowell.json +3 -0
  239. data/spec/data/rubygems.org/sexp_processor-info +2 -1
  240. data/spec/data/trusted_certs/example.crt +20 -29
  241. data/spec/data/trusted_certs/example_no_cn.crt +34 -30
  242. data/spec/data/trusted_certs/opscode.pem +54 -33
  243. data/spec/functional/assets/yumrepo-empty/repodata/01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2 +0 -0
  244. data/spec/functional/assets/yumrepo-empty/repodata/401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz +0 -0
  245. data/spec/functional/assets/yumrepo-empty/repodata/5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2 +0 -0
  246. data/spec/functional/assets/yumrepo-empty/repodata/6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz +0 -0
  247. data/spec/functional/assets/yumrepo-empty/repodata/7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2 +0 -0
  248. data/spec/functional/assets/yumrepo-empty/repodata/dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz +0 -0
  249. data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +55 -0
  250. data/spec/functional/resource/chocolatey_package_spec.rb +20 -32
  251. data/spec/functional/resource/dsc_script_spec.rb +1 -1
  252. data/spec/functional/resource/group_spec.rb +10 -6
  253. data/spec/functional/resource/link_spec.rb +8 -8
  254. data/spec/functional/resource/macos_userdefaults_spec.rb +4 -4
  255. data/spec/functional/resource/plist_spec.rb +25 -0
  256. data/spec/functional/resource/user/linux_user_spec.rb +127 -0
  257. data/spec/functional/resource/windows_certificate_spec.rb +1 -26
  258. data/spec/functional/resource/windows_font_spec.rb +12 -9
  259. data/spec/functional/resource/yum_package_spec.rb +17 -1
  260. data/spec/functional/resource/zypper_package_spec.rb +12 -0
  261. data/spec/functional/shell_spec.rb +1 -2
  262. data/spec/functional/version_spec.rb +1 -1
  263. data/spec/integration/client/client_spec.rb +82 -3
  264. data/spec/integration/client/exit_code_spec.rb +1 -1
  265. data/spec/integration/client/fips_spec.rb +20 -0
  266. data/spec/integration/client/ipv6_spec.rb +1 -1
  267. data/spec/integration/compliance/compliance_spec.rb +1 -1
  268. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  269. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  270. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  271. data/spec/integration/recipes/notifies_spec.rb +1 -1
  272. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  273. data/spec/integration/recipes/remote_directory.rb +1 -1
  274. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  275. data/spec/integration/recipes/use_partial_spec.rb +2 -1
  276. data/spec/integration/solo/solo_spec.rb +2 -2
  277. data/spec/spec_helper.rb +5 -0
  278. data/spec/support/platform_helpers.rb +8 -0
  279. data/spec/support/ruby_installer.rb +1 -1
  280. data/spec/support/shared/functional/windows_script.rb +2 -2
  281. data/spec/unit/application/client_spec.rb +0 -10
  282. data/spec/unit/chef_fs/file_system_spec.rb +2 -0
  283. data/spec/unit/client_spec.rb +57 -8
  284. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
  285. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  286. data/spec/unit/http/authenticator_spec.rb +68 -0
  287. data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
  288. data/spec/unit/platform/query_helpers_spec.rb +2 -17
  289. data/spec/unit/property/validation_spec.rb +30 -0
  290. data/spec/unit/provider/cron_spec.rb +36 -0
  291. data/spec/unit/provider/http_request_spec.rb +60 -72
  292. data/spec/unit/provider/mount/linux_spec.rb +10 -0
  293. data/spec/unit/provider/package/chocolatey_spec.rb +3 -19
  294. data/spec/unit/provider/package/rubygems_spec.rb +1 -1
  295. data/spec/unit/provider/package/zypper_spec.rb +32 -0
  296. data/spec/unit/provider/user/linux_spec.rb +51 -11
  297. data/spec/unit/provider/user_spec.rb +24 -6
  298. data/spec/unit/resource/archive_file_spec.rb +1 -1
  299. data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
  300. data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
  301. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
  302. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
  303. data/spec/unit/resource/cron_d_spec.rb +37 -1
  304. data/spec/unit/resource/macos_user_defaults_spec.rb +4 -4
  305. data/spec/unit/resource/rest_resource_spec.rb +381 -0
  306. data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
  307. data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
  308. data/spec/unit/resource/selinux_install_spec.rb +60 -0
  309. data/spec/unit/resource/selinux_module_spec.rb +55 -0
  310. data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
  311. data/spec/unit/resource/selinux_port_spec.rb +42 -0
  312. data/spec/unit/resource/selinux_state_spec.rb +46 -0
  313. data/spec/unit/resource/sysctl_spec.rb +2 -2
  314. data/spec/unit/resource/user/linux_user_spec.rb +42 -0
  315. data/spec/unit/resource/yum_repository_spec.rb +4 -0
  316. data/spec/unit/resource_spec.rb +0 -1
  317. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
  318. data/tasks/rspec.rb +1 -1
  319. metadata +107 -31
  320. /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.0.nupkg → test-A.1.0.nupkg} +0 -0
  321. /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.0.nupkg → test-A.1.5.nupkg} +0 -0
  322. /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.0.nupkg → test-A.2.0.nupkg} +0 -0
  323. /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.0.nupkg → test-B.1.0.nupkg} +0 -0
  324. /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
  325. /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
  326. /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
  327. /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
  328. /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
  329. /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
@@ -19,6 +19,70 @@
19
19
  require "spec_helper"
20
20
  require "chef/http/authenticator"
21
21
 
22
+ describe Chef::HTTP::Authenticator, :windows_only do
23
+ let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test") }
24
+ let(:method) { "GET" }
25
+ let(:url) { URI("https://chef.example.com/organizations/test") }
26
+ let(:headers) { {} }
27
+ let(:data) { "" }
28
+ let(:node_name) { "test" }
29
+ let(:passwrd) { "some_insecure_password" }
30
+
31
+ before do
32
+ Chef::Config[:node_name] = node_name
33
+ cert_name = "chef-#{node_name}"
34
+ d = Time.now
35
+ end_date = Time.new + (3600 * 24 * 90)
36
+ end_date = end_date.utc.iso8601
37
+
38
+ my_client = Chef::Client.new
39
+ pfx = my_client.generate_pfx_package(cert_name, end_date)
40
+ my_client.import_pfx_to_store(pfx)
41
+ end
42
+
43
+ after(:each) do
44
+ require "chef/mixin/powershell_exec"
45
+ extend Chef::Mixin::PowershellExec
46
+ cert_name = "chef-#{node_name}"
47
+ delete_certificate(cert_name)
48
+ end
49
+
50
+ context "when retrieving a certificate from the certificate store" do
51
+ it "retrieves a certificate password from the registry when the hive does not already exist" do
52
+ delete_registry_hive
53
+ expect { class_instance.get_cert_password }.not_to raise_error
54
+ end
55
+
56
+ it "should return a password of at least 14 characters in length" do
57
+ password = class_instance.get_cert_password
58
+ expect(password.length).to eql(14)
59
+ end
60
+
61
+ it "correctly retrieves a valid certificate in pem format from the certstore" do
62
+ require "openssl"
63
+ certificate = class_instance.retrieve_certificate_key(node_name)
64
+ cert_object = OpenSSL::PKey::RSA.new(certificate)
65
+ expect(cert_object.to_s).to match(/BEGIN RSA PRIVATE KEY/)
66
+ end
67
+ end
68
+
69
+ def delete_certificate(cert_name)
70
+ powershell_code = <<~CODE
71
+ Get-ChildItem -path cert:\\LocalMachine\\My -Recurse -Force | Where-Object { $_.Subject -Match "#{cert_name}" } | Remove-item
72
+ CODE
73
+ powershell_exec!(powershell_code)
74
+ end
75
+
76
+ def delete_registry_hive
77
+ @win32registry = Chef::Win32::Registry.new
78
+ path = "HKEY_LOCAL_MACHINE\\Software\\Progress\\Authentication"
79
+ present = @win32registry.get_values(path)
80
+ unless present.nil? || present.empty?
81
+ @win32registry.delete_key(path, true)
82
+ end
83
+ end
84
+ end
85
+
22
86
  describe Chef::HTTP::Authenticator do
23
87
  let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test") }
24
88
  let(:method) { "GET" }
@@ -26,6 +90,10 @@ describe Chef::HTTP::Authenticator do
26
90
  let(:headers) { {} }
27
91
  let(:data) { "" }
28
92
 
93
+ before do
94
+ ::Chef::Config[:node_name] = "foo"
95
+ end
96
+
29
97
  context "when handle_request is called" do
30
98
  shared_examples_for "merging the server API version into the headers" do
31
99
  before do
@@ -26,7 +26,7 @@ describe Chef::Mixin::PowershellExec, :windows_only do
26
26
  describe "#powershell_exec" do
27
27
  context "not specifying an interpreter" do
28
28
  it "runs a basic command and returns a Chef::PowerShell object" do
29
- expect(object.powershell_exec("$PSVersionTable")).to be_kind_of(Chef::PowerShell)
29
+ expect(object.powershell_exec("$PSVersionTable")).to be_kind_of(ChefPowerShell::PowerShell)
30
30
  end
31
31
 
32
32
  it "uses less than version 6" do
@@ -37,7 +37,7 @@ describe Chef::Mixin::PowershellExec, :windows_only do
37
37
 
38
38
  context "using pwsh interpreter" do
39
39
  it "runs a basic command and returns a Chef::PowerShell object" do
40
- expect(object.powershell_exec("$PSVersionTable", :pwsh)).to be_kind_of(Chef::Pwsh)
40
+ expect(object.powershell_exec("$PSVersionTable", :pwsh)).to be_kind_of(ChefPowerShell::Pwsh)
41
41
  end
42
42
 
43
43
  it "uses greater than version 6" do
@@ -48,7 +48,7 @@ describe Chef::Mixin::PowershellExec, :windows_only do
48
48
 
49
49
  context "using powershell interpreter" do
50
50
  it "runs a basic command and returns a Chef::PowerShell object" do
51
- expect(object.powershell_exec("$PSVersionTable", :powershell)).to be_kind_of(Chef::PowerShell)
51
+ expect(object.powershell_exec("$PSVersionTable", :powershell)).to be_kind_of(ChefPowerShell::PowerShell)
52
52
  end
53
53
 
54
54
  it "uses less than version 6" do
@@ -76,11 +76,11 @@ describe Chef::Mixin::PowershellExec, :windows_only do
76
76
 
77
77
  describe "#powershell_exec!" do
78
78
  it "runs a basic command and returns a Chef::PowerShell object" do
79
- expect(object.powershell_exec!("$PSVersionTable")).to be_kind_of(Chef::PowerShell)
79
+ expect(object.powershell_exec!("$PSVersionTable")).to be_kind_of(ChefPowerShell::PowerShell)
80
80
  end
81
81
 
82
82
  it "raises an error if the command fails" do
83
- expect { object.powershell_exec!("this-should-error") }.to raise_error(Chef::PowerShell::CommandFailed)
83
+ expect { object.powershell_exec!("this-should-error") }.to raise_error(ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed)
84
84
  end
85
85
 
86
86
  it "raises an error if the interpreter is invalid" do
@@ -18,7 +18,7 @@
18
18
 
19
19
  require "spec_helper"
20
20
 
21
- describe "Chef::Platform#supports_dsc_invoke_resource?" do
21
+ describe "Chef::Platform#supports_dsc_invoke_resource?", :windows_only do
22
22
  it "returns false if powershell is not present" do
23
23
  node = Chef::Node.new
24
24
  expect(Chef::Platform.supports_dsc_invoke_resource?(node)).to be_falsey
@@ -39,25 +39,10 @@ describe "Chef::Platform#supports_dsc_invoke_resource?" do
39
39
  end
40
40
  end
41
41
 
42
- describe "Chef::Platform#dsc_refresh_mode_disabled?" do
42
+ describe "Chef::Platform#dsc_refresh_mode_disabled?", :windows_only do
43
43
  let(:node) { instance_double("Chef::Node") }
44
- let(:powershell) { instance_double("Chef::PowerShell") }
45
44
 
46
45
  it "returns true when RefreshMode is Disabled" do
47
- expect(Chef::PowerShell).to receive(:new)
48
- .with("Get-DscLocalConfigurationManager")
49
- .and_return(powershell)
50
- expect(powershell).to receive(:error!)
51
- expect(powershell).to receive(:result).and_return({ "RefreshMode" => "Disabled" })
52
- expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be true
53
- end
54
-
55
- it "returns false when RefreshMode is not Disabled" do
56
- expect(Chef::PowerShell).to receive(:new)
57
- .with("Get-DscLocalConfigurationManager")
58
- .and_return(powershell)
59
- expect(powershell).to receive(:error!)
60
- expect(powershell).to receive(:result).and_return({ "RefreshMode" => "LaLaLa" })
61
46
  expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be false
62
47
  end
63
48
  end
@@ -600,6 +600,36 @@ describe "Chef::Resource.property validation" do
600
600
  it "does not fail if it is not specified, on running the doit2 action" do
601
601
  expect { resource.run_action(:doit2) }.not_to raise_error
602
602
  end
603
+
604
+ context "when an action does not require it" do
605
+ before do
606
+ resource.action(:doit2)
607
+ end
608
+
609
+ it "retrieval succeeds if x is not set when resource uses the doit2 action" do
610
+ expect { resource.x }.not_to raise_error
611
+ end
612
+
613
+ it "succeeds with set to nil when resource uses the doit2 action" do
614
+ expect { resource.x nil }.not_to raise_error
615
+ end
616
+ end
617
+
618
+ context "when an action requires it" do
619
+ before do
620
+ # NOTE: this is already the default action, but it doesn't
621
+ # hurt to be clear about the situation.
622
+ resource.action(:doit)
623
+ end
624
+
625
+ it "if x is not specified, retrieval fails for the doit action" do
626
+ expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
627
+ end
628
+
629
+ it "value nil is not valid for the doit action (required means 'not nil')" do
630
+ expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed
631
+ end
632
+ end
603
633
  end
604
634
 
605
635
  with_property ":x, String, required: true" do
@@ -769,6 +769,42 @@ describe Chef::Provider::Cron do
769
769
  end
770
770
  end
771
771
 
772
+ context "when integers are provided to the resource to express time values" do
773
+ it "should not report any difference" do
774
+ @new_resource.minute(1)
775
+ @new_resource.hour(1)
776
+ @new_resource.day(1)
777
+ @new_resource.month(1)
778
+ @new_resource.weekday(1)
779
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
780
+ # Chef Name: cronhole some stuff
781
+ 1 1 1 1 1 /bin/true
782
+
783
+ CRONTAB
784
+
785
+ @provider.run_action(:create)
786
+ expect(@new_resource).not_to be_updated_by_last_action
787
+ end
788
+ end
789
+
790
+ context "when strings are provided to the resource to express time values" do
791
+ it "should not report any difference" do
792
+ @new_resource.minute("1")
793
+ @new_resource.hour("1")
794
+ @new_resource.day("1")
795
+ @new_resource.month("1")
796
+ @new_resource.weekday("1")
797
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
798
+ # Chef Name: cronhole some stuff
799
+ 1 1 1 1 1 /bin/true
800
+
801
+ CRONTAB
802
+
803
+ @provider.run_action(:create)
804
+ expect(@new_resource).not_to be_updated_by_last_action
805
+ end
806
+ end
807
+
772
808
  context "when environment variable is used" do
773
809
  before :each do
774
810
  @provider.cron_exists = true
@@ -19,87 +19,75 @@
19
19
  require "spec_helper"
20
20
 
21
21
  describe Chef::Provider::HttpRequest do
22
- before(:each) do
23
- @node = Chef::Node.new
24
- @events = Chef::EventDispatch::Dispatcher.new
25
- @run_context = Chef::RunContext.new(@node, {}, @events)
26
-
27
- @new_resource = Chef::Resource::HttpRequest.new("adam")
28
- @new_resource.name "adam"
29
- @new_resource.url "http://www.opscode.com/"
30
- @new_resource.message "is cool"
31
-
32
- @provider = Chef::Provider::HttpRequest.new(@new_resource, @run_context)
33
- end
34
-
35
- describe "load_current_resource" do
36
-
37
- it "should set up a Chef::ServerAPI client, with no authentication" do
38
- expect(Chef::HTTP::Simple).to receive(:new).with(@new_resource.url)
39
- @provider.load_current_resource
22
+ let(:node) { Chef::Node.new }
23
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
24
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
25
+ let(:new_resource) do
26
+ Chef::Resource::HttpRequest.new("adam").tap do |new_resource|
27
+ new_resource.name "adam"
28
+ new_resource.url "http://www.opscode.com/"
29
+ new_resource.message "is cool"
40
30
  end
41
31
  end
42
32
 
33
+ let(:provider) { Chef::Provider::HttpRequest.new(new_resource, run_context) }
34
+
43
35
  describe "when making REST calls" do
44
- before(:each) do
45
- # run_action(x) forces load_current_resource to run;
46
- # that would overwrite our supplied mock Chef::Rest # object
47
- allow(@provider).to receive(:load_current_resource).and_return(true)
48
- @http = double("Chef::ServerAPI")
49
- @provider.http = @http
36
+ let(:http) do
37
+ provider.http = double("Chef::ServerAPI")
50
38
  end
51
39
 
52
40
  describe "action_get" do
53
41
 
54
42
  it "should inflate a message block at runtime" do
55
- @new_resource.message { "return" }
56
- expect(@http).to receive(:get).with("http://www.opscode.com/", {})
57
- @provider.run_action(:get)
58
- expect(@new_resource).to be_updated
43
+ new_resource.message { "return" }
44
+ expect(http).to receive(:get).with("http://www.opscode.com/", {})
45
+ provider.run_action(:get)
46
+ expect(new_resource).to be_updated
59
47
  end
60
48
 
61
49
  it "should run a GET request" do
62
- expect(@http).to receive(:get).with("http://www.opscode.com/", {})
63
- @provider.run_action(:get)
64
- expect(@new_resource).to be_updated
50
+ expect(http).to receive(:get).with("http://www.opscode.com/", {})
51
+ provider.run_action(:get)
52
+ expect(new_resource).to be_updated
65
53
  end
66
54
  end
67
55
 
68
56
  describe "action_put" do
69
57
  it "should run a PUT request with the message as the payload" do
70
- expect(@http).to receive(:put).with("http://www.opscode.com/", @new_resource.message, {})
71
- @provider.run_action(:put)
72
- expect(@new_resource).to be_updated
58
+ expect(http).to receive(:put).with("http://www.opscode.com/", new_resource.message, {})
59
+ provider.run_action(:put)
60
+ expect(new_resource).to be_updated
73
61
  end
74
62
 
75
63
  it "should inflate a message block at runtime" do
76
- @new_resource.message(lambda { "return" })
77
- expect(@http).to receive(:put).with("http://www.opscode.com/", "return", {})
78
- @provider.run_action(:put)
79
- expect(@new_resource).to be_updated
64
+ new_resource.message(lambda { "return" })
65
+ expect(http).to receive(:put).with("http://www.opscode.com/", "return", {})
66
+ provider.run_action(:put)
67
+ expect(new_resource).to be_updated
80
68
  end
81
69
  end
82
70
 
83
71
  describe "action_post" do
84
72
  it "should run a PUT request with the message as the payload" do
85
- expect(@http).to receive(:post).with("http://www.opscode.com/", @new_resource.message, {})
86
- @provider.run_action(:post)
87
- expect(@new_resource).to be_updated
73
+ expect(http).to receive(:post).with("http://www.opscode.com/", new_resource.message, {})
74
+ provider.run_action(:post)
75
+ expect(new_resource).to be_updated
88
76
  end
89
77
 
90
78
  it "should inflate a message block at runtime" do
91
- @new_resource.message { "return" }
92
- expect(@http).to receive(:post).with("http://www.opscode.com/", "return", {})
93
- @provider.run_action(:post)
94
- expect(@new_resource).to be_updated
79
+ new_resource.message { "return" }
80
+ expect(http).to receive(:post).with("http://www.opscode.com/", "return", {})
81
+ provider.run_action(:post)
82
+ expect(new_resource).to be_updated
95
83
  end
96
84
  end
97
85
 
98
86
  describe "action_delete" do
99
87
  it "should run a DELETE request" do
100
- expect(@http).to receive(:delete).with("http://www.opscode.com/", {})
101
- @provider.run_action(:delete)
102
- expect(@new_resource).to be_updated
88
+ expect(http).to receive(:delete).with("http://www.opscode.com/", {})
89
+ provider.run_action(:delete)
90
+ expect(new_resource).to be_updated
103
91
  end
104
92
  end
105
93
 
@@ -107,52 +95,52 @@ describe Chef::Provider::HttpRequest do
107
95
  # and false for a "304 Not Modified" response
108
96
  describe "action_head" do
109
97
  before do
110
- @provider.http = @http
98
+ provider.http = http
111
99
  end
112
100
 
113
101
  it "should inflate a message block at runtime" do
114
- @new_resource.message { "return" }
115
- expect(@http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil)
116
- @provider.run_action(:head)
117
- expect(@new_resource).to be_updated
102
+ new_resource.message { "return" }
103
+ expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil)
104
+ provider.run_action(:head)
105
+ expect(new_resource).to be_updated
118
106
  end
119
107
 
120
108
  it "should run a HEAD request" do
121
- expect(@http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil)
122
- @provider.run_action(:head)
123
- expect(@new_resource).to be_updated
109
+ expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil)
110
+ provider.run_action(:head)
111
+ expect(new_resource).to be_updated
124
112
  end
125
113
 
126
114
  it "should update a HEAD request with empty string response body (CHEF-4762)" do
127
- expect(@http).to receive(:head).with("http://www.opscode.com/", {}).and_return("")
128
- @provider.run_action(:head)
129
- expect(@new_resource).to be_updated
115
+ expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return("")
116
+ provider.run_action(:head)
117
+ expect(new_resource).to be_updated
130
118
  end
131
119
 
132
120
  it "should update a HEAD request with nil response body (CHEF-4762)" do
133
- expect(@http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil)
134
- @provider.run_action(:head)
135
- expect(@new_resource).to be_updated
121
+ expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil)
122
+ provider.run_action(:head)
123
+ expect(new_resource).to be_updated
136
124
  end
137
125
 
138
126
  it "should not update a HEAD request if a not modified response (CHEF-4762)" do
139
127
  if_modified_since = File.mtime(__FILE__).httpdate
140
- @new_resource.headers "If-Modified-Since" => if_modified_since
141
- expect(@http).to receive(:head).with("http://www.opscode.com/", { "If-Modified-Since" => if_modified_since }).and_return(false)
142
- @provider.run_action(:head)
143
- expect(@new_resource).not_to be_updated
128
+ new_resource.headers "If-Modified-Since" => if_modified_since
129
+ expect(http).to receive(:head).with("http://www.opscode.com/", { "If-Modified-Since" => if_modified_since }).and_return(false)
130
+ provider.run_action(:head)
131
+ expect(new_resource).not_to be_updated
144
132
  end
145
133
 
146
134
  it "should run a HEAD request with If-Modified-Since header" do
147
- @new_resource.headers "If-Modified-Since" => File.mtime(__FILE__).httpdate
148
- expect(@http).to receive(:head).with("http://www.opscode.com/", @new_resource.headers)
149
- @provider.run_action(:head)
135
+ new_resource.headers "If-Modified-Since" => File.mtime(__FILE__).httpdate
136
+ expect(http).to receive(:head).with("http://www.opscode.com/", new_resource.headers)
137
+ provider.run_action(:head)
150
138
  end
151
139
 
152
140
  it "doesn't call converge_by if HEAD does not return modified" do
153
- expect(@http).to receive(:head).and_return(false)
154
- expect(@provider).not_to receive(:converge_by)
155
- @provider.run_action(:head)
141
+ expect(http).to receive(:head).and_return(false)
142
+ expect(provider).not_to receive(:converge_by)
143
+ provider.run_action(:head)
156
144
  end
157
145
  end
158
146
  end
@@ -25,6 +25,7 @@ describe Chef::Provider::Mount::Linux do
25
25
  allow(::File).to receive(:exists?).with("/dev/sdz1").and_return true
26
26
  allow(::File).to receive(:exists?).with("/tmp/foo").and_return true
27
27
  allow(::File).to receive(:exists?).with("//192.168.11.102/Share/backup").and_return true
28
+ allow(::File).to receive(:exists?).with("//192.168.11.102/Share/backup folder").and_return true
28
29
  allow(::File).to receive(:realpath).with("/dev/sdz1").and_return "/dev/sdz1"
29
30
  allow(::File).to receive(:realpath).with("/tmp/foo").and_return "/tmp/foo"
30
31
  end
@@ -103,6 +104,15 @@ describe Chef::Provider::Mount::Linux do
103
104
  provider.load_current_resource
104
105
  expect(provider.current_resource.mounted).to be_truthy
105
106
  end
107
+
108
+ it "should set mounted true if device name has a space and the mount point is found in the mounts list" do
109
+ new_resource.device "//192.168.11.102/Share/backup folder"
110
+ new_resource.fstype "cifs"
111
+ mount = "/tmp/foo //192.168.11.102/Share/backup\x20folder cifs rw\n"
112
+ allow(provider).to receive(:shell_out!).and_return(double(stdout: mount))
113
+ provider.load_current_resource
114
+ expect(provider.current_resource.mounted).to be_truthy
115
+ end
106
116
  end
107
117
 
108
118
  context "to check if loop resource is mounted" do
@@ -49,10 +49,6 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
49
49
  allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-l", "-r", { returns: [0, 2], timeout: timeout }).and_return(local_list_obj)
50
50
  end
51
51
 
52
- after(:each) do
53
- described_class.instance_variable_set(:@get_choco_version, nil)
54
- end
55
-
56
52
  def allow_remote_list(package_names, args = nil)
57
53
  remote_list_stdout = <<~EOF
58
54
  Chocolatey v0.9.9.11
@@ -65,9 +61,9 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
65
61
  remote_list_obj = double(stdout: remote_list_stdout)
66
62
  package_names.each do |pkg|
67
63
  if args
68
- allow(provider).to receive(:shell_out_compacted!).with(choco_exe, described_class.query_command, "-r", pkg, *args, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
64
+ allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, *args, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
69
65
  else
70
- allow(provider).to receive(:shell_out_compacted!).with(choco_exe, described_class.query_command, "-r", pkg, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
66
+ allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
71
67
  end
72
68
  end
73
69
  end
@@ -82,18 +78,6 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
82
78
  end
83
79
  end
84
80
 
85
- describe "choco searches change with the version" do
86
- it "Choco V1 uses List" do
87
- allow(described_class).to receive(:get_choco_version).and_return("1.4.0")
88
- expect(provider.query_command).to eql("list")
89
- end
90
-
91
- it "Choco V2 uses Search" do
92
- allow(described_class).to receive(:get_choco_version).and_return("2.1.0")
93
- expect(provider.query_command).to eql("search")
94
- end
95
- end
96
-
97
81
  describe "#candidate_version" do
98
82
  it "should set the candidate_version to the latest version when not pinning" do
99
83
  allow_remote_list(["git"])
@@ -166,7 +150,7 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
166
150
  new_resource.package_name("package-does-not-exist")
167
151
  new_resource.returns([0])
168
152
  allow(provider).to receive(:shell_out_compacted!)
169
- .with(choco_exe, described_class.query_command, "-r", new_resource.package_name.first, { returns: new_resource.returns, timeout: timeout })
153
+ .with(choco_exe, "list", "-r", new_resource.package_name.first, { returns: new_resource.returns, timeout: timeout })
170
154
  .and_raise(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
171
155
  expect { provider.send(:available_packages) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
172
156
  end
@@ -139,7 +139,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
139
139
  .to_return(status: 200, body: "", headers: {})
140
140
  stub_request(:get, "https://rubygems2.org/info/sexp_processor")
141
141
  .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-info")))
142
- stub_request(:get, "https://rubygems2.org/quick/Marshal.4.8/sexp_processor-4.15.1.gemspec.rz")
142
+ stub_request(:get, "https://rubygems2.org/quick/Marshal.4.8/sexp_processor-4.16.1.gemspec.rz")
143
143
  .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-4.15.1.gemspec.rz")))
144
144
 
145
145
  dep = Gem::Dependency.new("sexp_processor", ">= 0")
@@ -32,6 +32,8 @@ describe Chef::Provider::Package::Zypper do
32
32
 
33
33
  let(:status) { double(stdout: "\n", exitstatus: 0) }
34
34
 
35
+ let(:source) { "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm" }
36
+
35
37
  before(:each) do
36
38
  allow(Chef::Resource::Package).to receive(:new).and_return(current_resource)
37
39
  allow(provider).to receive(:shell_out_compacted!).and_return(status)
@@ -163,6 +165,21 @@ describe Chef::Provider::Package::Zypper do
163
165
  )
164
166
  provider.install_package(["emacs"], ["1.0"])
165
167
  end
168
+
169
+ it "should run zypper install with source option" do
170
+ new_resource.source "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm"
171
+ allow(::File).to receive(:exist?).with("/tmp/wget_1.11.4-1ubuntu1_amd64.rpm").and_return(true)
172
+ shell_out_expectation!(
173
+ "zypper", "--non-interactive", "install", "--auto-agree-with-licenses", "--oldpackage", "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm"
174
+ )
175
+ provider.install_package(["wget"], ["1.11.4-1ubuntu1_amd64"])
176
+ end
177
+
178
+ it "should raise an exception if a source is supplied but not found when :install" do
179
+ new_resource.source "/tmp/blah/wget_1.11.4-1ubuntu1_amd64.rpm"
180
+ allow(::File).to receive(:exist?).with(new_resource.source).and_return(false)
181
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
182
+ end
166
183
  end
167
184
 
168
185
  describe "upgrade_package" do
@@ -200,6 +217,21 @@ describe Chef::Provider::Package::Zypper do
200
217
  )
201
218
  provider.upgrade_package(["emacs"], ["1.0"])
202
219
  end
220
+
221
+ it "should run zypper upgrade with source option" do
222
+ new_resource.source "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm"
223
+ allow(::File).to receive(:exist?).with("/tmp/wget_1.11.4-1ubuntu1_amd64.rpm").and_return(true)
224
+ shell_out_expectation!(
225
+ "zypper", "--non-interactive", "install", "--auto-agree-with-licenses", "--oldpackage", "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm"
226
+ )
227
+ provider.upgrade_package(["wget"], ["1.11.4-1ubuntu1_amd64"])
228
+ end
229
+
230
+ it "should raise an exception if a source is supplied but not found when :upgrade" do
231
+ new_resource.source "/tmp/blah/wget_1.11.4-1ubuntu1_amd64.rpm"
232
+ allow(::File).to receive(:exist?).with(new_resource.source).and_return(false)
233
+ expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
234
+ end
203
235
  end
204
236
 
205
237
  describe "remove_package" do
@@ -20,7 +20,7 @@
20
20
 
21
21
  require "spec_helper"
22
22
 
23
- describe Chef::Provider::User::Linux do
23
+ describe Chef::Provider::User::Linux, linux_only: true do
24
24
 
25
25
  subject(:provider) do
26
26
  p = described_class.new(@new_resource, @run_context)
@@ -71,6 +71,56 @@ describe Chef::Provider::User::Linux do
71
71
  end
72
72
  end
73
73
 
74
+ describe "expire_date behavior" do
75
+ before(:each) do
76
+ @new_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context)
77
+ @current_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context)
78
+ end
79
+
80
+ it "defaults expire_date to nil" do
81
+ expect( @new_resource.expire_date ).to be nil
82
+ end
83
+
84
+ it "by default expire_date is nil and we use ''" do
85
+ expect( provider.universal_options ).to eql([])
86
+ end
87
+
88
+ it "setting expire_date to nil includes ''" do
89
+ @new_resource.expire_date nil
90
+ expect( provider.universal_options ).to eql([])
91
+ end
92
+
93
+ it "setting expire_date to 1982-04-16 includes -e" do
94
+ @new_resource.expire_date "1982-04-16"
95
+ expect( provider.universal_options ).to eql(["-e", "1982-04-16"])
96
+ end
97
+ end
98
+
99
+ describe "inactive behavior" do
100
+ before(:each) do
101
+ @new_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context)
102
+ @current_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context)
103
+ end
104
+
105
+ it "defaults inactive to nil" do
106
+ expect( @new_resource.inactive ).to be nil
107
+ end
108
+
109
+ it "by default inactive is nil and we use ''" do
110
+ expect( provider.universal_options ).to eql([])
111
+ end
112
+
113
+ it "setting inactive to nil includes ''" do
114
+ @new_resource.inactive nil
115
+ expect( provider.universal_options ).to eql([])
116
+ end
117
+
118
+ it "setting inactive to 90 includes -f" do
119
+ @new_resource.inactive 90
120
+ expect( provider.universal_options ).to eql(["-f", 90])
121
+ end
122
+ end
123
+
74
124
  describe "compare_user_linux" do
75
125
  before(:each) do
76
126
  @new_resource = Chef::Resource::User::LinuxUser.new("notarealuser")
@@ -86,7 +136,6 @@ describe Chef::Provider::User::Linux do
86
136
  "home" => ["/home/notarealuser", "/Users/notarealuser"],
87
137
  "shell" => ["/usr/bin/zsh", "/bin/bash"],
88
138
  "password" => %w{abcd 12345},
89
- "sensitive" => [true],
90
139
  }
91
140
  end
92
141
 
@@ -98,15 +147,6 @@ describe Chef::Provider::User::Linux do
98
147
  end
99
148
  end
100
149
 
101
- it "should show a blank for password if sensitive set to true" do
102
- @new_resource.password mapping["password"][0]
103
- @current_resource.password mapping["password"][1]
104
- @new_resource.sensitive true
105
- @current_resource.sensitive true
106
- provider.compare_user
107
- expect(provider.change_desc).to eql(["change password from ******** to ********"])
108
- end
109
-
110
150
  %w{uid gid}.each do |property|
111
151
  it "should return false if string #{property} matches fixnum" do
112
152
  @new_resource.send(property, "100")