chef 16.1.16 → 16.2.44

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -3
  3. data/README.md +3 -3
  4. data/Rakefile +2 -2
  5. data/chef.gemspec +3 -3
  6. data/lib/chef/application/apply.rb +1 -1
  7. data/lib/chef/application/base.rb +1 -1
  8. data/lib/chef/application/client.rb +1 -1
  9. data/lib/chef/application/windows_service_manager.rb +1 -1
  10. data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
  11. data/lib/chef/chef_fs/path_utils.rb +1 -1
  12. data/lib/chef/cookbook/chefignore.rb +1 -1
  13. data/lib/chef/cookbook/metadata.rb +1 -1
  14. data/lib/chef/cookbook_version.rb +2 -2
  15. data/lib/chef/data_bag.rb +4 -4
  16. data/lib/chef/deprecated.rb +4 -0
  17. data/lib/chef/file_access_control.rb +1 -1
  18. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +1 -1
  19. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +3 -3
  20. data/lib/chef/http.rb +17 -2
  21. data/lib/chef/http/http_request.rb +1 -1
  22. data/lib/chef/http/json_output.rb +1 -1
  23. data/lib/chef/http/ssl_policies.rb +18 -0
  24. data/lib/chef/knife.rb +1 -1
  25. data/lib/chef/knife/bootstrap.rb +3 -6
  26. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  27. data/lib/chef/knife/client_bulk_delete.rb +1 -1
  28. data/lib/chef/knife/config_get.rb +1 -1
  29. data/lib/chef/knife/cookbook_delete.rb +1 -1
  30. data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
  31. data/lib/chef/knife/data_bag_create.rb +1 -1
  32. data/lib/chef/knife/node_bulk_delete.rb +1 -1
  33. data/lib/chef/knife/node_run_list_remove.rb +1 -1
  34. data/lib/chef/knife/role_bulk_delete.rb +1 -1
  35. data/lib/chef/knife/ssh.rb +1 -1
  36. data/lib/chef/knife/supermarket_share.rb +1 -1
  37. data/lib/chef/knife/supermarket_unshare.rb +1 -1
  38. data/lib/chef/log.rb +1 -1
  39. data/lib/chef/mixin/securable.rb +2 -2
  40. data/lib/chef/powershell.rb +1 -1
  41. data/lib/chef/provider/batch.rb +3 -10
  42. data/lib/chef/provider/cron.rb +2 -14
  43. data/lib/chef/provider/execute.rb +2 -1
  44. data/lib/chef/provider/group/dscl.rb +2 -2
  45. data/lib/chef/provider/group/windows.rb +1 -1
  46. data/lib/chef/provider/ifconfig.rb +7 -7
  47. data/lib/chef/provider/mount/aix.rb +1 -1
  48. data/lib/chef/provider/mount/windows.rb +2 -2
  49. data/lib/chef/provider/noop.rb +1 -1
  50. data/lib/chef/provider/package/openbsd.rb +1 -1
  51. data/lib/chef/provider/package/portage.rb +2 -2
  52. data/lib/chef/provider/package/powershell.rb +6 -2
  53. data/lib/chef/provider/package/rubygems.rb +2 -2
  54. data/lib/chef/provider/package/snap.rb +96 -27
  55. data/lib/chef/provider/package/windows/msi.rb +3 -3
  56. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
  57. data/lib/chef/provider/powershell_script.rb +10 -14
  58. data/lib/chef/provider/remote_file/http.rb +4 -1
  59. data/lib/chef/provider/script.rb +4 -75
  60. data/lib/chef/provider/service/arch.rb +1 -1
  61. data/lib/chef/provider/service/debian.rb +2 -2
  62. data/lib/chef/provider/service/openbsd.rb +4 -4
  63. data/lib/chef/provider/service/redhat.rb +1 -1
  64. data/lib/chef/provider/service/windows.rb +1 -1
  65. data/lib/chef/provider/subversion.rb +2 -2
  66. data/lib/chef/provider/user/dscl.rb +4 -4
  67. data/lib/chef/provider/user/linux.rb +3 -3
  68. data/lib/chef/provider/user/mac.rb +5 -5
  69. data/lib/chef/provider/windows_script.rb +87 -25
  70. data/lib/chef/provider/zypper_repository.rb +30 -10
  71. data/lib/chef/resource.rb +22 -11
  72. data/lib/chef/resource/apt_package.rb +1 -1
  73. data/lib/chef/resource/archive_file.rb +28 -8
  74. data/lib/chef/resource/bash.rb +0 -1
  75. data/lib/chef/resource/batch.rb +4 -2
  76. data/lib/chef/resource/chef_client_scheduled_task.rb +13 -1
  77. data/lib/chef/resource/cron/_cron_shared.rb +98 -0
  78. data/lib/chef/resource/cron/cron.rb +46 -0
  79. data/lib/chef/resource/{cron_d.rb → cron/cron_d.rb} +7 -87
  80. data/lib/chef/resource/cron_access.rb +11 -3
  81. data/lib/chef/resource/csh.rb +0 -1
  82. data/lib/chef/resource/execute.rb +477 -7
  83. data/lib/chef/resource/file.rb +1 -1
  84. data/lib/chef/resource/freebsd_package.rb +1 -1
  85. data/lib/chef/resource/helpers/cron_validations.rb +6 -3
  86. data/lib/chef/resource/homebrew_package.rb +30 -1
  87. data/lib/chef/resource/homebrew_update.rb +107 -0
  88. data/lib/chef/resource/hostname.rb +6 -19
  89. data/lib/chef/resource/kernel_module.rb +14 -1
  90. data/lib/chef/resource/mount.rb +1 -1
  91. data/lib/chef/resource/perl.rb +0 -1
  92. data/lib/chef/resource/plist.rb +23 -4
  93. data/lib/chef/resource/powershell_script.rb +4 -2
  94. data/lib/chef/resource/python.rb +0 -1
  95. data/lib/chef/resource/remote_file.rb +26 -10
  96. data/lib/chef/resource/ruby.rb +0 -1
  97. data/lib/chef/resource/template.rb +1 -1
  98. data/lib/chef/resource/windows_ad_join.rb +30 -1
  99. data/lib/chef/resource/windows_audit_policy.rb +227 -0
  100. data/lib/chef/resource/windows_auto_run.rb +11 -0
  101. data/lib/chef/resource/windows_certificate.rb +26 -0
  102. data/lib/chef/resource/windows_font.rb +3 -3
  103. data/lib/chef/resource/windows_package.rb +1 -1
  104. data/lib/chef/resource/windows_pagefile.rb +1 -1
  105. data/lib/chef/resource/windows_script.rb +2 -16
  106. data/lib/chef/resource/windows_security_policy.rb +17 -15
  107. data/lib/chef/resource/windows_shortcut.rb +1 -2
  108. data/lib/chef/resource/windows_task.rb +4 -4
  109. data/lib/chef/resource/windows_user_privilege.rb +5 -5
  110. data/lib/chef/resource/yum_repository.rb +9 -9
  111. data/lib/chef/resources.rb +4 -2
  112. data/lib/chef/search/query.rb +1 -1
  113. data/lib/chef/util/diff.rb +2 -2
  114. data/lib/chef/util/windows/net_user.rb +1 -1
  115. data/lib/chef/util/windows/volume.rb +1 -1
  116. data/lib/chef/version.rb +1 -1
  117. data/lib/chef/win32/file.rb +1 -1
  118. data/lib/chef/win32/registry.rb +2 -2
  119. data/lib/chef/win32/security.rb +1 -1
  120. data/spec/data/lwrp/providers/buck_passer.rb +1 -1
  121. data/spec/data/lwrp/providers/buck_passer_2.rb +1 -1
  122. data/spec/data/lwrp/providers/embedded_resource_accesses_providers_scope.rb +1 -1
  123. data/spec/functional/resource/cron_spec.rb +10 -0
  124. data/spec/functional/resource/remote_file_spec.rb +2 -2
  125. data/spec/functional/resource/windows_task_spec.rb +8 -8
  126. data/spec/support/platform_helpers.rb +1 -1
  127. data/spec/support/platforms/win32/spec_service.rb +1 -1
  128. data/spec/support/shared/functional/execute_resource.rb +1 -1
  129. data/spec/support/shared/unit/execute_resource.rb +1 -1
  130. data/spec/unit/application_spec.rb +7 -0
  131. data/spec/unit/data_bag_spec.rb +1 -1
  132. data/spec/unit/http/ssl_policies_spec.rb +20 -0
  133. data/spec/unit/knife/bootstrap_spec.rb +2 -2
  134. data/spec/unit/mixin/user_context_spec.rb +1 -9
  135. data/spec/unit/property_spec.rb +1 -1
  136. data/spec/unit/provider/batch_spec.rb +130 -0
  137. data/spec/unit/provider/cron_spec.rb +9 -49
  138. data/spec/unit/provider/package/powershell_spec.rb +95 -86
  139. data/spec/unit/provider/package/snap_spec.rb +1 -1
  140. data/spec/unit/provider/powershell_script_spec.rb +3 -45
  141. data/spec/unit/provider/script_spec.rb +20 -110
  142. data/spec/unit/provider/zypper_repository_spec.rb +60 -10
  143. data/spec/unit/resource/archive_file_spec.rb +11 -2
  144. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +17 -7
  145. data/spec/unit/resource/cron_spec.rb +2 -2
  146. data/spec/unit/resource/helpers/cron_validations_spec.rb +5 -1
  147. data/spec/unit/resource/homebrew_update_spec.rb +30 -0
  148. data/spec/unit/resource/powershell_script_spec.rb +10 -15
  149. data/spec/unit/resource/timezone_spec.rb +1 -1
  150. data/spec/unit/resource/windows_audit_policy_spec.rb +64 -0
  151. data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
  152. data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
  153. data/spec/unit/resource/windows_task_spec.rb +1 -1
  154. data/spec/unit/resource/windows_uac_spec.rb +2 -2
  155. data/spec/unit/resource/yum_repository_spec.rb +21 -21
  156. data/spec/unit/resource_spec.rb +67 -1
  157. data/spec/unit/util/dsc/configuration_generator_spec.rb +1 -1
  158. data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
  159. metadata +22 -22
  160. data/lib/chef/resource/cron.rb +0 -157
@@ -243,7 +243,7 @@ describe Chef::DataBag do
243
243
 
244
244
  expect do
245
245
  Chef::DataBag.load("foo")
246
- end.to raise_error Chef::Exceptions::InvalidDataBagPath, "Data bag path '/var/chef/data_bags' is invalid"
246
+ end.to raise_error Chef::Exceptions::InvalidDataBagPath, "Data bag path '/var/chef/data_bags' not found. Please create this directory."
247
247
  end
248
248
 
249
249
  end
@@ -166,4 +166,24 @@ describe "HTTP SSL Policy" do
166
166
  end
167
167
 
168
168
  end
169
+
170
+ describe Chef::HTTP::VerifyPeerSSLPolicy do
171
+
172
+ let(:ssl_policy) { Chef::HTTP::VerifyPeerSSLPolicy.new(unconfigured_http_client) }
173
+
174
+ it "sets the OpenSSL verify mode to verify_peer" do
175
+ expect(http_client.verify_mode).to eq(OpenSSL::SSL::VERIFY_PEER)
176
+ end
177
+
178
+ end
179
+
180
+ describe Chef::HTTP::VerifyNoneSSLPolicy do
181
+
182
+ let(:ssl_policy) { Chef::HTTP::VerifyNoneSSLPolicy.new(unconfigured_http_client) }
183
+
184
+ it "sets the OpenSSL verify mode to verify_peer" do
185
+ expect(http_client.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
186
+ end
187
+
188
+ end
169
189
  end
@@ -1729,8 +1729,8 @@ describe Chef::Knife::Bootstrap do
1729
1729
  allow(vault_handler_mock).to receive(:doing_chef_vault?).and_return false
1730
1730
  end
1731
1731
 
1732
- it "shows a message" do
1733
- expect(knife.ui).to receive(:info)
1732
+ it "shows a warning message" do
1733
+ expect(knife.ui).to receive(:warn).twice
1734
1734
  knife.register_client
1735
1735
  end
1736
1736
  end
@@ -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
@@ -121,7 +121,7 @@ describe "Chef::Resource.property" do
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
@@ -0,0 +1,130 @@
1
+ #
2
+ # Author:: Adam Jacob (adam@chef.io)
3
+ # Copyright:: Copyright 2009-2016, Opscode
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "spec_helper"
20
+
21
+ describe Chef::Provider::Batch do
22
+ let(:node) do
23
+ node = Chef::Node.new
24
+ node.default["kernel"] = {}
25
+ node.default["kernel"][:machine] = :x86_64.to_s
26
+ node
27
+ end
28
+
29
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
30
+
31
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
32
+
33
+ let(:new_resource) do
34
+ new_resource = Chef::Resource::Batch.new("cmd.exe and conquer")
35
+ new_resource.code %q{echo "hello"}
36
+ new_resource
37
+ end
38
+
39
+ let(:provider) { Chef::Provider::Batch.new(new_resource, run_context) }
40
+
41
+ context "#grant_alternate_user_read_access" do
42
+ before do
43
+ allow(ChefUtils).to receive(:windows?).and_return(true)
44
+ stub_const("Chef::ReservedNames::Win32::API::Security::GENERIC_READ", 1)
45
+ stub_const("Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE", 4)
46
+ stub_const("Chef::ReservedNames::Win32::Security", Class.new)
47
+ stub_const("Chef::ReservedNames::Win32::Security::SecurableObject", Class.new)
48
+ stub_const("Chef::ReservedNames::Win32::Security::SID", Class.new)
49
+ stub_const("Chef::ReservedNames::Win32::Security::ACE", Class.new)
50
+ stub_const("Chef::ReservedNames::Win32::Security::ACL", Class.new)
51
+
52
+ provider.singleton_class.send(:public, :grant_alternate_user_read_access)
53
+ end
54
+
55
+ context "when an alternate user is not specified" do
56
+ it "does not attempt to set the script file's security descriptor" do
57
+ expect(provider).to receive(:grant_alternate_user_read_access)
58
+ expect(Chef::ReservedNames::Win32::Security::SecurableObject).not_to receive(:new)
59
+ provider.grant_alternate_user_read_access("a fake path")
60
+ end
61
+ end
62
+
63
+ context "when an alternate user is specified" do
64
+ let(:security_descriptor) { instance_double("Chef::ReservedNames::Win32::Security::SecurityDescriptor", dacl: []) }
65
+ let(:securable_object) { instance_double("Chef::ReservedNames::Win32::Security::SecurableObject", :security_descriptor => security_descriptor, :dacl= => nil) }
66
+
67
+ it "sets the script file's security descriptor" do
68
+ new_resource.user("toor")
69
+ expect(Chef::ReservedNames::Win32::Security::SecurableObject).to receive(:new).and_return(securable_object)
70
+ expect(Chef::ReservedNames::Win32::Security::SID).to receive(:from_account).and_return(nil)
71
+ expect(Chef::ReservedNames::Win32::Security::ACE).to receive(:access_allowed).and_return(nil)
72
+ expect(Chef::ReservedNames::Win32::Security::ACL).to receive(:create).and_return(nil)
73
+ expect(securable_object).to receive(:dacl=)
74
+ provider.grant_alternate_user_read_access("a fake path")
75
+ end
76
+ end
77
+ end
78
+
79
+ describe "#with_temp_script_file" do
80
+ before do
81
+ provider.singleton_class.send(:public, :with_temp_script_file)
82
+ provider.singleton_class.send(:public, :script_file_path)
83
+ end
84
+
85
+ it "should put the contents of the script in the temp file" do
86
+ temp_file_contents = nil
87
+
88
+ provider.with_temp_script_file do
89
+ temp_file_contents = File.read(provider.script_file_path)
90
+ end
91
+
92
+ expect(temp_file_contents.strip).to eq(%q{echo "hello"})
93
+ end
94
+ end
95
+
96
+ describe "#command" do
97
+ let(:basepath) { "C:\\Windows\\system32" }
98
+ let(:interpreter) { File.join(basepath, "cmd.exe") }
99
+
100
+ before do
101
+ allow(provider).to receive(:basepath).and_return(basepath)
102
+ provider.singleton_class.send(:public, :with_temp_script_file)
103
+ provider.singleton_class.send(:public, :script_file_path)
104
+ end
105
+
106
+ it 'should set the command to "interpreter" "tempfile"' do
107
+ command = nil
108
+ script_file_path = nil
109
+ provider.with_temp_script_file do
110
+ command = provider.command
111
+ script_file_path = provider.script_file_path
112
+ end
113
+
114
+ expect(command).to eq(%Q{"#{interpreter}" /c "#{script_file_path}"})
115
+ end
116
+
117
+ it "should set the command to 'interpreter flags tempfile'" do
118
+ new_resource.flags "/f"
119
+
120
+ command = nil
121
+ script_file_path = nil
122
+ provider.with_temp_script_file do
123
+ command = provider.command
124
+ script_file_path = provider.script_file_path
125
+ end
126
+
127
+ expect(command).to eq(%Q{"#{interpreter}" /f /c "#{script_file_path}"})
128
+ end
129
+ end
130
+ end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  require "spec_helper"
20
19
 
21
20
  describe Chef::Provider::Cron do
@@ -322,7 +321,7 @@ describe Chef::Provider::Cron do
322
321
  expect(cron.hour).to eq("5")
323
322
  expect(cron.day).to eq("*")
324
323
  expect(cron.month).to eq("Jan")
325
- expect(cron.weekday).to eq("Mon")
324
+ expect(cron.weekday).to eq("1")
326
325
  expect(cron.command).to eq("/bin/true param1 param2")
327
326
  end
328
327
 
@@ -338,6 +337,7 @@ describe Chef::Provider::Cron do
338
337
  0 2 * * * /some/other/command
339
338
 
340
339
  # Chef Name: cronhole some stuff
340
+ * * * * * /bin/true
341
341
  CRONTAB
342
342
  cron = @provider.load_current_resource
343
343
  expect(@provider.cron_exists).to eq(true)
@@ -347,7 +347,7 @@ describe Chef::Provider::Cron do
347
347
  expect(cron.month).to eq("*")
348
348
  expect(cron.weekday).to eq("*")
349
349
  expect(cron.time).to eq(nil)
350
- expect(cron.command).to eq(nil)
350
+ expect(cron.command).to eq("/bin/true")
351
351
  end
352
352
 
353
353
  it "should not pick up a commented out crontab line" do
@@ -355,6 +355,7 @@ describe Chef::Provider::Cron do
355
355
  0 2 * * * /some/other/command
356
356
 
357
357
  # Chef Name: cronhole some stuff
358
+ * * * * * /bin/true
358
359
  #* 5 * 1 * /bin/true param1 param2
359
360
  CRONTAB
360
361
  cron = @provider.load_current_resource
@@ -365,7 +366,7 @@ describe Chef::Provider::Cron do
365
366
  expect(cron.month).to eq("*")
366
367
  expect(cron.weekday).to eq("*")
367
368
  expect(cron.time).to eq(nil)
368
- expect(cron.command).to eq(nil)
369
+ expect(cron.command).to eq("/bin/true")
369
370
  end
370
371
 
371
372
  it "should not pick up a later crontab entry" do
@@ -373,6 +374,7 @@ describe Chef::Provider::Cron do
373
374
  0 2 * * * /some/other/command
374
375
 
375
376
  # Chef Name: cronhole some stuff
377
+ * * * * * /bin/true
376
378
  #* 5 * 1 * /bin/true param1 param2
377
379
  # Chef Name: something else
378
380
  2 * 1 * * /bin/false
@@ -387,7 +389,7 @@ describe Chef::Provider::Cron do
387
389
  expect(cron.month).to eq("*")
388
390
  expect(cron.weekday).to eq("*")
389
391
  expect(cron.time).to eq(nil)
390
- expect(cron.command).to eq(nil)
392
+ expect(cron.command).to eq("/bin/true")
391
393
  end
392
394
  end
393
395
  end
@@ -1040,48 +1042,6 @@ describe Chef::Provider::Cron do
1040
1042
  end
1041
1043
  end
1042
1044
 
1043
- describe "weekday_in_crontab" do
1044
- context "when weekday is symbol" do
1045
- it "should return weekday in crontab format" do
1046
- @new_resource.weekday :wednesday
1047
- expect(@provider.send(:weekday_in_crontab)).to eq("3")
1048
- end
1049
-
1050
- it "should raise an error with an unknown weekday" do
1051
- expect { @new_resource.weekday :caturday }.to raise_error(RangeError)
1052
- end
1053
- end
1054
-
1055
- context "when weekday is a number in a string" do
1056
- it "should return the string" do
1057
- @new_resource.weekday "3"
1058
- expect(@provider.send(:weekday_in_crontab)).to eq("3")
1059
- end
1060
-
1061
- it "should raise an error with an out of range number" do
1062
- expect { @new_resource.weekday "-1" }.to raise_error(RangeError)
1063
- end
1064
- end
1065
-
1066
- context "when weekday is string with the name of the week" do
1067
- it "should return the string" do
1068
- @new_resource.weekday "mon"
1069
- expect(@provider.send(:weekday_in_crontab)).to eq("mon")
1070
- end
1071
- end
1072
-
1073
- context "when weekday is an integer" do
1074
- it "should return the integer" do
1075
- @new_resource.weekday 1
1076
- expect(@provider.send(:weekday_in_crontab)).to eq("1")
1077
- end
1078
-
1079
- it "should raise an error with an out of range integer" do
1080
- expect { @new_resource.weekday 45 }.to raise_error(RangeError)
1081
- end
1082
- end
1083
- end
1084
-
1085
1045
  describe "#env_var_str" do
1086
1046
  context "when no env vars are set" do
1087
1047
  it "returns an empty string" do
@@ -1196,8 +1156,8 @@ describe Chef::Provider::Cron do
1196
1156
  context "Without command, passed" do
1197
1157
  context "as nil" do
1198
1158
  it "returns an empty string with a next line" do
1199
- @new_resource.command nil
1200
- expect(@provider.send(:cmd_str)).to eq(" \n")
1159
+ @new_resource.command "bin/true"
1160
+ expect(@provider.send(:cmd_str)).to eq(" bin/true\n")
1201
1161
  end
1202
1162
  end
1203
1163
  context "as an empty string" do
@@ -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,14 +117,14 @@ 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")
@@ -132,60 +132,60 @@ describe Chef::Provider::Package::Powershell, :windows_only do
132
132
  end
133
133
 
134
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 ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
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