chef 17.7.29 → 17.8.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/application/base.rb +1 -1
- data/lib/chef/compliance/default_attributes.rb +12 -2
- data/lib/chef/compliance/runner.rb +51 -5
- data/lib/chef/mixin/powershell_exec.rb +6 -5
- data/lib/chef/mixin/why_run.rb +8 -2
- data/lib/chef/powershell.rb +8 -6
- data/lib/chef/provider/mount/linux.rb +16 -2
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/package/dnf.rb +1 -1
- data/lib/chef/provider/package/powershell.rb +13 -10
- data/lib/chef/provider/package/zypper.rb +2 -0
- data/lib/chef/provider/package.rb +58 -23
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/pwsh.rb +3 -2
- data/lib/chef/resource/chef_client_config.rb +22 -1
- data/lib/chef/resource/chef_client_launchd.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +4 -6
- data/lib/chef/resource/dpkg_package.rb +5 -0
- data/lib/chef/resource/execute.rb +1 -4
- data/lib/chef/resource/launchd.rb +0 -3
- data/lib/chef/resource/macos_userdefaults.rb +5 -7
- data/lib/chef/resource/rhsm_register.rb +31 -0
- data/lib/chef/resource/support/client.erb +7 -0
- data/lib/chef/resource/windows_feature_powershell.rb +7 -7
- data/lib/chef/resource.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/resource/dnf_package_spec.rb +34 -20
- data/spec/functional/resource/dpkg_package_spec.rb +16 -0
- data/spec/functional/resource/macos_userdefaults_spec.rb +20 -0
- data/spec/functional/resource/zypper_package_spec.rb +7 -0
- data/spec/integration/client/client_spec.rb +31 -0
- data/spec/unit/application/base_spec.rb +40 -0
- data/spec/unit/compliance/runner_spec.rb +62 -1
- data/spec/unit/file_access_control_spec.rb +1 -1
- data/spec/unit/mixin/why_run_spec.rb +53 -0
- data/spec/unit/provider/group/groupadd_spec.rb +1 -0
- data/spec/unit/provider/group/usermod_spec.rb +2 -2
- data/spec/unit/provider/ifconfig_spec.rb +2 -0
- data/spec/unit/provider/mount/linux_spec.rb +16 -3
- data/spec/unit/provider/package/bff_spec.rb +1 -0
- data/spec/unit/provider/package/powershell_spec.rb +114 -114
- data/spec/unit/provider/package/rubygems_spec.rb +3 -0
- data/spec/unit/provider/package/solaris_spec.rb +1 -0
- data/spec/unit/provider/service/arch_service_spec.rb +2 -2
- data/spec/unit/provider/service/debian_service_spec.rb +1 -0
- data/spec/unit/provider/service/gentoo_service_spec.rb +1 -0
- data/spec/unit/provider/service/macosx_spec.rb +1 -0
- data/spec/unit/provider/service/redhat_spec.rb +4 -1
- data/spec/unit/provider/service/simple_service_spec.rb +6 -4
- data/spec/unit/provider/user_spec.rb +2 -0
- data/spec/unit/resource/dpkg_package_spec.rb +12 -0
- data/spec/unit/resource/rhsm_register_spec.rb +42 -0
- metadata +9 -7
@@ -10,9 +10,9 @@ describe Chef::Provider::Mount::Linux do
|
|
10
10
|
|
11
11
|
let(:new_resource) do
|
12
12
|
new_resource = Chef::Resource::Mount.new("/tmp/foo")
|
13
|
-
new_resource.device
|
13
|
+
new_resource.device "/dev/sdz1"
|
14
14
|
new_resource.device_type :device
|
15
|
-
new_resource.fstype
|
15
|
+
new_resource.fstype "ext3"
|
16
16
|
new_resource.supports remount: false
|
17
17
|
new_resource
|
18
18
|
end
|
@@ -32,6 +32,7 @@ describe Chef::Provider::Mount::Linux do
|
|
32
32
|
context "to see if the volume is mounted" do
|
33
33
|
|
34
34
|
it "should set mounted true if the mount point is found in the mounts list" do
|
35
|
+
allow(provider).to receive(:shell_out!).with("losetup --list").and_return(double(stdout: "/tmp/foo"))
|
35
36
|
allow(provider).to receive(:shell_out!).and_return(double(stdout: "/tmp/foo /dev/sdz1 type ext3 (rw)\n"))
|
36
37
|
provider.load_current_resource
|
37
38
|
expect(provider.current_resource.mounted).to be_truthy
|
@@ -104,4 +105,16 @@ describe Chef::Provider::Mount::Linux do
|
|
104
105
|
end
|
105
106
|
end
|
106
107
|
|
107
|
-
|
108
|
+
context "to check if loop resource is mounted" do
|
109
|
+
it "should set mounted true in case of loop resource" do
|
110
|
+
new_resource.options "loop"
|
111
|
+
mount = "/tmp/foo /dev/loop16 iso660 cifs ro\n"
|
112
|
+
losetup = "/dev/loop16 0 0 1 1 /dev/sdz1 \n"
|
113
|
+
allow(provider).to receive(:shell_out!).with("findmnt -rn").and_return(double(stdout: mount))
|
114
|
+
allow(provider).to receive(:shell_out!).with("losetup -a").and_return(double(stdout: losetup))
|
115
|
+
provider.load_current_resource
|
116
|
+
expect(provider.current_resource.mounted).to be_truthy
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -61,6 +61,7 @@ describe Chef::Provider::Package::Bff do
|
|
61
61
|
allow(@provider).to receive(:shell_out_compacted).and_return(@empty_status)
|
62
62
|
allow(::File).to receive(:exist?).with(@new_resource.source).and_return(false)
|
63
63
|
@provider.load_current_resource
|
64
|
+
@provider.action = :install
|
64
65
|
@provider.define_resource_requirements
|
65
66
|
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Package)
|
66
67
|
end
|
@@ -17,10 +17,10 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require "spec_helper"
|
20
|
-
require "chef/mixin/
|
20
|
+
require "chef/mixin/powershell_exec"
|
21
21
|
|
22
22
|
describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
23
|
-
include Chef::Mixin::
|
23
|
+
include Chef::Mixin::PowershellExec
|
24
24
|
let(:timeout) { 900 }
|
25
25
|
let(:source) { nil }
|
26
26
|
|
@@ -35,63 +35,63 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
let(:package_xcertificate_installed) do
|
38
|
-
double("
|
38
|
+
double("powershell_exec", result: "2.1.0.0\r\n")
|
39
39
|
end
|
40
40
|
|
41
41
|
let(:package_xcertificate_installed_2_0_0_0) do
|
42
|
-
double("
|
42
|
+
double("powershell_exec", result: "2.0.0.0\r\n")
|
43
43
|
end
|
44
44
|
|
45
45
|
let(:package_xcertificate_available) do
|
46
|
-
double("
|
46
|
+
double("powershell_exec", result: "2.1.0.0\r\n")
|
47
47
|
end
|
48
48
|
|
49
49
|
let(:package_xcertificate_available_2_0_0_0) do
|
50
|
-
double("
|
50
|
+
double("powershell_exec", result: "2.0.0.0\r\n")
|
51
51
|
end
|
52
52
|
|
53
53
|
let(:package_xcertificate_not_installed) do
|
54
|
-
double("
|
54
|
+
double("powershell_exec", result: "")
|
55
55
|
end
|
56
56
|
|
57
57
|
let(:package_xcertificate_not_available) do
|
58
|
-
double("
|
58
|
+
double("powershell_exec", result: "")
|
59
59
|
end
|
60
60
|
|
61
61
|
let(:package_xnetworking_installed) do
|
62
|
-
double("
|
62
|
+
double("powershell_exec", result: "2.12.0.0\r\n")
|
63
63
|
end
|
64
64
|
|
65
65
|
let(:package_xnetworking_installed_2_11_0_0) do
|
66
|
-
double("
|
66
|
+
double("powershell_exec", result: "2.11.0.0\r\n")
|
67
67
|
end
|
68
68
|
|
69
69
|
let(:package_xnetworking_available) do
|
70
|
-
double("
|
70
|
+
double("powershell_exec", result: "2.12.0.0\r\n")
|
71
71
|
end
|
72
72
|
|
73
73
|
let(:package_xnetworking_available_2_11_0_0) do
|
74
|
-
double("
|
74
|
+
double("powershell_exec", result: "2.11.0.0\r\n")
|
75
75
|
end
|
76
76
|
|
77
77
|
let(:package_xnetworking_not_installed) do
|
78
|
-
double("
|
78
|
+
double("powershell_exec", result: "")
|
79
79
|
end
|
80
80
|
|
81
81
|
let(:package_xnetworking_not_available) do
|
82
|
-
double("
|
82
|
+
double("powershell_exec", result: "")
|
83
83
|
end
|
84
84
|
|
85
85
|
let(:package_7zip_available) do
|
86
|
-
double("
|
86
|
+
double("powershell_exec", result: "16.02\r\n")
|
87
87
|
end
|
88
88
|
|
89
89
|
let(:package_7zip_not_installed) do
|
90
|
-
double("
|
90
|
+
double("powershell_exec", result: "")
|
91
91
|
end
|
92
92
|
|
93
93
|
let(:powershell_installed_version) do
|
94
|
-
double("
|
94
|
+
double("powershell_exec", result: "5")
|
95
95
|
end
|
96
96
|
|
97
97
|
let(:tls_set_command) { "if ([Net.ServicePointManager]::SecurityProtocol -lt [Net.SecurityProtocolType]::Tls12) { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 };" }
|
@@ -122,14 +122,14 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
122
122
|
describe "#candidate_version" do
|
123
123
|
|
124
124
|
it "should set the candidate_version to the latest version when not pinning" do
|
125
|
-
allow(provider).to receive(:
|
125
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
126
126
|
new_resource.package_name(["xNetworking"])
|
127
127
|
new_resource.version(nil)
|
128
128
|
expect(provider.candidate_version).to eql(["2.12.0.0"])
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should use the candidate_version from the correct source" do
|
132
|
-
allow(provider).to receive(:
|
132
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
133
133
|
new_resource.package_name(["xNetworking"])
|
134
134
|
new_resource.version(nil)
|
135
135
|
new_resource.source("MyGallery")
|
@@ -137,60 +137,60 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
it "should set the candidate_version to the latest version when not pinning and package name is space separated" do
|
140
|
-
allow(provider).to receive(:
|
140
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
|
141
141
|
new_resource.package_name(["7-Zip 16.02 (x64)"])
|
142
142
|
new_resource.version(nil)
|
143
143
|
expect(provider.candidate_version).to eql(["16.02"])
|
144
144
|
end
|
145
145
|
|
146
146
|
it "should set the candidate_version to pinned version if available" do
|
147
|
-
allow(provider).to receive(:
|
147
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( 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)
|
148
148
|
new_resource.package_name(["xCertificate"])
|
149
149
|
new_resource.version(["2.0.0.0"])
|
150
150
|
expect(provider.candidate_version).to eql(["2.0.0.0"])
|
151
151
|
end
|
152
152
|
|
153
153
|
it "should set the candidate_version to nil if there is no candidate" do
|
154
|
-
allow(provider).to receive(:
|
154
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
155
155
|
new_resource.package_name(["xCertificate"])
|
156
156
|
expect(provider.candidate_version).to eql([nil])
|
157
157
|
end
|
158
158
|
|
159
159
|
it "should set the candidate_version correctly when there are two packages to install" do
|
160
|
-
allow(provider).to receive(:
|
161
|
-
allow(provider).to receive(:
|
160
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
161
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
162
162
|
new_resource.package_name(%w{xCertificate xNetworking})
|
163
163
|
new_resource.version(nil)
|
164
164
|
expect(provider.candidate_version).to eql(["2.1.0.0", "2.12.0.0"])
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should set the candidate_version correctly when only the first is installable" do
|
168
|
-
allow(provider).to receive(:
|
169
|
-
allow(provider).to receive(:
|
168
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
169
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
170
170
|
new_resource.package_name(%w{xCertificate xNetworking})
|
171
171
|
new_resource.version(nil)
|
172
172
|
expect(provider.candidate_version).to eql(["2.1.0.0", nil])
|
173
173
|
end
|
174
174
|
|
175
175
|
it "should set the candidate_version correctly when only the last is installable" do
|
176
|
-
allow(provider).to receive(:
|
177
|
-
allow(provider).to receive(:
|
176
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
177
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
178
178
|
new_resource.package_name(%w{xCertificate xNetworking})
|
179
179
|
new_resource.version(nil)
|
180
180
|
expect(provider.candidate_version).to eql([nil, "2.12.0.0"])
|
181
181
|
end
|
182
182
|
|
183
183
|
it "should set the candidate_version correctly when neither are is installable and version is passed as nil array" do
|
184
|
-
allow(provider).to receive(:
|
185
|
-
allow(provider).to receive(:
|
184
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
185
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
186
186
|
new_resource.package_name(%w{xNetworking xCertificate})
|
187
187
|
new_resource.version([nil, nil])
|
188
188
|
expect(provider.candidate_version).to eql([nil, nil])
|
189
189
|
end
|
190
190
|
|
191
191
|
it "should set the candidate_version correctly when neither are is installable and version is not passed" do
|
192
|
-
allow(provider).to receive(:
|
193
|
-
allow(provider).to receive(:
|
192
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
193
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
194
194
|
new_resource.package_name(%w{xNetworking xCertificate})
|
195
195
|
new_resource.version(nil)
|
196
196
|
expect(provider.candidate_version).to eql([nil, nil])
|
@@ -322,10 +322,10 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
322
322
|
provider.load_current_resource
|
323
323
|
new_resource.package_name(["xCertificate"])
|
324
324
|
new_resource.version(nil)
|
325
|
-
allow(provider).to receive(:
|
326
|
-
allow(provider).to receive(:
|
327
|
-
allow(provider).to receive(:
|
328
|
-
expect(provider).to receive(:
|
325
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
326
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
327
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
328
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
329
329
|
provider.run_action(:install)
|
330
330
|
expect(new_resource).to be_updated_by_last_action
|
331
331
|
end
|
@@ -335,10 +335,10 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
335
335
|
new_resource.package_name(["xCertificate"])
|
336
336
|
new_resource.version(nil)
|
337
337
|
new_resource.source("MyGallery")
|
338
|
-
allow(provider).to receive(:
|
339
|
-
allow(provider).to receive(:
|
340
|
-
allow(provider).to receive(:
|
341
|
-
expect(provider).to receive(:
|
338
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
339
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
340
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
341
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
|
342
342
|
provider.run_action(:install)
|
343
343
|
expect(new_resource).to be_updated_by_last_action
|
344
344
|
end
|
@@ -348,10 +348,10 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
348
348
|
new_resource.package_name(["xCertificate"])
|
349
349
|
new_resource.version(nil)
|
350
350
|
new_resource.skip_publisher_check(true)
|
351
|
-
allow(provider).to receive(:
|
352
|
-
allow(provider).to receive(:
|
353
|
-
allow(provider).to receive(:
|
354
|
-
expect(provider).to receive(:
|
351
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
352
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
353
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
354
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { timeout: new_resource.timeout })
|
355
355
|
provider.run_action(:install)
|
356
356
|
expect(new_resource).to be_updated_by_last_action
|
357
357
|
end
|
@@ -360,10 +360,10 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
360
360
|
provider.load_current_resource
|
361
361
|
new_resource.package_name(["7-Zip 16.02 (x64)"])
|
362
362
|
new_resource.version(nil)
|
363
|
-
allow(provider).to receive(:
|
364
|
-
allow(provider).to receive(:
|
365
|
-
allow(provider).to receive(:
|
366
|
-
expect(provider).to receive(:
|
363
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
|
364
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_not_installed)
|
365
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
366
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 16.02 ).Version", { timeout: new_resource.timeout })
|
367
367
|
provider.run_action(:install)
|
368
368
|
expect(new_resource).to be_updated_by_last_action
|
369
369
|
end
|
@@ -375,10 +375,10 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
375
375
|
provider.load_current_resource
|
376
376
|
new_resource.package_name(["xCertificate"])
|
377
377
|
new_resource.version(nil)
|
378
|
-
allow(provider).to receive(:
|
379
|
-
allow(provider).to receive(:
|
380
|
-
allow(provider).to receive(:
|
381
|
-
expect(provider).to receive(:
|
378
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
379
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
380
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
381
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
382
382
|
provider.run_action(:install)
|
383
383
|
expect(new_resource).to be_updated_by_last_action
|
384
384
|
end
|
@@ -387,9 +387,9 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
387
387
|
it "should not install packages that are up-to-date" do
|
388
388
|
new_resource.package_name(["xCertificate"])
|
389
389
|
new_resource.version(nil)
|
390
|
-
allow(provider).to receive(:
|
391
|
-
allow(provider).to receive(:
|
392
|
-
allow(provider).to receive(:
|
390
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
391
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
392
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
393
393
|
provider.load_current_resource
|
394
394
|
expect(provider).not_to receive(:install_package)
|
395
395
|
provider.run_action(:install)
|
@@ -399,9 +399,9 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
399
399
|
it "should not install packages that are up-to-date" do
|
400
400
|
new_resource.package_name(["xNetworking"])
|
401
401
|
new_resource.version(["2.11.0.0"])
|
402
|
-
allow(provider).to receive(:
|
403
|
-
allow(provider).to receive(:
|
404
|
-
allow(provider).to receive(:
|
402
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
403
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( 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)
|
404
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
405
405
|
provider.load_current_resource
|
406
406
|
expect(provider).not_to receive(:install_package)
|
407
407
|
provider.run_action(:install)
|
@@ -413,13 +413,13 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
413
413
|
# new_version.resource[0]
|
414
414
|
new_resource.package_name(%w{xCertificate xNetworking})
|
415
415
|
new_resource.version([nil, "2.11.0.0"])
|
416
|
-
allow(provider).to receive(:
|
417
|
-
allow(provider).to receive(:
|
418
|
-
allow(provider).to receive(:
|
419
|
-
allow(provider).to receive(:
|
420
|
-
allow(provider).to receive(:
|
421
|
-
expect(provider).to receive(:
|
422
|
-
expect(provider).to receive(:
|
416
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
417
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
418
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( 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)
|
419
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
420
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
421
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
422
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout })
|
423
423
|
provider.load_current_resource
|
424
424
|
provider.run_action(:install)
|
425
425
|
expect(new_resource).to be_updated_by_last_action
|
@@ -428,13 +428,13 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
428
428
|
it "should split up commands when given two packages, one with a version pin" do
|
429
429
|
new_resource.package_name(%w{xCertificate xNetworking})
|
430
430
|
new_resource.version(["2.1.0.0", nil])
|
431
|
-
allow(provider).to receive(:
|
432
|
-
allow(provider).to receive(:
|
433
|
-
allow(provider).to receive(:
|
434
|
-
allow(provider).to receive(:
|
435
|
-
allow(provider).to receive(:
|
436
|
-
expect(provider).to receive(:
|
437
|
-
expect(provider).to receive(:
|
431
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
432
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
433
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
434
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
435
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
436
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
437
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
|
438
438
|
|
439
439
|
provider.load_current_resource
|
440
440
|
provider.run_action(:install)
|
@@ -444,13 +444,13 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
444
444
|
it "should do multipackage installs when given two packages without constraints" do
|
445
445
|
new_resource.package_name(%w{xCertificate xNetworking})
|
446
446
|
new_resource.version(nil)
|
447
|
-
allow(provider).to receive(:
|
448
|
-
allow(provider).to receive(:
|
449
|
-
allow(provider).to receive(:
|
450
|
-
allow(provider).to receive(:
|
451
|
-
allow(provider).to receive(:
|
452
|
-
expect(provider).to receive(:
|
453
|
-
expect(provider).to receive(:
|
447
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
448
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
449
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
450
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
451
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
452
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
453
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
|
454
454
|
provider.load_current_resource
|
455
455
|
provider.run_action(:install)
|
456
456
|
expect(new_resource).to be_updated_by_last_action
|
@@ -460,13 +460,13 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
460
460
|
new_resource.package_name(%w{xCertificate xNetworking})
|
461
461
|
new_resource.version(nil)
|
462
462
|
new_resource.source("MyGallery")
|
463
|
-
allow(provider).to receive(:
|
464
|
-
allow(provider).to receive(:
|
465
|
-
allow(provider).to receive(:
|
466
|
-
allow(provider).to receive(:
|
467
|
-
allow(provider).to receive(:
|
468
|
-
expect(provider).to receive(:
|
469
|
-
expect(provider).to receive(:
|
463
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
464
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
465
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
466
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
467
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
468
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
|
469
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
|
470
470
|
provider.load_current_resource
|
471
471
|
provider.run_action(:install)
|
472
472
|
expect(new_resource).to be_updated_by_last_action
|
@@ -477,10 +477,10 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
477
477
|
new_resource.package_name(["xCertificate"])
|
478
478
|
new_resource.version(nil)
|
479
479
|
new_resource.options(%w{-AcceptLicense -Verbose})
|
480
|
-
allow(provider).to receive(:
|
481
|
-
allow(provider).to receive(:
|
482
|
-
allow(provider).to receive(:
|
483
|
-
expect(provider).to receive(:
|
480
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
481
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
482
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
483
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -AcceptLicense -Verbose ).Version", { timeout: new_resource.timeout })
|
484
484
|
provider.run_action(:install)
|
485
485
|
expect(new_resource).to be_updated_by_last_action
|
486
486
|
end
|
@@ -491,9 +491,9 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
491
491
|
provider.load_current_resource
|
492
492
|
new_resource.package_name(["xCertificate"])
|
493
493
|
new_resource.version(["2.1.0.0"])
|
494
|
-
allow(provider).to receive(:
|
495
|
-
allow(provider).to receive(:
|
496
|
-
allow(provider).to receive(:
|
494
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
495
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
496
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
497
497
|
expect(provider).not_to receive(:remove_package)
|
498
498
|
provider.run_action(:remove)
|
499
499
|
expect(new_resource).not_to be_updated_by_last_action
|
@@ -503,11 +503,11 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
503
503
|
new_resource.package_name(["xCertificate"])
|
504
504
|
new_resource.version(["2.1.0.0"])
|
505
505
|
new_resource.source("MyGallery")
|
506
|
-
allow(provider).to receive(:
|
507
|
-
allow(provider).to receive(:
|
508
|
-
allow(provider).to receive(:
|
506
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
507
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
508
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
509
509
|
provider.load_current_resource
|
510
|
-
expect(provider).to receive(:
|
510
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
511
511
|
provider.run_action(:remove)
|
512
512
|
expect(new_resource).to be_updated_by_last_action
|
513
513
|
end
|
@@ -515,11 +515,11 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
515
515
|
it "does nothing when all the packages are already removed" do
|
516
516
|
new_resource.package_name(%w{xCertificate xNetworking})
|
517
517
|
new_resource.version(nil)
|
518
|
-
allow(provider).to receive(:
|
519
|
-
allow(provider).to receive(:
|
520
|
-
allow(provider).to receive(:
|
521
|
-
allow(provider).to receive(:
|
522
|
-
allow(provider).to receive(:
|
518
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
519
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
520
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
521
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
522
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
523
523
|
provider.load_current_resource
|
524
524
|
expect(provider).not_to receive(:remove_package)
|
525
525
|
provider.run_action(:remove)
|
@@ -529,11 +529,11 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
529
529
|
it "removes a package when version is specified" do
|
530
530
|
new_resource.package_name(["xCertificate"])
|
531
531
|
new_resource.version(["2.1.0.0"])
|
532
|
-
allow(provider).to receive(:
|
533
|
-
allow(provider).to receive(:
|
534
|
-
allow(provider).to receive(:
|
532
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
533
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
534
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
535
535
|
provider.load_current_resource
|
536
|
-
expect(provider).to receive(:
|
536
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
537
537
|
provider.run_action(:remove)
|
538
538
|
expect(new_resource).to be_updated_by_last_action
|
539
539
|
end
|
@@ -541,11 +541,11 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
541
541
|
it "removes a package when version is not specified" do
|
542
542
|
new_resource.package_name(["xCertificate"])
|
543
543
|
new_resource.version(nil)
|
544
|
-
allow(provider).to receive(:
|
545
|
-
allow(provider).to receive(:
|
546
|
-
allow(provider).to receive(:
|
544
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
545
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
546
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
547
547
|
provider.load_current_resource
|
548
|
-
expect(provider).to receive(:
|
548
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
549
549
|
provider.run_action(:remove)
|
550
550
|
expect(new_resource).to be_updated_by_last_action
|
551
551
|
end
|
@@ -553,11 +553,11 @@ describe Chef::Provider::Package::Powershell, :windows_only, :windows_gte_10 do
|
|
553
553
|
it "should remove a package using provided options" do
|
554
554
|
new_resource.package_name(["xCertificate"])
|
555
555
|
new_resource.options(%w{-AllVersions})
|
556
|
-
allow(provider).to receive(:
|
557
|
-
allow(provider).to receive(:
|
558
|
-
allow(provider).to receive(:
|
556
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
557
|
+
allow(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
558
|
+
allow(provider).to receive(:powershell_exec).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
559
559
|
provider.load_current_resource
|
560
|
-
expect(provider).to receive(:
|
560
|
+
expect(provider).to receive(:powershell_exec).with("#{tls_set_command} ( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -AllVersions ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
561
561
|
provider.run_action(:remove)
|
562
562
|
expect(new_resource).to be_updated_by_last_action
|
563
563
|
end
|
@@ -410,6 +410,9 @@ describe Chef::Provider::Package::Rubygems do
|
|
410
410
|
# Rubygems uses these two interally
|
411
411
|
allow(RbConfig::CONFIG).to receive(:[]).with("arch").and_call_original
|
412
412
|
allow(RbConfig::CONFIG).to receive(:[]).with("ruby_install_name").and_call_original
|
413
|
+
allow(RbConfig::CONFIG).to receive(:[]).with("ruby_version").and_call_original
|
414
|
+
allow(RbConfig::CONFIG).to receive(:[]).with("rubylibprefix").and_call_original
|
415
|
+
allow(RbConfig::CONFIG).to receive(:[]).with("vendordir").and_call_original
|
413
416
|
allow(File).to receive(:executable?).and_return false
|
414
417
|
allow(File).to receive(:executable?).with("#{bindir}/gem").and_return true
|
415
418
|
# XXX: we can't stub the provider object directly here because referencing it will create it and that
|
@@ -65,6 +65,7 @@ describe Chef::Provider::Package::Solaris do
|
|
65
65
|
allow(@provider).to receive(:shell_out_compacted).and_return(@status)
|
66
66
|
allow(::File).to receive(:exist?).and_return(false)
|
67
67
|
@provider.load_current_resource
|
68
|
+
@provider.action = :install
|
68
69
|
@provider.define_resource_requirements
|
69
70
|
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Package)
|
70
71
|
end
|
@@ -95,15 +95,15 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
|
|
95
95
|
|
96
96
|
it "should raise error if the node has a nil ps property and no other means to get status" do
|
97
97
|
@node.automatic_attrs[:command] = { ps: nil }
|
98
|
-
@provider.define_resource_requirements
|
99
98
|
@provider.action = :start
|
99
|
+
@provider.define_resource_requirements
|
100
100
|
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should raise error if the node has an empty ps property and no other means to get status" do
|
104
104
|
@node.automatic_attrs[:command] = { ps: "" }
|
105
|
-
@provider.define_resource_requirements
|
106
105
|
@provider.action = :start
|
106
|
+
@provider.define_resource_requirements
|
107
107
|
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
|
108
108
|
end
|
109
109
|
|