chef 15.11.8-universal-mingw32 → 15.16.2-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +12 -13
  3. data/README.md +3 -3
  4. data/Rakefile +11 -17
  5. data/chef-universal-mingw32.gemspec +4 -4
  6. data/chef.gemspec +25 -7
  7. data/distro/powershell/chef/chef.psm1 +3 -3
  8. data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
  9. data/lib/chef/api_client/registration.rb +2 -2
  10. data/lib/chef/application/apply.rb +1 -1
  11. data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
  12. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  13. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  14. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
  15. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  16. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  17. data/lib/chef/chef_fs/path_utils.rb +3 -3
  18. data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
  19. data/lib/chef/data_bag.rb +2 -2
  20. data/lib/chef/data_collector/error_handlers.rb +1 -1
  21. data/lib/chef/deprecated.rb +12 -0
  22. data/lib/chef/dsl/declare_resource.rb +1 -1
  23. data/lib/chef/dsl/platform_introspection.rb +2 -0
  24. data/lib/chef/environment.rb +2 -2
  25. data/lib/chef/exceptions.rb +3 -0
  26. data/lib/chef/http.rb +2 -1
  27. data/lib/chef/knife/bootstrap.rb +6 -9
  28. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  29. data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
  30. data/lib/chef/knife/cookbook_download.rb +1 -1
  31. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  32. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  33. data/lib/chef/knife/core/hashed_command_loader.rb +3 -2
  34. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  35. data/lib/chef/knife/exec.rb +2 -2
  36. data/lib/chef/knife/ssh.rb +20 -1
  37. data/lib/chef/log.rb +1 -1
  38. data/lib/chef/mixin/openssl_helper.rb +26 -3
  39. data/lib/chef/mixin/template.rb +1 -0
  40. data/lib/chef/node_map.rb +5 -2
  41. data/lib/chef/provider/mount/solaris.rb +0 -1
  42. data/lib/chef/provider/package/cab.rb +1 -1
  43. data/lib/chef/provider/package/chocolatey.rb +1 -1
  44. data/lib/chef/provider/package/dnf/dnf_helper.py +5 -0
  45. data/lib/chef/provider/package/freebsd/pkgng.rb +3 -1
  46. data/lib/chef/provider/package/msu.rb +1 -0
  47. data/lib/chef/provider/package/powershell.rb +5 -1
  48. data/lib/chef/provider/package/snap.rb +96 -27
  49. data/lib/chef/provider/package/yum/yum_helper.py +4 -0
  50. data/lib/chef/provider/package/zypper.rb +0 -1
  51. data/lib/chef/provider/service/arch.rb +2 -2
  52. data/lib/chef/provider/service/debian.rb +1 -1
  53. data/lib/chef/provider/service/gentoo.rb +2 -2
  54. data/lib/chef/provider/service/macosx.rb +2 -2
  55. data/lib/chef/provider/service/openbsd.rb +1 -1
  56. data/lib/chef/provider/service/redhat.rb +2 -2
  57. data/lib/chef/provider/service/upstart.rb +1 -1
  58. data/lib/chef/provider/yum_repository.rb +1 -1
  59. data/lib/chef/provider/zypper_repository.rb +31 -11
  60. data/lib/chef/resource.rb +2 -0
  61. data/lib/chef/resource/archive_file.rb +28 -8
  62. data/lib/chef/resource/cron_access.rb +13 -5
  63. data/lib/chef/resource/cron_d.rb +2 -1
  64. data/lib/chef/resource/homebrew_cask.rb +3 -3
  65. data/lib/chef/resource/hostname.rb +19 -18
  66. data/lib/chef/resource/locale.rb +1 -1
  67. data/lib/chef/resource/lwrp_base.rb +7 -0
  68. data/lib/chef/resource/msu_package.rb +5 -0
  69. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  70. data/lib/chef/resource/sudo.rb +2 -2
  71. data/lib/chef/resource/windows_feature_powershell.rb +6 -2
  72. data/lib/chef/resource/windows_font.rb +2 -1
  73. data/lib/chef/role.rb +2 -2
  74. data/lib/chef/shell.rb +32 -1
  75. data/lib/chef/shell/shell_session.rb +2 -0
  76. data/lib/chef/util/diff.rb +1 -1
  77. data/lib/chef/util/dsc/configuration_generator.rb +1 -1
  78. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  79. data/lib/chef/version.rb +2 -2
  80. data/lib/chef/version_string.rb +1 -1
  81. data/lib/chef/win32/file.rb +2 -2
  82. data/spec/functional/knife/ssh_spec.rb +4 -4
  83. data/spec/functional/resource/aix_service_spec.rb +0 -1
  84. data/spec/functional/resource/aixinit_service_spec.rb +7 -8
  85. data/spec/functional/resource/apt_package_spec.rb +0 -1
  86. data/spec/functional/resource/bff_spec.rb +2 -2
  87. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  88. data/spec/functional/resource/cron_spec.rb +0 -1
  89. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  90. data/spec/functional/resource/insserv_spec.rb +4 -5
  91. data/spec/functional/resource/link_spec.rb +17 -17
  92. data/spec/functional/resource/msu_package_spec.rb +5 -2
  93. data/spec/functional/resource/rpm_spec.rb +2 -2
  94. data/spec/functional/resource/user/dscl_spec.rb +1 -1
  95. data/spec/functional/resource/user/mac_user_spec.rb +1 -1
  96. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  97. data/spec/functional/resource/windows_font_spec.rb +49 -0
  98. data/spec/functional/resource/windows_task_spec.rb +8 -8
  99. data/spec/functional/run_lock_spec.rb +2 -1
  100. data/spec/functional/shell_spec.rb +5 -5
  101. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  102. data/spec/functional/version_spec.rb +1 -1
  103. data/spec/functional/win32/service_manager_spec.rb +1 -1
  104. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  105. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +2 -2
  106. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  107. data/spec/integration/recipes/notifies_spec.rb +1 -1
  108. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  109. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  110. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
  111. data/spec/integration/recipes/resource_load_spec.rb +1 -0
  112. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  113. data/spec/scripts/ssl-serve.rb +1 -1
  114. data/spec/spec_helper.rb +10 -8
  115. data/spec/support/platform_helpers.rb +12 -42
  116. data/spec/support/platforms/win32/spec_service.rb +1 -1
  117. data/spec/support/shared/functional/directory_resource.rb +1 -1
  118. data/spec/support/shared/functional/execute_resource.rb +1 -1
  119. data/spec/support/shared/functional/file_resource.rb +2 -2
  120. data/spec/support/shared/functional/win32_service.rb +1 -1
  121. data/spec/support/shared/functional/windows_script.rb +3 -3
  122. data/spec/support/shared/integration/knife_support.rb +2 -5
  123. data/spec/unit/application_spec.rb +7 -0
  124. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
  125. data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
  126. data/spec/unit/data_bag_spec.rb +1 -1
  127. data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
  128. data/spec/unit/environment_spec.rb +7 -7
  129. data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
  130. data/spec/unit/knife/bootstrap_spec.rb +16 -16
  131. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  132. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  133. data/spec/unit/knife/cookbook_upload_spec.rb +5 -6
  134. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  135. data/spec/unit/knife/ssh_spec.rb +2 -2
  136. data/spec/unit/knife/supermarket_share_spec.rb +5 -3
  137. data/spec/unit/lwrp_spec.rb +4 -4
  138. data/spec/unit/mixin/securable_spec.rb +0 -1
  139. data/spec/unit/mixin/user_context_spec.rb +1 -9
  140. data/spec/unit/property_spec.rb +6 -6
  141. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  142. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -1
  143. data/spec/unit/provider/package/powershell_spec.rb +95 -86
  144. data/spec/unit/provider/package/rubygems_spec.rb +5 -10
  145. data/spec/unit/provider/package/snap_spec.rb +1 -1
  146. data/spec/unit/provider/package/windows_spec.rb +30 -53
  147. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  148. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  149. data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
  150. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  151. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  152. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  153. data/spec/unit/provider/service/windows_spec.rb +2 -6
  154. data/spec/unit/provider/systemd_unit_spec.rb +28 -24
  155. data/spec/unit/provider/zypper_repository_spec.rb +75 -25
  156. data/spec/unit/provider_spec.rb +1 -0
  157. data/spec/unit/resource/archive_file_spec.rb +11 -2
  158. data/spec/unit/resource/msu_package_spec.rb +4 -0
  159. data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
  160. data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
  161. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  162. data/spec/unit/resource/windows_package_spec.rb +1 -0
  163. data/spec/unit/resource/windows_task_spec.rb +1 -1
  164. data/spec/unit/resource/windows_uac_spec.rb +2 -2
  165. data/spec/unit/resource/yum_repository_spec.rb +21 -21
  166. data/spec/unit/resource_spec.rb +1 -1
  167. data/spec/unit/role_spec.rb +11 -11
  168. data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
  169. data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
  170. data/spec/unit/win32/security_spec.rb +4 -3
  171. metadata +64 -39
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Mark Mzyk (<mmzyk@chef.io>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -77,17 +77,9 @@ describe "a class that mixes in user_context" do
77
77
  end
78
78
 
79
79
  context "when the block raises an exception" do
80
- class UserContextTestException < RuntimeError
81
- end
82
- let(:block_parameter) { Proc.new { raise UserContextTextException } }
83
-
84
- it "raises the exception raised by the block" do
85
- expect { instance_with_user_context.with_context("kamilah", nil, "chef4life", &block_parameter) }.not_to raise_error(UserContextTestException)
86
- end
87
-
88
80
  it "closes the logon session so resources are not leaked" do
89
81
  expect(logon_session).to receive(:close)
90
- expect { instance_with_user_context.with_context("kamilah", nil, "chef4life", &block_parameter) }.not_to raise_error(UserContextTestException)
82
+ expect { instance_with_user_context.with_context("kamilah", nil, "chef4life") { 1 / 0 } }.to raise_error(ZeroDivisionError)
91
83
  end
92
84
  end
93
85
  end
@@ -111,17 +111,17 @@ describe "Chef::Resource.property" do
111
111
 
112
112
  with_property ":Straße" do
113
113
  it "properties with UTF-8 in their name work" do
114
- expect(resource.Straße).to eql(nil)
115
- expect(resource.Straße "foo").to eql("foo")
116
- expect(resource.Straße).to eql("foo")
117
- expect(resource.Straße = "bar").to eql("bar")
118
- expect(resource.Straße).to eql("bar")
114
+ expect(resource.Straße).to eql(nil) # rubocop: disable Naming/AsciiIdentifiers
115
+ expect(resource.Straße "foo").to eql("foo") # rubocop: disable Naming/AsciiIdentifiers
116
+ expect(resource.Straße).to eql("foo") # rubocop: disable Naming/AsciiIdentifiers
117
+ expect(resource.Straße = "bar").to eql("bar") # rubocop: disable Naming/AsciiIdentifiers
118
+ expect(resource.Straße).to eql("bar") # rubocop: disable Naming/AsciiIdentifiers
119
119
  end
120
120
  end
121
121
 
122
122
  context "deprecated properties" do
123
123
  it "does not create a deprecation warning on definition" do
124
- expect { resource_class.class_eval { property :x, String, deprecated: 10 } }.not_to raise_error Chef::Exceptions::DeprecatedFeatureError
124
+ expect { resource_class.class_eval { property :x, String, deprecated: 10 } }.not_to raise_error
125
125
  end
126
126
 
127
127
  with_property ":x, deprecated: 'a deprecated property'" do
@@ -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.query(:whatprovides, "tcpdump") }.to raise_error(/your hands in the air/)
28
28
  end
@@ -66,7 +66,7 @@ describe Chef::Provider::Package::Freebsd::Port do
66
66
  end
67
67
 
68
68
  it "should query pkg database" do
69
- expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
69
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 1, 70], timeout: 900).and_return(@pkg_info)
70
70
  expect(@provider.current_installed_version).to eq("3.1.7")
71
71
  end
72
72
  end
@@ -93,19 +93,19 @@ describe Chef::Provider::Package::Powershell do
93
93
  double("powershell_out", stdout: "5")
94
94
  end
95
95
 
96
- let(:generated_command) { "( Get-Package posh-git -Force -ForceBootstrap ).Version" }
97
- let(:generated_get_cmdlet) { "( Get-Package xNetworking -Force -ForceBootstrap ).Version" }
98
- let(:generated_get_cmdlet_with_version) { "( Get-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
99
- let(:generated_find_cmdlet) { "( Find-Package xNetworking -Force -ForceBootstrap ).Version" }
100
- let(:generated_find_cmdlet_with_version) { "( Find-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
101
- let(:generated_find_cmdlet_with_source) { "( Find-Package xNetworking -Force -ForceBootstrap -Source MyGallery ).Version" }
102
- let(:generated_find_cmdlet_with_source_and_version) { "( Find-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
103
- let(:generated_install_cmdlet) { "( Install-Package xNetworking -Force -ForceBootstrap ).Version" }
104
- let(:generated_install_cmdlet_with_version) { "( Install-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
105
- let(:generated_install_cmdlet_with_source) { "( Install-Package xNetworking -Force -ForceBootstrap -Source MyGallery ).Version" }
106
- let(:generated_install_cmdlet_with_source_and_version) { "( Install-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
107
- let(:generated_uninstall_cmdlet) { "( Uninstall-Package xNetworking -Force -ForceBootstrap ).Version" }
108
- let(:generated_uninstall_cmdlet_with_version) { "( Uninstall-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
96
+ let(:generated_command) { "( Get-Package posh-git -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
97
+ let(:generated_get_cmdlet) { "( Get-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
98
+ let(:generated_get_cmdlet_with_version) { "( Get-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
99
+ let(:generated_find_cmdlet) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
100
+ let(:generated_find_cmdlet_with_version) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
101
+ let(:generated_find_cmdlet_with_source) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version" }
102
+ let(:generated_find_cmdlet_with_source_and_version) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
103
+ let(:generated_install_cmdlet) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
104
+ let(:generated_install_cmdlet_with_version) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
105
+ let(:generated_install_cmdlet_with_source) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version" }
106
+ let(:generated_install_cmdlet_with_source_and_version) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
107
+ let(:generated_uninstall_cmdlet) { "( Uninstall-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
108
+ let(:generated_uninstall_cmdlet_with_version) { "( Uninstall-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
109
109
 
110
110
  describe "#initialize" do
111
111
  it "should return the correct class" do
@@ -116,14 +116,14 @@ describe Chef::Provider::Package::Powershell do
116
116
  describe "#candidate_version" do
117
117
 
118
118
  it "should set the candidate_version to the latest version when not pinning" do
119
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
119
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
120
120
  new_resource.package_name(["xNetworking"])
121
121
  new_resource.version(nil)
122
122
  expect(provider.candidate_version).to eql(["2.12.0.0"])
123
123
  end
124
124
 
125
125
  it "should use the candidate_version from the correct source" do
126
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
126
+ 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)
127
127
  new_resource.package_name(["xNetworking"])
128
128
  new_resource.version(nil)
129
129
  new_resource.source("MyGallery")
@@ -131,60 +131,60 @@ describe Chef::Provider::Package::Powershell do
131
131
  end
132
132
 
133
133
  it "should set the candidate_version to the latest version when not pinning and package name is space seperated" do
134
- 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
+ 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)
135
135
  new_resource.package_name(["7-Zip 16.02 (x64)"])
136
136
  new_resource.version(nil)
137
137
  expect(provider.candidate_version).to eql(["16.02"])
138
138
  end
139
139
 
140
140
  it "should set the candidate_version to pinned version if available" do
141
- 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)
141
+ 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)
142
142
  new_resource.package_name(["xCertificate"])
143
143
  new_resource.version(["2.0.0.0"])
144
144
  expect(provider.candidate_version).to eql(["2.0.0.0"])
145
145
  end
146
146
 
147
147
  it "should set the candidate_version to nil if there is no candidate" do
148
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
148
+ 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)
149
149
  new_resource.package_name(["xCertificate"])
150
150
  expect(provider.candidate_version).to eql([nil])
151
151
  end
152
152
 
153
153
  it "should set the candidate_version correctly when there are two packages to install" do
154
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
155
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
154
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
155
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
156
156
  new_resource.package_name(%w{xCertificate xNetworking})
157
157
  new_resource.version(nil)
158
158
  expect(provider.candidate_version).to eql(["2.1.0.0", "2.12.0.0"])
159
159
  end
160
160
 
161
161
  it "should set the candidate_version correctly when only the first is installable" do
162
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
163
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
162
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
163
+ 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)
164
164
  new_resource.package_name(%w{xCertificate xNetworking})
165
165
  new_resource.version(nil)
166
166
  expect(provider.candidate_version).to eql(["2.1.0.0", nil])
167
167
  end
168
168
 
169
169
  it "should set the candidate_version correctly when only the last is installable" do
170
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
171
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
170
+ 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)
171
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
172
172
  new_resource.package_name(%w{xCertificate xNetworking})
173
173
  new_resource.version(nil)
174
174
  expect(provider.candidate_version).to eql([nil, "2.12.0.0"])
175
175
  end
176
176
 
177
177
  it "should set the candidate_version correctly when neither are is installable and version is passed as nil array" do
178
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
179
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
178
+ 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)
179
+ 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)
180
180
  new_resource.package_name(%w{xNetworking xCertificate})
181
181
  new_resource.version([nil, nil])
182
182
  expect(provider.candidate_version).to eql([nil, nil])
183
183
  end
184
184
 
185
185
  it "should set the candidate_version correctly when neither are is installable and version is not passed" do
186
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
187
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
186
+ 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)
187
+ 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)
188
188
  new_resource.package_name(%w{xNetworking xCertificate})
189
189
  new_resource.version(nil)
190
190
  expect(provider.candidate_version).to eql([nil, nil])
@@ -283,10 +283,11 @@ describe Chef::Provider::Package::Powershell do
283
283
  provider.load_current_resource
284
284
  new_resource.package_name(["xCertificate"])
285
285
  new_resource.version(nil)
286
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
287
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
286
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
287
+ 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)
288
288
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
289
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
289
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
290
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
290
291
  provider.run_action(:install)
291
292
  expect(new_resource).to be_updated_by_last_action
292
293
  end
@@ -296,10 +297,11 @@ describe Chef::Provider::Package::Powershell do
296
297
  new_resource.package_name(["xCertificate"])
297
298
  new_resource.version(nil)
298
299
  new_resource.source("MyGallery")
299
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
300
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
300
+ 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)
301
+ 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)
301
302
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
302
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
303
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
304
+ 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 })
303
305
  provider.run_action(:install)
304
306
  expect(new_resource).to be_updated_by_last_action
305
307
  end
@@ -309,10 +311,11 @@ describe Chef::Provider::Package::Powershell do
309
311
  new_resource.package_name(["xCertificate"])
310
312
  new_resource.version(nil)
311
313
  new_resource.skip_publisher_check(true)
312
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
313
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
314
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
315
+ 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)
314
316
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
315
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { timeout: new_resource.timeout })
317
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
318
+ 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 })
316
319
  provider.run_action(:install)
317
320
  expect(new_resource).to be_updated_by_last_action
318
321
  end
@@ -321,10 +324,11 @@ describe Chef::Provider::Package::Powershell do
321
324
  provider.load_current_resource
322
325
  new_resource.package_name(["7-Zip 16.02 (x64)"])
323
326
  new_resource.version(nil)
324
- 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)
325
- 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)
327
+ 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)
328
+ 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)
326
329
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
327
- expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -RequiredVersion 16.02 ).Version", { timeout: new_resource.timeout })
330
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
331
+ 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 })
328
332
  provider.run_action(:install)
329
333
  expect(new_resource).to be_updated_by_last_action
330
334
  end
@@ -336,10 +340,11 @@ describe Chef::Provider::Package::Powershell do
336
340
  provider.load_current_resource
337
341
  new_resource.package_name(["xCertificate"])
338
342
  new_resource.version(nil)
339
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
340
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
343
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
344
+ 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)
341
345
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
342
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
346
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
347
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
343
348
  provider.run_action(:install)
344
349
  expect(new_resource).to be_updated_by_last_action
345
350
  end
@@ -348,8 +353,8 @@ describe Chef::Provider::Package::Powershell do
348
353
  it "should not install packages that are up-to-date" do
349
354
  new_resource.package_name(["xCertificate"])
350
355
  new_resource.version(nil)
351
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
352
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
356
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
357
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
353
358
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
354
359
  provider.load_current_resource
355
360
  expect(provider).not_to receive(:install_package)
@@ -360,8 +365,8 @@ describe Chef::Provider::Package::Powershell do
360
365
  it "should not install packages that are up-to-date" do
361
366
  new_resource.package_name(["xNetworking"])
362
367
  new_resource.version(["2.11.0.0"])
363
- 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)
364
- 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)
368
+ 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)
369
+ 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)
365
370
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
366
371
  provider.load_current_resource
367
372
  expect(provider).not_to receive(:install_package)
@@ -374,13 +379,14 @@ describe Chef::Provider::Package::Powershell do
374
379
  # new_version.resource[0]
375
380
  new_resource.package_name(%w{xCertificate xNetworking})
376
381
  new_resource.version([nil, "2.11.0.0"])
377
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
378
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
379
- 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)
380
- 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)
382
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
383
+ 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)
384
+ 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)
385
+ 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)
381
386
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
382
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
383
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout })
387
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
388
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
389
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout })
384
390
  provider.load_current_resource
385
391
  provider.run_action(:install)
386
392
  expect(new_resource).to be_updated_by_last_action
@@ -389,13 +395,14 @@ describe Chef::Provider::Package::Powershell do
389
395
  it "should split up commands when given two packages, one with a version pin" do
390
396
  new_resource.package_name(%w{xCertificate xNetworking})
391
397
  new_resource.version(["2.1.0.0", nil])
392
- 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)
393
- 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)
394
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
395
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
398
+ 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)
399
+ 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)
400
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
401
+ 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)
396
402
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
397
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
398
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
403
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
404
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
405
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
399
406
 
400
407
  provider.load_current_resource
401
408
  provider.run_action(:install)
@@ -405,13 +412,14 @@ describe Chef::Provider::Package::Powershell do
405
412
  it "should do multipackage installs when given two packages without constraints" do
406
413
  new_resource.package_name(%w{xCertificate xNetworking})
407
414
  new_resource.version(nil)
408
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
409
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
410
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
411
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
415
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
416
+ 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)
417
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
418
+ 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)
412
419
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
413
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
414
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
420
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
421
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
422
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
415
423
  provider.load_current_resource
416
424
  provider.run_action(:install)
417
425
  expect(new_resource).to be_updated_by_last_action
@@ -421,13 +429,14 @@ describe Chef::Provider::Package::Powershell do
421
429
  new_resource.package_name(%w{xCertificate xNetworking})
422
430
  new_resource.version(nil)
423
431
  new_resource.source("MyGallery")
424
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
425
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
426
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
427
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
432
+ 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)
433
+ 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)
434
+ 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)
435
+ 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)
428
436
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
429
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
430
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
437
+ allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
438
+ 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 })
439
+ 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 })
431
440
  provider.load_current_resource
432
441
  provider.run_action(:install)
433
442
  expect(new_resource).to be_updated_by_last_action
@@ -439,8 +448,8 @@ describe Chef::Provider::Package::Powershell do
439
448
  provider.load_current_resource
440
449
  new_resource.package_name(["xCertificate"])
441
450
  new_resource.version(["2.1.0.0"])
442
- 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)
443
- 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)
451
+ 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)
452
+ 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)
444
453
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
445
454
  expect(provider).not_to receive(:remove_package)
446
455
  provider.run_action(:remove)
@@ -451,11 +460,11 @@ describe Chef::Provider::Package::Powershell do
451
460
  new_resource.package_name(["xCertificate"])
452
461
  new_resource.version(["2.1.0.0"])
453
462
  new_resource.source("MyGallery")
454
- 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)
455
- 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)
463
+ 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)
464
+ 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)
456
465
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
457
466
  provider.load_current_resource
458
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
467
+ expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
459
468
  provider.run_action(:remove)
460
469
  expect(new_resource).to be_updated_by_last_action
461
470
  end
@@ -463,10 +472,10 @@ describe Chef::Provider::Package::Powershell do
463
472
  it "does nothing when all the packages are already removed" do
464
473
  new_resource.package_name(%w{xCertificate xNetworking})
465
474
  new_resource.version(nil)
466
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
467
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
468
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
469
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
475
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
476
+ 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)
477
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
478
+ 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)
470
479
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
471
480
  provider.load_current_resource
472
481
  expect(provider).not_to receive(:remove_package)
@@ -477,11 +486,11 @@ describe Chef::Provider::Package::Powershell do
477
486
  it "removes a package when version is specified" do
478
487
  new_resource.package_name(["xCertificate"])
479
488
  new_resource.version(["2.1.0.0"])
480
- 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)
481
- 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)
489
+ 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)
490
+ 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)
482
491
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
483
492
  provider.load_current_resource
484
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
493
+ expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
485
494
  provider.run_action(:remove)
486
495
  expect(new_resource).to be_updated_by_last_action
487
496
  end
@@ -489,11 +498,11 @@ describe Chef::Provider::Package::Powershell do
489
498
  it "removes a package when version is not specified" do
490
499
  new_resource.package_name(["xCertificate"])
491
500
  new_resource.version(nil)
492
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
493
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
501
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
502
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
494
503
  allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
495
504
  provider.load_current_resource
496
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
505
+ 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)
497
506
  provider.run_action(:remove)
498
507
  expect(new_resource).to be_updated_by_last_action
499
508
  end
@@ -106,30 +106,25 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
106
106
  context "new default rubygems behavior" do
107
107
  before do
108
108
  Chef::Config[:rubygems_cache_enabled] = false
109
+
110
+ dep_installer = Gem::DependencyInstaller.new
111
+ expect(dep_installer).not_to receive(:find_gems_with_sources)
112
+ allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
109
113
  end
110
114
 
111
115
  it "finds a matching gem candidate version on rubygems 2.0.0+" do
112
116
  dep = Gem::Dependency.new("rspec", ">= 0")
113
- dep_installer = Gem::DependencyInstaller.new
114
- allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
115
- expect(dep_installer).not_to receive(:find_gems_with_sources).with(dep).and_call_original
116
117
  expect(@gem_env.candidate_version_from_remote(dep)).to be_kind_of(Gem::Version)
117
118
  end
118
119
 
119
120
  it "gives the candidate version as nil if none is found" do
120
121
  dep = Gem::Dependency.new("lksdjflksdjflsdkfj", ">= 0")
121
- dep_installer = Gem::DependencyInstaller.new
122
- allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
123
- expect(dep_installer).not_to receive(:find_gems_with_sources).with(dep).and_call_original
124
122
  expect(@gem_env.candidate_version_from_remote(dep)).to be_nil
125
123
  end
126
124
 
127
125
  it "finds a matching gem from a specific gemserver when explicit sources are given (to a server that doesn't respond to api requests)" do
128
126
  dep = Gem::Dependency.new("rspec", ">= 0")
129
- dep_installer = Gem::DependencyInstaller.new
130
- allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
131
- expect(dep_installer).not_to receive(:find_gems_with_sources).with(dep).and_call_original
132
- expect(@gem_env.candidate_version_from_remote(dep, "http://production.cf.rubygems.org")).to be_kind_of(Gem::Version)
127
+ expect(@gem_env.candidate_version_from_remote(dep, "https://rubygems.org")).to be_kind_of(Gem::Version)
133
128
  end
134
129
  end
135
130