chef 17.10.163 → 18.0.169

Sign up to get free protection for your applications and to get access to all the features.
Files changed (330) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +19 -20
  3. data/README.md +7 -7
  4. data/Rakefile +3 -22
  5. data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +8 -7
  6. data/chef.gemspec +17 -15
  7. data/lib/chef/api_client_v1.rb +9 -1
  8. data/lib/chef/application/exit_code.rb +3 -3
  9. data/lib/chef/client.rb +182 -0
  10. data/lib/chef/compliance/input.rb +1 -1
  11. data/lib/chef/compliance/profile.rb +1 -1
  12. data/lib/chef/compliance/profile_collection.rb +0 -1
  13. data/lib/chef/compliance/waiver.rb +1 -1
  14. data/lib/chef/cookbook/syntax_check.rb +2 -2
  15. data/lib/chef/dsl/reader_helpers.rb +1 -1
  16. data/lib/chef/dsl/rest_resource.rb +77 -0
  17. data/lib/chef/event_dispatch/base.rb +3 -0
  18. data/lib/chef/exceptions.rb +8 -0
  19. data/lib/chef/http/authenticator.rb +170 -3
  20. data/lib/chef/http/ssl_policies.rb +4 -4
  21. data/lib/chef/mixin/checksum.rb +0 -6
  22. data/lib/chef/mixin/homebrew_user.rb +5 -15
  23. data/lib/chef/mixin/openssl_helper.rb +13 -17
  24. data/lib/chef/mixin/powershell_exec.rb +5 -28
  25. data/lib/chef/node/mixin/immutablize_array.rb +1 -0
  26. data/lib/chef/property.rb +5 -3
  27. data/lib/chef/provider/cron.rb +1 -5
  28. data/lib/chef/provider/file.rb +2 -2
  29. data/lib/chef/provider/group/windows.rb +1 -1
  30. data/lib/chef/provider/http_request.rb +11 -9
  31. data/lib/chef/provider/mount/linux.rb +5 -0
  32. data/lib/chef/provider/mount/mount.rb +8 -0
  33. data/lib/chef/provider/mount/windows.rb +1 -1
  34. data/lib/chef/provider/package/chocolatey.rb +1 -14
  35. data/lib/chef/provider/package/rubygems.rb +1 -1
  36. data/lib/chef/provider/package/windows/msi.rb +2 -2
  37. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
  38. data/lib/chef/provider/package/windows.rb +1 -1
  39. data/lib/chef/provider/package/yum/yum_helper.py +14 -2
  40. data/lib/chef/provider/package/zypper/version.rb +60 -0
  41. data/lib/chef/provider/package/zypper.rb +47 -8
  42. data/lib/chef/provider/service/windows.rb +1 -1
  43. data/lib/chef/provider/user/aix.rb +5 -0
  44. data/lib/chef/provider/user/linux.rb +29 -0
  45. data/lib/chef/provider/user/mac.rb +1 -1
  46. data/lib/chef/provider/user.rb +46 -14
  47. data/lib/chef/provider.rb +1 -1
  48. data/lib/chef/recipe.rb +1 -1
  49. data/lib/chef/resource/_rest_resource.rb +389 -0
  50. data/lib/chef/resource/alternatives.rb +0 -1
  51. data/lib/chef/resource/apt_package.rb +0 -1
  52. data/lib/chef/resource/apt_preference.rb +0 -1
  53. data/lib/chef/resource/apt_repository.rb +0 -1
  54. data/lib/chef/resource/apt_update.rb +0 -1
  55. data/lib/chef/resource/archive_file.rb +0 -1
  56. data/lib/chef/resource/bash.rb +0 -1
  57. data/lib/chef/resource/batch.rb +0 -1
  58. data/lib/chef/resource/bff_package.rb +0 -1
  59. data/lib/chef/resource/breakpoint.rb +0 -1
  60. data/lib/chef/resource/build_essential.rb +0 -1
  61. data/lib/chef/resource/cab_package.rb +0 -1
  62. data/lib/chef/resource/chef_client_config.rb +14 -18
  63. data/lib/chef/resource/chef_client_cron.rb +1 -2
  64. data/lib/chef/resource/chef_client_launchd.rb +2 -2
  65. data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
  66. data/lib/chef/resource/chef_client_systemd_timer.rb +1 -2
  67. data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
  68. data/lib/chef/resource/chef_gem.rb +0 -1
  69. data/lib/chef/resource/chef_handler.rb +0 -1
  70. data/lib/chef/resource/chef_sleep.rb +1 -3
  71. data/lib/chef/resource/chef_vault_secret.rb +0 -1
  72. data/lib/chef/resource/chocolatey_config.rb +0 -1
  73. data/lib/chef/resource/chocolatey_feature.rb +0 -1
  74. data/lib/chef/resource/chocolatey_package.rb +0 -1
  75. data/lib/chef/resource/chocolatey_source.rb +0 -1
  76. data/lib/chef/resource/cookbook_file.rb +0 -1
  77. data/lib/chef/resource/cron/_cron_shared.rb +0 -1
  78. data/lib/chef/resource/cron/cron.rb +0 -1
  79. data/lib/chef/resource/cron/cron_d.rb +15 -1
  80. data/lib/chef/resource/cron_access.rb +0 -1
  81. data/lib/chef/resource/csh.rb +0 -1
  82. data/lib/chef/resource/directory.rb +0 -1
  83. data/lib/chef/resource/dmg_package.rb +0 -1
  84. data/lib/chef/resource/dnf_package.rb +0 -1
  85. data/lib/chef/resource/dpkg_package.rb +0 -1
  86. data/lib/chef/resource/dsc_resource.rb +0 -1
  87. data/lib/chef/resource/dsc_script.rb +0 -1
  88. data/lib/chef/resource/execute.rb +0 -1
  89. data/lib/chef/resource/file.rb +0 -1
  90. data/lib/chef/resource/freebsd_package.rb +0 -1
  91. data/lib/chef/resource/gem_package.rb +0 -1
  92. data/lib/chef/resource/group.rb +25 -2
  93. data/lib/chef/resource/habitat/habitat_package.rb +0 -1
  94. data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
  95. data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
  96. data/lib/chef/resource/habitat_config.rb +0 -1
  97. data/lib/chef/resource/habitat_install.rb +0 -1
  98. data/lib/chef/resource/habitat_service.rb +0 -1
  99. data/lib/chef/resource/habitat_user_toml.rb +0 -1
  100. data/lib/chef/resource/homebrew_cask.rb +8 -8
  101. data/lib/chef/resource/homebrew_package.rb +1 -2
  102. data/lib/chef/resource/homebrew_tap.rb +5 -6
  103. data/lib/chef/resource/homebrew_update.rb +0 -2
  104. data/lib/chef/resource/hostname.rb +0 -1
  105. data/lib/chef/resource/http_request.rb +0 -1
  106. data/lib/chef/resource/ifconfig.rb +0 -1
  107. data/lib/chef/resource/inspec_input.rb +0 -1
  108. data/lib/chef/resource/inspec_waiver.rb +0 -1
  109. data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
  110. data/lib/chef/resource/ips_package.rb +0 -1
  111. data/lib/chef/resource/kernel_module.rb +0 -1
  112. data/lib/chef/resource/ksh.rb +0 -1
  113. data/lib/chef/resource/launchd.rb +0 -1
  114. data/lib/chef/resource/link.rb +0 -1
  115. data/lib/chef/resource/locale.rb +2 -6
  116. data/lib/chef/resource/log.rb +0 -1
  117. data/lib/chef/resource/lwrp_base.rb +0 -4
  118. data/lib/chef/resource/macos_userdefaults.rb +5 -10
  119. data/lib/chef/resource/macosx_service.rb +0 -1
  120. data/lib/chef/resource/macports_package.rb +0 -1
  121. data/lib/chef/resource/mdadm.rb +0 -1
  122. data/lib/chef/resource/mount.rb +0 -1
  123. data/lib/chef/resource/msu_package.rb +0 -1
  124. data/lib/chef/resource/notify_group.rb +0 -2
  125. data/lib/chef/resource/ohai.rb +0 -1
  126. data/lib/chef/resource/ohai_hint.rb +0 -1
  127. data/lib/chef/resource/openbsd_package.rb +0 -1
  128. data/lib/chef/resource/openssl_dhparam.rb +0 -2
  129. data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
  130. data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
  131. data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
  132. data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
  133. data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
  134. data/lib/chef/resource/openssl_x509_crl.rb +0 -2
  135. data/lib/chef/resource/openssl_x509_request.rb +0 -2
  136. data/lib/chef/resource/osx_profile.rb +0 -1
  137. data/lib/chef/resource/package.rb +0 -1
  138. data/lib/chef/resource/pacman_package.rb +0 -1
  139. data/lib/chef/resource/paludis_package.rb +0 -1
  140. data/lib/chef/resource/perl.rb +0 -1
  141. data/lib/chef/resource/plist.rb +7 -3
  142. data/lib/chef/resource/portage_package.rb +0 -1
  143. data/lib/chef/resource/powershell_package.rb +0 -1
  144. data/lib/chef/resource/powershell_package_source.rb +0 -1
  145. data/lib/chef/resource/powershell_script.rb +0 -1
  146. data/lib/chef/resource/python.rb +0 -1
  147. data/lib/chef/resource/reboot.rb +0 -1
  148. data/lib/chef/resource/registry_key.rb +0 -1
  149. data/lib/chef/resource/remote_directory.rb +0 -1
  150. data/lib/chef/resource/remote_file.rb +0 -1
  151. data/lib/chef/resource/rhsm_errata.rb +0 -1
  152. data/lib/chef/resource/rhsm_errata_level.rb +0 -1
  153. data/lib/chef/resource/rhsm_register.rb +0 -3
  154. data/lib/chef/resource/rhsm_repo.rb +0 -1
  155. data/lib/chef/resource/rhsm_subscription.rb +0 -1
  156. data/lib/chef/resource/route.rb +0 -1
  157. data/lib/chef/resource/rpm_package.rb +0 -1
  158. data/lib/chef/resource/ruby.rb +0 -1
  159. data/lib/chef/resource/ruby_block.rb +0 -1
  160. data/lib/chef/resource/scm/_scm.rb +0 -2
  161. data/lib/chef/resource/scm/git.rb +0 -2
  162. data/lib/chef/resource/scm/subversion.rb +0 -2
  163. data/lib/chef/resource/script.rb +0 -1
  164. data/lib/chef/resource/selinux/common_helpers.rb +47 -0
  165. data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
  166. data/lib/chef/resource/selinux/selinux_default.erb +15 -0
  167. data/lib/chef/resource/selinux_boolean.rb +101 -0
  168. data/lib/chef/resource/selinux_fcontext.rb +160 -0
  169. data/lib/chef/resource/selinux_install.rb +107 -0
  170. data/lib/chef/resource/selinux_module.rb +143 -0
  171. data/lib/chef/resource/selinux_permissive.rb +64 -0
  172. data/lib/chef/resource/selinux_port.rb +118 -0
  173. data/lib/chef/resource/selinux_state.rb +166 -0
  174. data/lib/chef/resource/service.rb +0 -1
  175. data/lib/chef/resource/smartos_package.rb +0 -1
  176. data/lib/chef/resource/snap_package.rb +0 -1
  177. data/lib/chef/resource/solaris_package.rb +0 -1
  178. data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
  179. data/lib/chef/resource/sudo.rb +0 -1
  180. data/lib/chef/resource/support/client.erb +5 -6
  181. data/lib/chef/resource/swap_file.rb +0 -1
  182. data/lib/chef/resource/sysctl.rb +1 -2
  183. data/lib/chef/resource/systemd_unit.rb +0 -1
  184. data/lib/chef/resource/template.rb +0 -1
  185. data/lib/chef/resource/timezone.rb +0 -1
  186. data/lib/chef/resource/user/aix_user.rb +0 -1
  187. data/lib/chef/resource/user/linux_user.rb +0 -1
  188. data/lib/chef/resource/user/mac_user.rb +0 -1
  189. data/lib/chef/resource/user/pw_user.rb +0 -1
  190. data/lib/chef/resource/user/solaris_user.rb +0 -1
  191. data/lib/chef/resource/user/windows_user.rb +0 -1
  192. data/lib/chef/resource/user.rb +10 -1
  193. data/lib/chef/resource/user_ulimit.rb +0 -1
  194. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
  195. data/lib/chef/resource/windows_ad_join.rb +0 -2
  196. data/lib/chef/resource/windows_audit_policy.rb +0 -2
  197. data/lib/chef/resource/windows_auto_run.rb +0 -1
  198. data/lib/chef/resource/windows_defender.rb +0 -1
  199. data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
  200. data/lib/chef/resource/windows_dfs_folder.rb +0 -1
  201. data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
  202. data/lib/chef/resource/windows_dfs_server.rb +0 -1
  203. data/lib/chef/resource/windows_dns_record.rb +0 -1
  204. data/lib/chef/resource/windows_dns_zone.rb +0 -1
  205. data/lib/chef/resource/windows_env.rb +0 -1
  206. data/lib/chef/resource/windows_feature.rb +0 -1
  207. data/lib/chef/resource/windows_feature_dism.rb +0 -1
  208. data/lib/chef/resource/windows_feature_powershell.rb +0 -1
  209. data/lib/chef/resource/windows_firewall_profile.rb +0 -2
  210. data/lib/chef/resource/windows_firewall_rule.rb +0 -1
  211. data/lib/chef/resource/windows_font.rb +2 -3
  212. data/lib/chef/resource/windows_package.rb +0 -1
  213. data/lib/chef/resource/windows_pagefile.rb +0 -2
  214. data/lib/chef/resource/windows_path.rb +0 -1
  215. data/lib/chef/resource/windows_printer.rb +0 -1
  216. data/lib/chef/resource/windows_printer_port.rb +0 -1
  217. data/lib/chef/resource/windows_script.rb +0 -2
  218. data/lib/chef/resource/windows_security_policy.rb +0 -1
  219. data/lib/chef/resource/windows_service.rb +0 -1
  220. data/lib/chef/resource/windows_share.rb +0 -1
  221. data/lib/chef/resource/windows_shortcut.rb +1 -2
  222. data/lib/chef/resource/windows_task.rb +0 -1
  223. data/lib/chef/resource/windows_uac.rb +0 -1
  224. data/lib/chef/resource/windows_update_settings.rb +0 -1
  225. data/lib/chef/resource/windows_user_privilege.rb +0 -1
  226. data/lib/chef/resource/windows_workgroup.rb +0 -1
  227. data/lib/chef/resource/yum_package.rb +0 -1
  228. data/lib/chef/resource/yum_repository.rb +0 -1
  229. data/lib/chef/resource/zypper_package.rb +0 -1
  230. data/lib/chef/resource/zypper_repository.rb +0 -1
  231. data/lib/chef/resource.rb +12 -5
  232. data/lib/chef/resources.rb +7 -0
  233. data/lib/chef/run_context.rb +3 -3
  234. data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
  235. data/lib/chef/version.rb +1 -1
  236. data/lib/chef/win32/handle.rb +6 -7
  237. data/lib/chef/win32/registry.rb +7 -3
  238. data/spec/data/rubygems.org/sexp_processor-info +2 -1
  239. data/spec/data/trusted_certs/example.crt +20 -29
  240. data/spec/data/trusted_certs/example_no_cn.crt +34 -30
  241. data/spec/data/trusted_certs/opscode.pem +54 -33
  242. data/spec/functional/resource/chocolatey_package_spec.rb +20 -32
  243. data/spec/functional/resource/dsc_script_spec.rb +1 -1
  244. data/spec/functional/resource/group_spec.rb +26 -42
  245. data/spec/functional/resource/link_spec.rb +8 -8
  246. data/spec/functional/resource/macos_userdefaults_spec.rb +4 -4
  247. data/spec/functional/resource/plist_spec.rb +25 -0
  248. data/spec/functional/resource/user/linux_user_spec.rb +127 -0
  249. data/spec/functional/resource/windows_certificate_spec.rb +1 -26
  250. data/spec/functional/resource/windows_font_spec.rb +12 -9
  251. data/spec/functional/resource/yum_package_spec.rb +1 -17
  252. data/spec/functional/resource/zypper_package_spec.rb +12 -10
  253. data/spec/functional/shell_spec.rb +1 -2
  254. data/spec/functional/version_spec.rb +1 -1
  255. data/spec/functional/win32/registry_spec.rb +0 -3
  256. data/spec/integration/client/client_spec.rb +82 -3
  257. data/spec/integration/client/exit_code_spec.rb +1 -1
  258. data/spec/integration/client/ipv6_spec.rb +1 -1
  259. data/spec/integration/compliance/compliance_spec.rb +1 -1
  260. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  261. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  262. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  263. data/spec/integration/recipes/notifies_spec.rb +1 -1
  264. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  265. data/spec/integration/recipes/remote_directory.rb +1 -1
  266. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  267. data/spec/integration/recipes/use_partial_spec.rb +2 -1
  268. data/spec/integration/solo/solo_spec.rb +2 -2
  269. data/spec/spec_helper.rb +1 -5
  270. data/spec/support/platform_helpers.rb +0 -4
  271. data/spec/support/ruby_installer.rb +1 -1
  272. data/spec/support/shared/functional/windows_script.rb +2 -2
  273. data/spec/unit/application/client_spec.rb +0 -10
  274. data/spec/unit/client_spec.rb +70 -2
  275. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
  276. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  277. data/spec/unit/http/authenticator_spec.rb +68 -0
  278. data/spec/unit/mixin/checksum_spec.rb +0 -28
  279. data/spec/unit/mixin/homebrew_user_spec.rb +7 -30
  280. data/spec/unit/mixin/openssl_helper_spec.rb +1 -1
  281. data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
  282. data/spec/unit/platform/query_helpers_spec.rb +2 -17
  283. data/spec/unit/provider/cron_spec.rb +0 -34
  284. data/spec/unit/provider/http_request_spec.rb +60 -72
  285. data/spec/unit/provider/mount/linux_spec.rb +10 -0
  286. data/spec/unit/provider/package/chocolatey_spec.rb +3 -20
  287. data/spec/unit/provider/package/rubygems_spec.rb +1 -1
  288. data/spec/unit/provider/package/zypper_spec.rb +32 -0
  289. data/spec/unit/provider/user/linux_spec.rb +51 -11
  290. data/spec/unit/provider/user_spec.rb +24 -6
  291. data/spec/unit/resource/archive_file_spec.rb +1 -1
  292. data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
  293. data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
  294. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
  295. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +2 -2
  296. data/spec/unit/resource/cron_d_spec.rb +37 -1
  297. data/spec/unit/resource/macos_user_defaults_spec.rb +4 -4
  298. data/spec/unit/resource/rest_resource_spec.rb +381 -0
  299. data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
  300. data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
  301. data/spec/unit/resource/selinux_install_spec.rb +60 -0
  302. data/spec/unit/resource/selinux_module_spec.rb +55 -0
  303. data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
  304. data/spec/unit/resource/selinux_port_spec.rb +42 -0
  305. data/spec/unit/resource/selinux_state_spec.rb +46 -0
  306. data/spec/unit/resource/sysctl_spec.rb +2 -2
  307. data/spec/unit/resource/user/linux_user_spec.rb +42 -0
  308. data/spec/unit/resource_spec.rb +8 -2
  309. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
  310. data/tasks/rspec.rb +1 -1
  311. metadata +106 -55
  312. data/spec/functional/assets/yumrepo-empty/repodata/01a3b-filelists.sqlite.bz2 +0 -0
  313. data/spec/functional/assets/yumrepo-empty/repodata/401dc-filelists.xml.gz +0 -0
  314. data/spec/functional/assets/yumrepo-empty/repodata/5dc1e-primary.sqlite.bz2 +0 -0
  315. data/spec/functional/assets/yumrepo-empty/repodata/6bf96-other.xml.gz +0 -0
  316. data/spec/functional/assets/yumrepo-empty/repodata/7c365-other.sqlite.bz2 +0 -0
  317. data/spec/functional/assets/yumrepo-empty/repodata/dabe2-primary.xml.gz +0 -0
  318. data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +0 -55
  319. data/spec/integration/client/fips_spec.rb +0 -29
  320. data/spec/integration/client/open_ssl_spec.rb +0 -20
  321. /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.0.nupkg → test-A.1.0.nupkg} +0 -0
  322. /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.0.nupkg → test-A.1.5.nupkg} +0 -0
  323. /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.0.nupkg → test-A.2.0.nupkg} +0 -0
  324. /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.0.nupkg → test-B.1.0.nupkg} +0 -0
  325. /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
  326. /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
  327. /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
  328. /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
  329. /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
  330. /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
@@ -92,7 +92,7 @@ describe Chef::Mixin::OpenSSLHelper do
92
92
 
93
93
  context "When the dhparam.pem file does exist, and does contain a vaild dhparam key" do
94
94
  it "returns true" do
95
- @dhparam_file.puts(::OpenSSL::PKey::DH.new(1024).to_pem)
95
+ @dhparam_file.puts(::OpenSSL::PKey::DH.new(256).to_pem) # this is 256 to speed up specs
96
96
  @dhparam_file.close
97
97
  expect(instance.dhparam_pem_valid?(@dhparam_file.path)).to be_truthy
98
98
  end
@@ -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
@@ -769,40 +769,6 @@ 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
- CRONTAB
783
-
784
- @provider.run_action(:create)
785
- expect(@new_resource).not_to be_updated_by_last_action
786
- end
787
- end
788
-
789
- context "when strings are provided to the resource to express time values" do
790
- it "should not report any difference" do
791
- @new_resource.minute("1")
792
- @new_resource.hour("1")
793
- @new_resource.day("1")
794
- @new_resource.month("1")
795
- @new_resource.weekday("1")
796
- allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
797
- # Chef Name: cronhole some stuff
798
- 1 1 1 1 1 /bin/true
799
- CRONTAB
800
-
801
- @provider.run_action(:create)
802
- expect(@new_resource).not_to be_updated_by_last_action
803
- end
804
- end
805
-
806
772
  context "when environment variable is used" do
807
773
  before :each do
808
774
  @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
@@ -47,11 +47,6 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
47
47
  allow(provider).to receive(:choco_exe).and_return(choco_exe)
48
48
  local_list_obj = double(stdout: local_list_stdout)
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
- allow(provider).to receive(:powershell_exec!).with("#{choco_exe} --version").and_return(double(result: "2.1.0"))
51
- end
52
-
53
- after(:each) do
54
- provider.instance_variable_set(:@get_choco_version, nil)
55
50
  end
56
51
 
57
52
  def allow_remote_list(package_names, args = nil)
@@ -66,9 +61,9 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
66
61
  remote_list_obj = double(stdout: remote_list_stdout)
67
62
  package_names.each do |pkg|
68
63
  if args
69
- allow(provider).to receive(:shell_out_compacted!).with(choco_exe, provider.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)
70
65
  else
71
- allow(provider).to receive(:shell_out_compacted!).with(choco_exe, provider.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)
72
67
  end
73
68
  end
74
69
  end
@@ -83,18 +78,6 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
83
78
  end
84
79
  end
85
80
 
86
- describe "choco searches change with the version" do
87
- it "Choco V1 uses List" do
88
- allow(provider).to receive(:powershell_exec!).with("#{choco_exe} --version").and_return(double(result: "1.4.0"))
89
- expect(provider.query_command).to eql("list")
90
- end
91
-
92
- it "Choco V2 uses Search" do
93
- allow(provider).to receive(:powershell_exec!).with("#{choco_exe} --version").and_return(double(result: "2.1.0"))
94
- expect(provider.query_command).to eql("search")
95
- end
96
- end
97
-
98
81
  describe "#candidate_version" do
99
82
  it "should set the candidate_version to the latest version when not pinning" do
100
83
  allow_remote_list(["git"])
@@ -167,7 +150,7 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
167
150
  new_resource.package_name("package-does-not-exist")
168
151
  new_resource.returns([0])
169
152
  allow(provider).to receive(:shell_out_compacted!)
170
- .with(choco_exe, provider.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 })
171
154
  .and_raise(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
172
155
  expect { provider.send(:available_packages) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
173
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")
@@ -178,12 +178,30 @@ describe Chef::Provider::User do
178
178
  end
179
179
  end
180
180
 
181
- it "should fail assertions when ruby-shadow cannot be loaded" do
182
- expect(@provider).to receive(:require).with("shadow") { raise LoadError }
183
- @provider.load_current_resource
184
- @provider.action = :create
185
- @provider.define_resource_requirements
186
- expect { @provider.process_resource_requirements }.to raise_error Chef::Exceptions::MissingLibrary
181
+ context "when ruby-shadow is supported on the platform" do
182
+ before do
183
+ allow(@provider).to receive(:supports_ruby_shadow?).and_return true
184
+ end
185
+ it "should fail assertions when ruby-shadow cannot be loaded" do
186
+ expect(@provider).to receive(:require).with("shadow") { raise LoadError }
187
+ @provider.load_current_resource
188
+ @provider.action = :create
189
+ @provider.define_resource_requirements
190
+ expect { @provider.process_resource_requirements }.to raise_error Chef::Exceptions::MissingLibrary
191
+ end
192
+ end
193
+
194
+ context "when ruby-shadow is not supported on the platform" do
195
+ before do
196
+ allow(@provider).to receive(:supports_ruby_shadow?).and_return false
197
+ end
198
+ it "should not fail any assertions when ruby-shadow cannot be loaded" do
199
+ expect(@provider).to receive(:require).with("shadow") { raise LoadError }
200
+ @provider.load_current_resource
201
+ @provider.action = :create
202
+ @provider.define_resource_requirements
203
+ @provider.process_resource_requirements
204
+ end
187
205
  end
188
206
 
189
207
  end
@@ -29,7 +29,7 @@ rescue LoadError
29
29
  end
30
30
  end
31
31
 
32
- describe Chef::Resource::ArchiveFile, :not_supported_on_aix do
32
+ describe Chef::Resource::ArchiveFile, :not_supported_on_aix, :not_supported_on_windows do
33
33
  let(:node) { Chef::Node.new }
34
34
  let(:events) { Chef::EventDispatch::Dispatcher.new }
35
35
  let(:run_context) { Chef::RunContext.new(node, {}, events) }
@@ -43,6 +43,11 @@ describe Chef::Resource::ChefClientCron do
43
43
  expect { resource.splay("-10") }.to raise_error(Chef::Exceptions::ValidationFailed)
44
44
  end
45
45
 
46
+ it "set splay to 0" do
47
+ resource.splay "0"
48
+ expect(resource.splay).to eql(0)
49
+ end
50
+
46
51
  it "builds a default value for chef_binary_path dist values" do
47
52
  expect(resource.chef_binary_path).to eql("/opt/chef/bin/chef-client")
48
53
  end
@@ -43,6 +43,11 @@ describe Chef::Resource::ChefClientLaunchd do
43
43
  expect { resource.splay("-10") }.to raise_error(Chef::Exceptions::ValidationFailed)
44
44
  end
45
45
 
46
+ it "set splay to 0" do
47
+ resource.splay "0"
48
+ expect(resource.splay).to eql(0)
49
+ end
50
+
46
51
  it "builds a default value for chef_binary_path dist values" do
47
52
  expect(resource.chef_binary_path).to eql("/opt/chef/bin/chef-client")
48
53
  end
@@ -43,6 +43,11 @@ describe Chef::Resource::ChefClientScheduledTask do
43
43
  expect { resource.splay("-10") }.to raise_error(Chef::Exceptions::ValidationFailed)
44
44
  end
45
45
 
46
+ it "set splay to 0" do
47
+ resource.splay "0"
48
+ expect(resource.splay).to eql(0)
49
+ end
50
+
46
51
  it "coerces frequency_modifier to an Integer" do
47
52
  resource.frequency_modifier "10"
48
53
  expect(resource.frequency_modifier).to eql(10)
@@ -102,7 +102,7 @@ describe Chef::Resource::ChefClientSystemdTimer do
102
102
 
103
103
  it "sets CPUQuota if cpu_quota property is set" do
104
104
  resource.cpu_quota 50
105
- expect(provider.service_content["Service"]["CPUQuota"]).to eq("50%")
105
+ expect(provider.service_content["Service"]["CPUQuota"]).to eq(50)
106
106
  end
107
107
  end
108
- end
108
+ end