chef 16.1.0-universal-mingw32 → 16.3.38-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (424) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -7
  3. data/README.md +3 -3
  4. data/Rakefile +4 -3
  5. data/chef-universal-mingw32.gemspec +2 -2
  6. data/chef.gemspec +7 -6
  7. data/distro/powershell/chef/chef.psm1 +3 -3
  8. data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
  9. data/lib/chef/application.rb +12 -0
  10. data/lib/chef/application/apply.rb +2 -1
  11. data/lib/chef/application/base.rb +1 -1
  12. data/lib/chef/application/client.rb +1 -1
  13. data/lib/chef/application/windows_service_manager.rb +1 -1
  14. data/lib/chef/{whitelist.rb → attribute_allowlist.rb} +11 -11
  15. data/lib/chef/{blacklist.rb → attribute_blocklist.rb} +9 -9
  16. data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
  17. data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -2
  18. data/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb +1 -1
  19. data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +2 -2
  20. data/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +1 -5
  21. data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
  22. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  23. data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +2 -2
  24. data/lib/chef/chef_fs/path_utils.rb +4 -4
  25. data/lib/chef/client.rb +3 -3
  26. data/lib/chef/cookbook/chefignore.rb +1 -1
  27. data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
  28. data/lib/chef/cookbook/metadata.rb +2 -2
  29. data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
  30. data/lib/chef/cookbook/syntax_check.rb +1 -2
  31. data/lib/chef/cookbook_loader.rb +16 -30
  32. data/lib/chef/cookbook_manifest.rb +1 -1
  33. data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
  34. data/lib/chef/cookbook_version.rb +4 -4
  35. data/lib/chef/data_bag.rb +5 -6
  36. data/lib/chef/data_collector.rb +1 -1
  37. data/lib/chef/data_collector/error_handlers.rb +1 -1
  38. data/lib/chef/decorator/lazy_array.rb +2 -2
  39. data/lib/chef/deprecated.rb +12 -0
  40. data/lib/chef/digester.rb +5 -4
  41. data/lib/chef/dsl/declare_resource.rb +1 -1
  42. data/lib/chef/dsl/platform_introspection.rb +2 -0
  43. data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
  44. data/lib/chef/encrypted_data_bag_item/encryptor.rb +1 -1
  45. data/lib/chef/environment.rb +1 -2
  46. data/lib/chef/exceptions.rb +3 -0
  47. data/lib/chef/file_access_control.rb +1 -1
  48. data/lib/chef/file_access_control/windows.rb +2 -2
  49. data/lib/chef/file_content_management/deploy/mv_unix.rb +1 -1
  50. data/lib/chef/formatters/base.rb +1 -1
  51. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +1 -1
  52. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +3 -3
  53. data/lib/chef/http.rb +19 -4
  54. data/lib/chef/http/authenticator.rb +1 -1
  55. data/lib/chef/http/decompressor.rb +1 -1
  56. data/lib/chef/http/http_request.rb +1 -1
  57. data/lib/chef/http/json_output.rb +1 -1
  58. data/lib/chef/http/ssl_policies.rb +18 -0
  59. data/lib/chef/json_compat.rb +1 -1
  60. data/lib/chef/key.rb +1 -1
  61. data/lib/chef/knife.rb +6 -6
  62. data/lib/chef/knife/bootstrap.rb +24 -24
  63. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -1
  64. data/lib/chef/knife/bootstrap/client_builder.rb +1 -1
  65. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  66. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +3 -1
  67. data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
  68. data/lib/chef/knife/client_bulk_delete.rb +1 -1
  69. data/lib/chef/knife/config_get.rb +2 -1
  70. data/lib/chef/knife/config_list_profiles.rb +4 -1
  71. data/lib/chef/knife/config_use_profile.rb +15 -5
  72. data/lib/chef/knife/configure.rb +1 -1
  73. data/lib/chef/knife/cookbook_delete.rb +1 -1
  74. data/lib/chef/knife/cookbook_upload.rb +6 -14
  75. data/lib/chef/knife/core/bootstrap_context.rb +1 -1
  76. data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
  77. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  78. data/lib/chef/knife/core/hashed_command_loader.rb +2 -1
  79. data/lib/chef/knife/core/node_presenter.rb +1 -1
  80. data/lib/chef/knife/core/status_presenter.rb +1 -1
  81. data/lib/chef/knife/core/subcommand_loader.rb +21 -2
  82. data/lib/chef/knife/core/ui.rb +8 -2
  83. data/lib/chef/knife/core/windows_bootstrap_context.rb +18 -4
  84. data/lib/chef/knife/data_bag_create.rb +1 -1
  85. data/lib/chef/knife/key_create_base.rb +1 -1
  86. data/lib/chef/knife/key_edit_base.rb +1 -1
  87. data/lib/chef/knife/node_bulk_delete.rb +1 -1
  88. data/lib/chef/knife/node_run_list_remove.rb +1 -1
  89. data/lib/chef/knife/rehash.rb +3 -21
  90. data/lib/chef/knife/role_bulk_delete.rb +1 -1
  91. data/lib/chef/knife/ssh.rb +7 -3
  92. data/lib/chef/knife/supermarket_share.rb +1 -1
  93. data/lib/chef/knife/supermarket_unshare.rb +1 -1
  94. data/lib/chef/log.rb +8 -3
  95. data/lib/chef/mixin/api_version_request_handling.rb +1 -1
  96. data/lib/chef/mixin/checksum.rb +0 -1
  97. data/{spec/functional/resource/base.rb → lib/chef/mixin/chef_utils_wiring.rb} +24 -12
  98. data/{spec/unit/log_spec.rb → lib/chef/mixin/default_paths.rb} +13 -5
  99. data/lib/chef/mixin/openssl_helper.rb +31 -9
  100. data/lib/chef/mixin/path_sanity.rb +5 -4
  101. data/lib/chef/mixin/properties.rb +2 -2
  102. data/lib/chef/mixin/securable.rb +2 -2
  103. data/lib/chef/mixin/shell_out.rb +4 -188
  104. data/lib/chef/mixin/template.rb +1 -0
  105. data/lib/chef/mixin/which.rb +6 -3
  106. data/lib/chef/mixins.rb +1 -0
  107. data/lib/chef/node.rb +36 -12
  108. data/lib/chef/node/attribute.rb +2 -2
  109. data/lib/chef/node/immutable_collections.rb +1 -1
  110. data/lib/chef/node_map.rb +21 -18
  111. data/lib/chef/platform/service_helpers.rb +31 -28
  112. data/lib/chef/policy_builder/policyfile.rb +1 -1
  113. data/lib/chef/powershell.rb +1 -1
  114. data/lib/chef/property.rb +2 -2
  115. data/lib/chef/provider.rb +3 -3
  116. data/lib/chef/provider/batch.rb +3 -10
  117. data/lib/chef/provider/cron.rb +2 -14
  118. data/lib/chef/provider/directory.rb +1 -1
  119. data/lib/chef/provider/execute.rb +2 -1
  120. data/lib/chef/provider/file.rb +1 -1
  121. data/lib/chef/provider/git.rb +12 -4
  122. data/lib/chef/provider/group/dscl.rb +2 -2
  123. data/lib/chef/provider/group/windows.rb +1 -1
  124. data/lib/chef/provider/ifconfig.rb +7 -7
  125. data/lib/chef/provider/mount/aix.rb +1 -1
  126. data/lib/chef/provider/mount/solaris.rb +0 -1
  127. data/lib/chef/provider/mount/windows.rb +2 -2
  128. data/lib/chef/provider/noop.rb +1 -1
  129. data/lib/chef/provider/package/chocolatey.rb +1 -1
  130. data/lib/chef/provider/package/dpkg.rb +1 -1
  131. data/lib/chef/provider/package/openbsd.rb +1 -1
  132. data/lib/chef/provider/package/portage.rb +3 -2
  133. data/lib/chef/provider/package/powershell.rb +6 -2
  134. data/lib/chef/provider/package/rubygems.rb +3 -3
  135. data/lib/chef/provider/package/snap.rb +97 -29
  136. data/lib/chef/provider/package/windows.rb +11 -6
  137. data/lib/chef/provider/package/windows/msi.rb +3 -3
  138. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
  139. data/lib/chef/provider/package/yum.rb +1 -1
  140. data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
  141. data/lib/chef/provider/package/zypper.rb +0 -1
  142. data/lib/chef/provider/powershell_script.rb +10 -14
  143. data/lib/chef/provider/remote_directory.rb +2 -2
  144. data/lib/chef/provider/remote_file/http.rb +4 -1
  145. data/lib/chef/provider/script.rb +4 -75
  146. data/lib/chef/provider/service.rb +2 -2
  147. data/lib/chef/provider/service/arch.rb +2 -2
  148. data/lib/chef/provider/service/debian.rb +2 -2
  149. data/lib/chef/provider/service/openbsd.rb +4 -4
  150. data/lib/chef/provider/service/redhat.rb +1 -1
  151. data/lib/chef/provider/service/upstart.rb +1 -1
  152. data/lib/chef/provider/service/windows.rb +1 -1
  153. data/lib/chef/provider/subversion.rb +2 -2
  154. data/lib/chef/provider/user/aix.rb +1 -1
  155. data/lib/chef/provider/user/dscl.rb +6 -6
  156. data/lib/chef/provider/user/linux.rb +3 -3
  157. data/lib/chef/provider/user/mac.rb +15 -11
  158. data/lib/chef/provider/windows_script.rb +87 -25
  159. data/lib/chef/provider/windows_task.rb +4 -2
  160. data/lib/chef/provider/yum_repository.rb +1 -1
  161. data/lib/chef/provider/zypper_repository.rb +31 -11
  162. data/lib/chef/resource.rb +27 -14
  163. data/lib/chef/resource/alternatives.rb +1 -1
  164. data/lib/chef/resource/apt_package.rb +1 -1
  165. data/lib/chef/resource/archive_file.rb +28 -8
  166. data/lib/chef/resource/bash.rb +0 -1
  167. data/lib/chef/resource/batch.rb +4 -2
  168. data/lib/chef/resource/build_essential.rb +2 -2
  169. data/lib/chef/resource/chef_client_scheduled_task.rb +14 -2
  170. data/lib/chef/resource/chef_gem.rb +57 -21
  171. data/lib/chef/resource/chef_handler.rb +2 -2
  172. data/lib/chef/resource/chef_vault_secret.rb +1 -1
  173. data/lib/chef/resource/chocolatey_feature.rb +1 -2
  174. data/lib/chef/resource/cron/_cron_shared.rb +98 -0
  175. data/lib/chef/resource/cron/cron.rb +46 -0
  176. data/lib/chef/resource/{cron_d.rb → cron/cron_d.rb} +7 -87
  177. data/lib/chef/resource/cron_access.rb +13 -5
  178. data/lib/chef/resource/csh.rb +0 -1
  179. data/lib/chef/resource/dmg_package.rb +2 -2
  180. data/lib/chef/resource/execute.rb +480 -10
  181. data/lib/chef/resource/file.rb +10 -8
  182. data/lib/chef/resource/freebsd_package.rb +1 -1
  183. data/lib/chef/resource/gem_package.rb +35 -2
  184. data/lib/chef/resource/helpers/cron_validations.rb +6 -3
  185. data/lib/chef/resource/homebrew_package.rb +30 -1
  186. data/lib/chef/resource/homebrew_update.rb +107 -0
  187. data/lib/chef/resource/hostname.rb +7 -20
  188. data/lib/chef/resource/kernel_module.rb +14 -1
  189. data/lib/chef/resource/launchd.rb +1 -1
  190. data/lib/chef/resource/locale.rb +3 -3
  191. data/lib/chef/resource/lwrp_base.rb +1 -0
  192. data/lib/chef/resource/macos_userdefaults.rb +176 -56
  193. data/lib/chef/resource/mount.rb +1 -1
  194. data/lib/chef/resource/openssl_x509_certificate.rb +11 -14
  195. data/lib/chef/resource/openssl_x509_crl.rb +1 -2
  196. data/lib/chef/resource/perl.rb +0 -1
  197. data/lib/chef/resource/plist.rb +23 -4
  198. data/lib/chef/resource/powershell_script.rb +4 -2
  199. data/lib/chef/resource/python.rb +0 -1
  200. data/lib/chef/resource/remote_file.rb +26 -10
  201. data/lib/chef/resource/ruby.rb +0 -1
  202. data/lib/chef/resource/scm/git.rb +1 -1
  203. data/lib/chef/resource/service.rb +2 -2
  204. data/lib/chef/resource/ssh_known_hosts_entry.rb +16 -1
  205. data/lib/chef/resource/sudo.rb +30 -3
  206. data/lib/chef/resource/swap_file.rb +17 -0
  207. data/lib/chef/resource/template.rb +1 -1
  208. data/lib/chef/resource/timezone.rb +15 -0
  209. data/lib/chef/resource/user_ulimit.rb +1 -1
  210. data/lib/chef/resource/windows_ad_join.rb +30 -1
  211. data/lib/chef/resource/windows_audit_policy.rb +227 -0
  212. data/lib/chef/resource/windows_auto_run.rb +11 -0
  213. data/lib/chef/resource/windows_certificate.rb +27 -1
  214. data/lib/chef/resource/windows_dfs_server.rb +1 -1
  215. data/lib/chef/resource/windows_dns_record.rb +17 -0
  216. data/lib/chef/resource/windows_firewall_profile.rb +197 -0
  217. data/lib/chef/resource/windows_font.rb +3 -3
  218. data/lib/chef/resource/windows_package.rb +1 -1
  219. data/lib/chef/resource/windows_pagefile.rb +2 -2
  220. data/lib/chef/resource/windows_script.rb +2 -16
  221. data/lib/chef/resource/windows_security_policy.rb +67 -36
  222. data/lib/chef/resource/windows_shortcut.rb +1 -2
  223. data/lib/chef/resource/windows_task.rb +10 -10
  224. data/lib/chef/resource/windows_user_privilege.rb +33 -10
  225. data/lib/chef/resource/yum_repository.rb +9 -9
  226. data/lib/chef/resource_inspector.rb +11 -4
  227. data/lib/chef/resources.rb +5 -2
  228. data/lib/chef/role.rb +1 -2
  229. data/lib/chef/run_context/cookbook_compiler.rb +1 -1
  230. data/lib/chef/search/query.rb +1 -1
  231. data/lib/chef/shell/ext.rb +1 -1
  232. data/lib/chef/shell/shell_session.rb +2 -0
  233. data/lib/chef/util/diff.rb +2 -3
  234. data/lib/chef/util/windows/net_user.rb +1 -1
  235. data/lib/chef/util/windows/volume.rb +1 -1
  236. data/lib/chef/version.rb +2 -2
  237. data/lib/chef/win32/api.rb +2 -2
  238. data/lib/chef/win32/api/error.rb +3 -1
  239. data/lib/chef/win32/api/file.rb +1 -1
  240. data/lib/chef/win32/api/net.rb +1 -0
  241. data/lib/chef/win32/file.rb +1 -1
  242. data/lib/chef/win32/mutex.rb +1 -1
  243. data/lib/chef/win32/net.rb +1 -0
  244. data/lib/chef/win32/registry.rb +3 -4
  245. data/lib/chef/win32/security.rb +1 -1
  246. data/lib/chef/win32/security/sid.rb +4 -4
  247. data/spec/data/lwrp/providers/buck_passer.rb +1 -1
  248. data/spec/data/lwrp/providers/buck_passer_2.rb +1 -1
  249. data/spec/data/lwrp/providers/embedded_resource_accesses_providers_scope.rb +1 -1
  250. data/spec/functional/knife/configure_spec.rb +1 -1
  251. data/spec/functional/knife/ssh_spec.rb +5 -16
  252. data/spec/functional/resource/aix_service_spec.rb +9 -2
  253. data/spec/functional/resource/aixinit_service_spec.rb +1 -2
  254. data/spec/functional/resource/apt_package_spec.rb +0 -1
  255. data/spec/functional/resource/bash_spec.rb +3 -2
  256. data/spec/functional/resource/bff_spec.rb +1 -1
  257. data/spec/functional/resource/chocolatey_package_spec.rb +4 -0
  258. data/spec/functional/resource/cron_spec.rb +20 -2
  259. data/spec/functional/resource/dnf_package_spec.rb +6 -3
  260. data/spec/functional/resource/execute_spec.rb +1 -1
  261. data/spec/functional/resource/git_spec.rb +29 -7
  262. data/spec/functional/resource/group_spec.rb +15 -3
  263. data/spec/functional/resource/ifconfig_spec.rb +9 -1
  264. data/spec/functional/resource/insserv_spec.rb +3 -3
  265. data/spec/functional/resource/link_spec.rb +2 -5
  266. data/spec/functional/resource/mount_spec.rb +9 -1
  267. data/spec/functional/resource/msu_package_spec.rb +9 -3
  268. data/spec/functional/resource/powershell_script_spec.rb +4 -4
  269. data/spec/functional/resource/remote_file_spec.rb +9 -15
  270. data/spec/functional/resource/rpm_spec.rb +1 -1
  271. data/spec/functional/resource/timezone_spec.rb +2 -0
  272. data/spec/functional/resource/windows_package_spec.rb +0 -1
  273. data/spec/functional/resource/windows_path_spec.rb +4 -0
  274. data/spec/functional/resource/windows_security_policy_spec.rb +0 -1
  275. data/spec/functional/resource/windows_service_spec.rb +4 -0
  276. data/spec/functional/resource/windows_task_spec.rb +16 -15
  277. data/spec/functional/resource/windows_user_privilege_spec.rb +1 -2
  278. data/spec/functional/resource/yum_package_spec.rb +4 -1
  279. data/spec/functional/resource/zypper_package_spec.rb +4 -1
  280. data/spec/functional/run_lock_spec.rb +2 -1
  281. data/spec/functional/shell_spec.rb +5 -6
  282. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  283. data/spec/functional/version_spec.rb +1 -1
  284. data/spec/functional/win32/crypto_spec.rb +1 -1
  285. data/spec/integration/knife/config_list_profiles_spec.rb +30 -2
  286. data/spec/integration/knife/config_use_profile_spec.rb +55 -2
  287. data/spec/integration/knife/cookbook_upload_spec.rb +28 -1
  288. data/spec/integration/knife/data_bag_from_file_spec.rb +1 -1
  289. data/spec/integration/knife/environment_from_file_spec.rb +1 -1
  290. data/spec/integration/knife/node_from_file_spec.rb +1 -1
  291. data/spec/integration/knife/role_from_file_spec.rb +1 -1
  292. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  293. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  294. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  295. data/spec/integration/recipes/notifies_spec.rb +1 -1
  296. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  297. data/spec/integration/recipes/recipe_dsl_spec.rb +5 -1
  298. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
  299. data/spec/integration/recipes/resource_load_spec.rb +4 -2
  300. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  301. data/spec/integration/recipes/use_partial_spec.rb +1 -1
  302. data/spec/scripts/ssl-serve.rb +1 -1
  303. data/spec/spec_helper.rb +10 -4
  304. data/spec/support/chef_helpers.rb +2 -21
  305. data/spec/support/platform_helpers.rb +1 -3
  306. data/spec/support/platforms/win32/spec_service.rb +1 -1
  307. data/spec/support/shared/functional/execute_resource.rb +1 -1
  308. data/spec/support/shared/functional/file_resource.rb +0 -1
  309. data/spec/support/shared/functional/securable_resource.rb +1 -2
  310. data/spec/support/shared/functional/securable_resource_with_reporting.rb +0 -1
  311. data/spec/support/shared/functional/windows_script.rb +3 -3
  312. data/spec/support/shared/integration/knife_support.rb +2 -9
  313. data/spec/support/shared/unit/application_dot_d.rb +0 -1
  314. data/spec/support/shared/unit/execute_resource.rb +1 -1
  315. data/spec/support/shared/unit/provider/file.rb +12 -8
  316. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +4 -4
  317. data/spec/unit/application/solo_spec.rb +4 -2
  318. data/spec/unit/application_spec.rb +11 -2
  319. data/spec/unit/chef_fs/config_spec.rb +2 -2
  320. data/spec/unit/chef_fs/diff_spec.rb +8 -8
  321. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
  322. data/spec/unit/chef_fs/{parallelizer.rb → parallelizer_spec.rb} +1 -1
  323. data/spec/unit/client_spec.rb +4 -1
  324. data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
  325. data/spec/unit/cookbook/synchronizer_spec.rb +26 -24
  326. data/spec/unit/data_bag_spec.rb +6 -3
  327. data/spec/unit/data_collector_spec.rb +1 -1
  328. data/spec/unit/decorator_spec.rb +23 -23
  329. data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
  330. data/spec/unit/environment_spec.rb +5 -1
  331. data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
  332. data/spec/unit/guard_interpreter_spec.rb +1 -1
  333. data/spec/unit/http/api_versions_spec.rb +1 -1
  334. data/spec/unit/http/ssl_policies_spec.rb +20 -0
  335. data/spec/unit/json_compat_spec.rb +1 -1
  336. data/spec/unit/knife/bootstrap_spec.rb +5 -8
  337. data/spec/unit/knife/cookbook_download_spec.rb +2 -2
  338. data/spec/unit/knife/cookbook_show_spec.rb +6 -7
  339. data/spec/unit/knife/cookbook_upload_spec.rb +7 -10
  340. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +7 -1
  341. data/spec/unit/knife/data_bag_edit_spec.rb +1 -1
  342. data/spec/unit/log/syslog_spec.rb +6 -10
  343. data/spec/unit/log/winevt_spec.rb +21 -13
  344. data/spec/unit/lwrp_spec.rb +9 -6
  345. data/spec/unit/mixin/{path_sanity_spec.rb → default_paths_spec.rb} +14 -14
  346. data/spec/unit/mixin/openssl_helper_spec.rb +4 -4
  347. data/spec/unit/mixin/powershell_exec_spec.rb +1 -1
  348. data/spec/unit/mixin/powershell_out_spec.rb +2 -4
  349. data/spec/unit/mixin/powershell_type_coercions_spec.rb +1 -1
  350. data/spec/unit/mixin/securable_spec.rb +0 -1
  351. data/spec/unit/mixin/shell_out_spec.rb +25 -26
  352. data/spec/unit/mixin/subclass_directive_spec.rb +2 -2
  353. data/spec/unit/mixin/unformatter_spec.rb +2 -2
  354. data/spec/unit/mixin/uris_spec.rb +1 -1
  355. data/spec/unit/mixin/user_context_spec.rb +1 -9
  356. data/spec/unit/mixin/which.rb +8 -0
  357. data/spec/unit/node/attribute_spec.rb +1 -1
  358. data/spec/unit/node_spec.rb +98 -11
  359. data/spec/unit/property_spec.rb +6 -6
  360. data/spec/unit/provider/batch_spec.rb +130 -0
  361. data/spec/unit/provider/cron/unix_spec.rb +1 -1
  362. data/spec/unit/provider/cron_spec.rb +9 -49
  363. data/spec/unit/provider/dsc_resource_spec.rb +22 -38
  364. data/spec/unit/provider/dsc_script_spec.rb +10 -10
  365. data/spec/unit/provider/execute_spec.rb +1 -8
  366. data/spec/unit/provider/git_spec.rb +3 -3
  367. data/spec/unit/provider/group/groupadd_spec.rb +1 -1
  368. data/spec/unit/provider/ifconfig_spec.rb +0 -1
  369. data/spec/unit/provider/mdadm_spec.rb +1 -3
  370. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  371. data/spec/unit/provider/package/openbsd_spec.rb +1 -1
  372. data/spec/unit/provider/package/pacman_spec.rb +17 -20
  373. data/spec/unit/provider/package/portage_spec.rb +2 -2
  374. data/spec/unit/provider/package/powershell_spec.rb +96 -87
  375. data/spec/unit/provider/package/rubygems_spec.rb +5 -10
  376. data/spec/unit/provider/package/smartos_spec.rb +1 -1
  377. data/spec/unit/provider/package/snap_spec.rb +1 -1
  378. data/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb +3 -3
  379. data/spec/unit/provider/package/windows_spec.rb +30 -53
  380. data/spec/unit/provider/powershell_script_spec.rb +3 -45
  381. data/spec/unit/provider/script_spec.rb +20 -110
  382. data/spec/unit/provider/service/redhat_spec.rb +1 -1
  383. data/spec/unit/provider/service/windows_spec.rb +2 -6
  384. data/spec/unit/provider/systemd_unit_spec.rb +28 -24
  385. data/spec/unit/provider/user/dscl_spec.rb +2 -2
  386. data/spec/unit/provider/windows_env_spec.rb +5 -4
  387. data/spec/unit/provider/zypper_repository_spec.rb +60 -10
  388. data/spec/unit/provider_spec.rb +1 -0
  389. data/spec/unit/resource/archive_file_spec.rb +11 -2
  390. data/spec/unit/resource/chef_client_cron_spec.rb +23 -7
  391. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +17 -7
  392. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +7 -4
  393. data/spec/unit/resource/cron_spec.rb +2 -2
  394. data/spec/unit/resource/execute_spec.rb +10 -0
  395. data/spec/unit/resource/file/verification_spec.rb +2 -1
  396. data/spec/unit/resource/helpers/cron_validations_spec.rb +5 -1
  397. data/spec/unit/resource/homebrew_update_spec.rb +30 -0
  398. data/spec/unit/resource/macos_user_defaults_spec.rb +103 -2
  399. data/spec/unit/resource/powershell_script_spec.rb +10 -15
  400. data/spec/unit/resource/timezone_spec.rb +1 -1
  401. data/spec/unit/resource/windows_audit_policy_spec.rb +64 -0
  402. data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
  403. data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
  404. data/spec/unit/resource/windows_firewall_profile_spec.rb +77 -0
  405. data/spec/unit/resource/windows_package_spec.rb +1 -0
  406. data/spec/unit/resource/windows_task_spec.rb +1 -1
  407. data/spec/unit/resource/windows_uac_spec.rb +2 -2
  408. data/spec/unit/resource/yum_repository_spec.rb +21 -21
  409. data/spec/unit/resource_reporter_spec.rb +1 -1
  410. data/spec/unit/resource_spec.rb +84 -1
  411. data/spec/unit/role_spec.rb +23 -21
  412. data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
  413. data/spec/unit/run_lock_spec.rb +1 -1
  414. data/spec/unit/scan_access_control_spec.rb +1 -1
  415. data/spec/unit/util/backup_spec.rb +1 -1
  416. data/spec/unit/util/diff_spec.rb +1 -15
  417. data/spec/unit/util/dsc/configuration_generator_spec.rb +1 -1
  418. data/spec/unit/util/powershell/ps_credential_spec.rb +2 -2
  419. data/spec/unit/util/selinux_spec.rb +2 -1
  420. data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
  421. data/spec/unit/win32/registry_spec.rb +1 -1
  422. data/spec/unit/win32/security_spec.rb +4 -3
  423. metadata +68 -40
  424. data/lib/chef/resource/cron.rb +0 -157
@@ -20,15 +20,21 @@ require "chef"
20
20
  require "spec_helper"
21
21
 
22
22
  describe Chef::Provider::DscResource do
23
- let (:events) { Chef::EventDispatch::Dispatcher.new }
24
- let (:run_context) { Chef::RunContext.new(node, {}, events) }
25
- let (:resource) { Chef::Resource::DscResource.new("dscresource", run_context) }
26
- let (:provider) do
23
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
24
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
25
+ let(:resource) { Chef::Resource::DscResource.new("dscresource", run_context) }
26
+ let(:provider) do
27
27
  Chef::Provider::DscResource.new(resource, run_context)
28
28
  end
29
29
 
30
+ let(:node) do
31
+ node = Chef::Node.new
32
+ node.automatic[:languages][:powershell][:version] = "5.0.10586.0"
33
+ node
34
+ end
35
+
30
36
  context "when PowerShell does not support Invoke-DscResource" do
31
- let (:node) do
37
+ let(:node) do
32
38
  node = Chef::Node.new
33
39
  node.automatic[:languages][:powershell][:version] = "4.0"
34
40
  node
@@ -45,7 +51,7 @@ describe Chef::Provider::DscResource do
45
51
 
46
52
  context "when RefreshMode is not set to Disabled" do
47
53
  context "and the WMF 5 is a preview release" do
48
- let (:node) do
54
+ let(:node) do
49
55
  node = Chef::Node.new
50
56
  node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
51
57
  node
@@ -58,7 +64,7 @@ describe Chef::Provider::DscResource do
58
64
  end
59
65
  end
60
66
  context "and the WMF is 5 RTM or newer" do
61
- let (:node) do
67
+ let(:node) do
62
68
  node = Chef::Node.new
63
69
  node.automatic[:languages][:powershell][:version] = "5.0.10586.0"
64
70
  node
@@ -74,15 +80,15 @@ describe Chef::Provider::DscResource do
74
80
  end
75
81
 
76
82
  context "when the LCM supports Invoke-DscResource" do
77
- let (:node) do
83
+ let(:node) do
78
84
  node = Chef::Node.new
79
85
  node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
80
86
  node
81
87
  end
82
- let (:resource_result) { double("CmdletResult", return_value: { "InDesiredState" => true }, stream: "description") }
83
- let (:invoke_dsc_resource) { double("cmdlet", run!: resource_result) }
84
- let (:store) { double("ResourceStore", find: resource_records) }
85
- let (:resource_records) { [] }
88
+ let(:resource_result) { double("CmdletResult", return_value: { "InDesiredState" => true }, stream: "description") }
89
+ let(:invoke_dsc_resource) { double("cmdlet", run!: resource_result) }
90
+ let(:store) { double("ResourceStore", find: resource_records) }
91
+ let(:resource_records) { [] }
86
92
 
87
93
  before do
88
94
  allow(Chef::Util::DSC::ResourceStore).to receive(:instance).and_return(store)
@@ -124,7 +130,7 @@ describe Chef::Provider::DscResource do
124
130
  end
125
131
 
126
132
  context "resource name cannot be found" do
127
- let (:resource_records) { [] }
133
+ let(:resource_records) { [] }
128
134
 
129
135
  it "raises ResourceNotFound" do
130
136
  expect { provider.run_action(:run) }.to raise_error(Chef::Exceptions::ResourceNotFound)
@@ -133,7 +139,7 @@ describe Chef::Provider::DscResource do
133
139
 
134
140
  context "resource name is found" do
135
141
  context "no module name for resource found" do
136
- let (:resource_records) { [{}] }
142
+ let(:resource_records) { [{}] }
137
143
 
138
144
  it "returns the default dsc resource module" do
139
145
  expect(Chef::Util::Powershell::Cmdlet).to receive(:new) do |node, cmdlet, format|
@@ -144,7 +150,7 @@ describe Chef::Provider::DscResource do
144
150
  end
145
151
 
146
152
  context "a module name for resource is found" do
147
- let (:resource_records) { [{ "Module" => { "Name" => "ModuleName" } }] }
153
+ let(:resource_records) { [{ "Module" => { "Name" => "ModuleName" } }] }
148
154
 
149
155
  it "returns the default dsc resource module" do
150
156
  expect(Chef::Util::Powershell::Cmdlet).to receive(:new) do |node, cmdlet, format|
@@ -155,7 +161,7 @@ describe Chef::Provider::DscResource do
155
161
  end
156
162
 
157
163
  context "multiple resource are found" do
158
- let (:resource_records) do
164
+ let(:resource_records) do
159
165
  [
160
166
  { "Module" => { "Name" => "ModuleName1", "Version" => "1.0.0.0" } },
161
167
  { "Module" => { "Name" => "ModuleName1", "Version" => "2.0.0.0" } },
@@ -170,10 +176,6 @@ describe Chef::Provider::DscResource do
170
176
  end
171
177
 
172
178
  describe "define_resource_requirements" do
173
- let (:node) do
174
- set_node_object
175
- end
176
-
177
179
  context "module usage is valid" do
178
180
  before do
179
181
  allow(provider).to receive(:module_usage_valid?).and_return(true)
@@ -208,10 +210,6 @@ describe Chef::Provider::DscResource do
208
210
  end
209
211
 
210
212
  describe "module_usage_valid?" do
211
- let (:node) do
212
- set_node_object
213
- end
214
-
215
213
  context "module_name and module_version both are not provided" do
216
214
  before do
217
215
  provider.instance_variable_set(:@module_name, nil)
@@ -262,10 +260,6 @@ describe Chef::Provider::DscResource do
262
260
  end
263
261
 
264
262
  describe "module_info_object" do
265
- let (:node) do
266
- set_node_object
267
- end
268
-
269
263
  context "module_version is not given" do
270
264
  before do
271
265
  provider.instance_variable_set(:@module_version, nil)
@@ -292,10 +286,6 @@ describe Chef::Provider::DscResource do
292
286
  end
293
287
 
294
288
  describe "invoke_resource" do
295
- let (:node) do
296
- set_node_object
297
- end
298
-
299
289
  let(:cmdlet) { double(run!: nil) }
300
290
 
301
291
  before(:each) do
@@ -338,9 +328,3 @@ describe Chef::Provider::DscResource do
338
328
  end
339
329
  end
340
330
  end
341
-
342
- def set_node_object
343
- node = Chef::Node.new
344
- node.automatic[:languages][:powershell][:version] = "5.0.10586.0"
345
- node
346
- end
@@ -23,15 +23,15 @@ require "spec_helper"
23
23
 
24
24
  describe Chef::Provider::DscScript do
25
25
  context "when DSC is available" do
26
- let (:node) do
26
+ let(:node) do
27
27
  node = Chef::Node.new
28
28
  node.automatic[:languages][:powershell][:version] = "4.0"
29
29
  node
30
30
  end
31
- let (:events) { Chef::EventDispatch::Dispatcher.new }
32
- let (:run_context) { Chef::RunContext.new(node, {}, events) }
33
- let (:resource) { Chef::Resource::DscScript.new("script", run_context) }
34
- let (:provider) do
31
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
32
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
33
+ let(:resource) { Chef::Resource::DscScript.new("script", run_context) }
34
+ let(:provider) do
35
35
  Chef::Provider::DscScript.new(resource, run_context)
36
36
  end
37
37
 
@@ -145,11 +145,11 @@ describe Chef::Provider::DscScript do
145
145
  end
146
146
 
147
147
  context "when Dsc is not available" do
148
- let (:node) { Chef::Node.new }
149
- let (:events) { Chef::EventDispatch::Dispatcher.new }
150
- let (:run_context) { Chef::RunContext.new(node, {}, events) }
151
- let (:resource) { Chef::Resource::DscScript.new("script", run_context) }
152
- let (:provider) { Chef::Provider::DscScript.new(resource, run_context) }
148
+ let(:node) { Chef::Node.new }
149
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
150
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
151
+ let(:resource) { Chef::Resource::DscScript.new("script", run_context) }
152
+ let(:provider) { Chef::Provider::DscScript.new(resource, run_context) }
153
153
 
154
154
  describe "action_run" do
155
155
  ["1.0", "2.0", "3.0"].each do |version|
@@ -26,7 +26,7 @@ describe Chef::Provider::Execute do
26
26
  let(:provider) { Chef::Provider::Execute.new(new_resource, run_context) }
27
27
  let(:current_resource) { Chef::Resource::Ifconfig.new("foo_resource", run_context) }
28
28
  # You will be the same object, I promise.
29
- @live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, name: :execute)
29
+ @live_stream = Chef::EventDispatch::EventsOutputStream.new(Chef::EventDispatch::Dispatcher.new, name: :execute)
30
30
 
31
31
  let(:opts) do
32
32
  {
@@ -43,17 +43,10 @@ describe Chef::Provider::Execute do
43
43
  before do
44
44
  allow(Chef::EventDispatch::EventsOutputStream).to receive(:new) { @live_stream }
45
45
  allow(ChefUtils).to receive(:windows?) { false }
46
- @original_log_level = Chef::Log.level
47
46
  Chef::Log.level = :info
48
47
  allow(STDOUT).to receive(:tty?).and_return(false)
49
48
  end
50
49
 
51
- after do
52
- Chef::Log.level = @original_log_level
53
- Chef::Config[:always_stream_execute] = false
54
- Chef::Config[:daemon] = false
55
- end
56
-
57
50
  describe "#initialize" do
58
51
  it "should return a Chef::Provider::Execute provider" do
59
52
  expect(provider.class).to eql(Chef::Provider::Execute)
@@ -293,7 +293,7 @@ describe Chef::Provider::Git do
293
293
  end
294
294
  end
295
295
  context "with a timeout set" do
296
- let (:seconds) { 10 }
296
+ let(:seconds) { 10 }
297
297
  before { @resource.timeout(seconds) }
298
298
  it "clones a repo with amended git options" do
299
299
  expect(@provider).to receive(:shell_out!).with(expected_cmd, default_options.merge(timeout: seconds))
@@ -301,7 +301,7 @@ describe Chef::Provider::Git do
301
301
  end
302
302
  end
303
303
  context "with a specific home" do
304
- let (:override_home) do
304
+ let(:override_home) do
305
305
  { "HOME" => "/home/masterNinja" }
306
306
  end
307
307
  let(:overrided_options) do
@@ -337,7 +337,7 @@ describe Chef::Provider::Git do
337
337
  allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja"))
338
338
  end
339
339
  context "with a specific home" do
340
- let (:override_home) do
340
+ let(:override_home) do
341
341
  { "HOME" => "/home/masterNinja" }
342
342
  end
343
343
  let(:overrided_options) do
@@ -57,7 +57,7 @@ describe Chef::Provider::Group::Groupadd do
57
57
  end
58
58
 
59
59
  it "should set the option for #{property} if the new resources #{property} is not null" do
60
- allow(new_resource).to receive(property).and_return("wowaweea")
60
+ allow(new_resource).to receive(property).and_return("cactus")
61
61
  expect(provider.set_options).to eql([ option, new_resource.send(property), new_resource.group_name])
62
62
  end
63
63
  end
@@ -16,7 +16,6 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- # require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
20
19
  require "spec_helper"
21
20
  require "chef/exceptions"
22
21
 
@@ -22,9 +22,7 @@ require "ostruct"
22
22
  describe Chef::Resource::Mdadm do
23
23
 
24
24
  before(:each) do
25
- @node = Chef::Node.new
26
- @events = Chef::EventDispatch::Dispatcher.new
27
- @run_context = Chef::RunContext.new(@node, {}, @events)
25
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
28
26
  @new_resource = Chef::Resource::Mdadm.new("/dev/md1", run_context)
29
27
  @new_resource.devices ["/dev/sdz1", "/dev/sdz2", "/dev/sdz3"]
30
28
  @provider = @new_resource.provider_for_action(:create)
@@ -22,7 +22,7 @@ require "spec_helper"
22
22
  describe Chef::Provider::Package::Dnf::PythonHelper do
23
23
  let(:helper) { Chef::Provider::Package::Dnf::PythonHelper.instance }
24
24
 
25
- it "propagates stacktraces on stderr from the forked subprocess" do
25
+ it "propagates stacktraces on stderr from the forked subprocess", :rhel do
26
26
  allow(helper).to receive(:dnf_command).and_return("ruby -e 'raise \"your hands in the air\"'")
27
27
  expect { helper.package_query(:whatprovides, "tcpdump") }.to raise_error(/your hands in the air/)
28
28
  end
@@ -27,7 +27,7 @@ describe Chef::Provider::Package::Openbsd do
27
27
  node
28
28
  end
29
29
 
30
- let (:provider) do
30
+ let(:provider) do
31
31
  events = Chef::EventDispatch::Dispatcher.new
32
32
  run_context = Chef::RunContext.new(node, {}, events)
33
33
  Chef::Provider::Package::Openbsd.new(new_resource, run_context)
@@ -17,13 +17,6 @@
17
17
  #
18
18
  require "spec_helper"
19
19
 
20
- def create_provider_for(name)
21
- @new_resource = Chef::Resource::Package.new(name)
22
- provider = Chef::Provider::Package::Pacman.new(@new_resource, @run_context)
23
- allow(provider).to receive(:shell_out_compacted).and_return(@status)
24
- provider
25
- end
26
-
27
20
  RSpec.shared_examples "current_resource" do |pkg, version, candidate|
28
21
  let(:current_resource) { @provider.load_current_resource }
29
22
  before(:each) do
@@ -45,11 +38,23 @@ RSpec.shared_examples "current_resource" do |pkg, version, candidate|
45
38
  end
46
39
 
47
40
  describe Chef::Provider::Package::Pacman do
41
+ def create_provider_for(name)
42
+ new_resource = Chef::Resource::Package.new(name)
43
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
44
+ provider = Chef::Provider::Package::Pacman.new(new_resource, run_context)
45
+
46
+ pacman_out = <<~PACMAN_OUT
47
+ extra nano 3.450-1
48
+ extra emacs 0.12.0-1 [installed]
49
+ core sed 3.234-2 [installed: 3.234-1]
50
+ PACMAN_OUT
51
+
52
+ allow(provider).to receive(:shell_out_compacted).and_return(double(stdout: pacman_out, exitstatus: 0))
53
+ provider
54
+ end
55
+
48
56
  before(:each) do
49
- @node = Chef::Node.new
50
- @events = Chef::EventDispatch::Dispatcher.new
51
- @run_context = Chef::RunContext.new(@node, {}, @events)
52
- @pacman_conf = <<~PACMAN_CONF
57
+ pacman_conf = <<~PACMAN_CONF
53
58
  [options]
54
59
  HoldPkg = pacman glibc
55
60
  Architecture = auto
@@ -68,15 +73,7 @@ describe Chef::Provider::Package::Pacman do
68
73
  PACMAN_CONF
69
74
 
70
75
  allow(::File).to receive(:exist?).with("/etc/pacman.conf").and_return(true)
71
- allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(@pacman_conf)
72
-
73
- pacman_out = <<~PACMAN_OUT
74
- extra nano 3.450-1
75
- extra emacs 0.12.0-1 [installed]
76
- core sed 3.234-2 [installed: 3.234-1]
77
- PACMAN_OUT
78
- @status = double(stdout: pacman_out, exitstatus: 0)
79
-
76
+ allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(pacman_conf)
80
77
  end
81
78
 
82
79
  describe "loading the current resource" do
@@ -118,13 +118,13 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do
118
118
  expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
119
119
  end
120
120
 
121
- it "should find the candidate_version if a category is specifed and there are no duplicates" do
121
+ it "should find the candidate_version if a category is specified and there are no duplicates" do
122
122
  status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0)
123
123
  expect(@provider).to receive(:shell_out_compacted).and_return(status)
124
124
  expect(@provider.candidate_version).to eq("2.16.2")
125
125
  end
126
126
 
127
- it "should find the candidate_version if a category is not specifed and there are no duplicates" do
127
+ it "should find the candidate_version if a category is not specified and there are no duplicates" do
128
128
  status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0)
129
129
  @provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context)
130
130
  expect(@provider).to receive(:shell_out_compacted).and_return(status)
@@ -94,19 +94,19 @@ describe Chef::Provider::Package::Powershell, :windows_only do
94
94
  double("powershell_out", stdout: "5")
95
95
  end
96
96
 
97
- let(:generated_command) { "( Get-Package posh-git -Force -ForceBootstrap ).Version" }
98
- let(:generated_get_cmdlet) { "( Get-Package xNetworking -Force -ForceBootstrap ).Version" }
99
- let(:generated_get_cmdlet_with_version) { "( Get-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
100
- let(:generated_find_cmdlet) { "( Find-Package xNetworking -Force -ForceBootstrap ).Version" }
101
- let(:generated_find_cmdlet_with_version) { "( Find-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
102
- let(:generated_find_cmdlet_with_source) { "( Find-Package xNetworking -Force -ForceBootstrap -Source MyGallery ).Version" }
103
- let(:generated_find_cmdlet_with_source_and_version) { "( Find-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
104
- let(:generated_install_cmdlet) { "( Install-Package xNetworking -Force -ForceBootstrap ).Version" }
105
- let(:generated_install_cmdlet_with_version) { "( Install-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
106
- let(:generated_install_cmdlet_with_source) { "( Install-Package xNetworking -Force -ForceBootstrap -Source MyGallery ).Version" }
107
- let(:generated_install_cmdlet_with_source_and_version) { "( Install-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
108
- let(:generated_uninstall_cmdlet) { "( Uninstall-Package xNetworking -Force -ForceBootstrap ).Version" }
109
- let(:generated_uninstall_cmdlet_with_version) { "( Uninstall-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
97
+ let(:generated_command) { "( Get-Package posh-git -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
98
+ let(:generated_get_cmdlet) { "( Get-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
99
+ let(:generated_get_cmdlet_with_version) { "( Get-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
100
+ let(:generated_find_cmdlet) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
101
+ let(:generated_find_cmdlet_with_version) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
102
+ let(:generated_find_cmdlet_with_source) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version" }
103
+ let(:generated_find_cmdlet_with_source_and_version) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
104
+ let(:generated_install_cmdlet) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
105
+ let(:generated_install_cmdlet_with_version) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
106
+ let(:generated_install_cmdlet_with_source) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version" }
107
+ let(:generated_install_cmdlet_with_source_and_version) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
108
+ let(:generated_uninstall_cmdlet) { "( Uninstall-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
109
+ let(:generated_uninstall_cmdlet_with_version) { "( Uninstall-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
110
110
 
111
111
  describe "#initialize" do
112
112
  it "should return the correct class" do
@@ -117,75 +117,75 @@ describe Chef::Provider::Package::Powershell, :windows_only do
117
117
  describe "#candidate_version" do
118
118
 
119
119
  it "should set the candidate_version to the latest version when not pinning" do
120
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
120
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
121
121
  new_resource.package_name(["xNetworking"])
122
122
  new_resource.version(nil)
123
123
  expect(provider.candidate_version).to eql(["2.12.0.0"])
124
124
  end
125
125
 
126
126
  it "should use the candidate_version from the correct source" do
127
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
127
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
128
128
  new_resource.package_name(["xNetworking"])
129
129
  new_resource.version(nil)
130
130
  new_resource.source("MyGallery")
131
131
  expect(provider.candidate_version).to eql(["2.12.0.0"])
132
132
  end
133
133
 
134
- it "should set the candidate_version to the latest version when not pinning and package name is space seperated" do
135
- allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
134
+ it "should set the candidate_version to the latest version when not pinning and package name is space separated" do
135
+ allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
136
136
  new_resource.package_name(["7-Zip 16.02 (x64)"])
137
137
  new_resource.version(nil)
138
138
  expect(provider.candidate_version).to eql(["16.02"])
139
139
  end
140
140
 
141
141
  it "should set the candidate_version to pinned version if available" do
142
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.0.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0)
142
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.0.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0)
143
143
  new_resource.package_name(["xCertificate"])
144
144
  new_resource.version(["2.0.0.0"])
145
145
  expect(provider.candidate_version).to eql(["2.0.0.0"])
146
146
  end
147
147
 
148
148
  it "should set the candidate_version to nil if there is no candidate" do
149
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
149
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
150
150
  new_resource.package_name(["xCertificate"])
151
151
  expect(provider.candidate_version).to eql([nil])
152
152
  end
153
153
 
154
154
  it "should set the candidate_version correctly when there are two packages to install" do
155
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
156
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
155
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
156
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
157
157
  new_resource.package_name(%w{xCertificate xNetworking})
158
158
  new_resource.version(nil)
159
159
  expect(provider.candidate_version).to eql(["2.1.0.0", "2.12.0.0"])
160
160
  end
161
161
 
162
162
  it "should set the candidate_version correctly when only the first is installable" do
163
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
164
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
163
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
164
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
165
165
  new_resource.package_name(%w{xCertificate xNetworking})
166
166
  new_resource.version(nil)
167
167
  expect(provider.candidate_version).to eql(["2.1.0.0", nil])
168
168
  end
169
169
 
170
170
  it "should set the candidate_version correctly when only the last is installable" do
171
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
172
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
171
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
172
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
173
173
  new_resource.package_name(%w{xCertificate xNetworking})
174
174
  new_resource.version(nil)
175
175
  expect(provider.candidate_version).to eql([nil, "2.12.0.0"])
176
176
  end
177
177
 
178
178
  it "should set the candidate_version correctly when neither are is installable and version is passed as nil array" do
179
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
180
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
179
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
180
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
181
181
  new_resource.package_name(%w{xNetworking xCertificate})
182
182
  new_resource.version([nil, nil])
183
183
  expect(provider.candidate_version).to eql([nil, nil])
184
184
  end
185
185
 
186
186
  it "should set the candidate_version correctly when neither are is installable and version is not passed" do
187
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
188
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
187
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
188
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
189
189
  new_resource.package_name(%w{xNetworking xCertificate})
190
190
  new_resource.version(nil)
191
191
  expect(provider.candidate_version).to eql([nil, nil])
@@ -284,10 +284,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
284
284
  provider.load_current_resource
285
285
  new_resource.package_name(["xCertificate"])
286
286
  new_resource.version(nil)
287
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
288
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
287
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
288
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
289
289
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
290
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
290
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
291
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
291
292
  provider.run_action(:install)
292
293
  expect(new_resource).to be_updated_by_last_action
293
294
  end
@@ -297,10 +298,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
297
298
  new_resource.package_name(["xCertificate"])
298
299
  new_resource.version(nil)
299
300
  new_resource.source("MyGallery")
300
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
301
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
301
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
302
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
302
303
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
303
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
304
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
305
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
304
306
  provider.run_action(:install)
305
307
  expect(new_resource).to be_updated_by_last_action
306
308
  end
@@ -310,10 +312,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
310
312
  new_resource.package_name(["xCertificate"])
311
313
  new_resource.version(nil)
312
314
  new_resource.skip_publisher_check(true)
313
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
314
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
315
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
316
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
315
317
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
316
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { timeout: new_resource.timeout })
318
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
319
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { timeout: new_resource.timeout })
317
320
  provider.run_action(:install)
318
321
  expect(new_resource).to be_updated_by_last_action
319
322
  end
@@ -322,10 +325,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
322
325
  provider.load_current_resource
323
326
  new_resource.package_name(["7-Zip 16.02 (x64)"])
324
327
  new_resource.version(nil)
325
- allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
326
- allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_not_installed)
328
+ allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
329
+ allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_not_installed)
327
330
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
328
- expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -RequiredVersion 16.02 ).Version", { timeout: new_resource.timeout })
331
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
332
+ expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 16.02 ).Version", { timeout: new_resource.timeout })
329
333
  provider.run_action(:install)
330
334
  expect(new_resource).to be_updated_by_last_action
331
335
  end
@@ -337,10 +341,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
337
341
  provider.load_current_resource
338
342
  new_resource.package_name(["xCertificate"])
339
343
  new_resource.version(nil)
340
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
341
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
344
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
345
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
342
346
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
343
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
347
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
348
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
344
349
  provider.run_action(:install)
345
350
  expect(new_resource).to be_updated_by_last_action
346
351
  end
@@ -349,8 +354,8 @@ describe Chef::Provider::Package::Powershell, :windows_only do
349
354
  it "should not install packages that are up-to-date" do
350
355
  new_resource.package_name(["xCertificate"])
351
356
  new_resource.version(nil)
352
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
353
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
357
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
358
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
354
359
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
355
360
  provider.load_current_resource
356
361
  expect(provider).not_to receive(:install_package)
@@ -361,8 +366,8 @@ describe Chef::Provider::Package::Powershell, :windows_only do
361
366
  it "should not install packages that are up-to-date" do
362
367
  new_resource.package_name(["xNetworking"])
363
368
  new_resource.version(["2.11.0.0"])
364
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
365
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
369
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
370
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
366
371
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
367
372
  provider.load_current_resource
368
373
  expect(provider).not_to receive(:install_package)
@@ -375,13 +380,14 @@ describe Chef::Provider::Package::Powershell, :windows_only do
375
380
  # new_version.resource[0]
376
381
  new_resource.package_name(%w{xCertificate xNetworking})
377
382
  new_resource.version([nil, "2.11.0.0"])
378
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
379
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
380
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
381
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
383
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
384
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
385
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
386
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
382
387
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
383
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
384
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout })
388
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
389
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
390
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout })
385
391
  provider.load_current_resource
386
392
  provider.run_action(:install)
387
393
  expect(new_resource).to be_updated_by_last_action
@@ -390,13 +396,14 @@ describe Chef::Provider::Package::Powershell, :windows_only do
390
396
  it "should split up commands when given two packages, one with a version pin" do
391
397
  new_resource.package_name(%w{xCertificate xNetworking})
392
398
  new_resource.version(["2.1.0.0", nil])
393
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
394
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
395
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
396
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
399
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
400
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
401
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
402
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
397
403
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
398
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
399
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
404
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
405
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
406
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
400
407
 
401
408
  provider.load_current_resource
402
409
  provider.run_action(:install)
@@ -406,13 +413,14 @@ describe Chef::Provider::Package::Powershell, :windows_only do
406
413
  it "should do multipackage installs when given two packages without constraints" do
407
414
  new_resource.package_name(%w{xCertificate xNetworking})
408
415
  new_resource.version(nil)
409
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
410
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
411
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
412
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
416
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
417
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
418
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
419
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
413
420
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
414
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
415
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
421
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
422
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
423
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
416
424
  provider.load_current_resource
417
425
  provider.run_action(:install)
418
426
  expect(new_resource).to be_updated_by_last_action
@@ -422,13 +430,14 @@ describe Chef::Provider::Package::Powershell, :windows_only do
422
430
  new_resource.package_name(%w{xCertificate xNetworking})
423
431
  new_resource.version(nil)
424
432
  new_resource.source("MyGallery")
425
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
426
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
427
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
428
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
433
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
434
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
435
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
436
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
429
437
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
430
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
431
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
438
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
439
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
440
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
432
441
  provider.load_current_resource
433
442
  provider.run_action(:install)
434
443
  expect(new_resource).to be_updated_by_last_action
@@ -440,8 +449,8 @@ describe Chef::Provider::Package::Powershell, :windows_only do
440
449
  provider.load_current_resource
441
450
  new_resource.package_name(["xCertificate"])
442
451
  new_resource.version(["2.1.0.0"])
443
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
444
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
452
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
453
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
445
454
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
446
455
  expect(provider).not_to receive(:remove_package)
447
456
  provider.run_action(:remove)
@@ -452,11 +461,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
452
461
  new_resource.package_name(["xCertificate"])
453
462
  new_resource.version(["2.1.0.0"])
454
463
  new_resource.source("MyGallery")
455
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
456
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
464
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
465
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
457
466
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
458
467
  provider.load_current_resource
459
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
468
+ expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
460
469
  provider.run_action(:remove)
461
470
  expect(new_resource).to be_updated_by_last_action
462
471
  end
@@ -464,10 +473,10 @@ describe Chef::Provider::Package::Powershell, :windows_only do
464
473
  it "does nothing when all the packages are already removed" do
465
474
  new_resource.package_name(%w{xCertificate xNetworking})
466
475
  new_resource.version(nil)
467
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
468
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
469
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
470
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
476
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
477
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
478
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
479
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
471
480
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
472
481
  provider.load_current_resource
473
482
  expect(provider).not_to receive(:remove_package)
@@ -478,11 +487,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
478
487
  it "removes a package when version is specified" do
479
488
  new_resource.package_name(["xCertificate"])
480
489
  new_resource.version(["2.1.0.0"])
481
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
482
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
490
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
491
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
483
492
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
484
493
  provider.load_current_resource
485
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
494
+ expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
486
495
  provider.run_action(:remove)
487
496
  expect(new_resource).to be_updated_by_last_action
488
497
  end
@@ -490,11 +499,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
490
499
  it "removes a package when version is not specified" do
491
500
  new_resource.package_name(["xCertificate"])
492
501
  new_resource.version(nil)
493
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
494
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
502
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
503
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
495
504
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
496
505
  provider.load_current_resource
497
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
506
+ expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
498
507
  provider.run_action(:remove)
499
508
  expect(new_resource).to be_updated_by_last_action
500
509
  end