chef 12.16.42-universal-mingw32 → 12.17.44-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/README.md +20 -5
- data/Rakefile +17 -0
- data/VERSION +1 -1
- data/acceptance/Gemfile.lock +32 -23
- data/distro/common/markdown/man1/knife-configure.mkd +3 -2
- data/lib-backcompat/chef/chef_fs/file_system/already_exists_error.rb +1 -1
- data/lib-backcompat/chef/chef_fs/file_system/cookbook_frozen_error.rb +1 -1
- data/lib-backcompat/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb +1 -1
- data/lib-backcompat/chef/chef_fs/file_system/file_system_error.rb +1 -1
- data/lib-backcompat/chef/chef_fs/file_system/must_delete_recursively_error.rb +1 -1
- data/lib-backcompat/chef/chef_fs/file_system/not_found_error.rb +1 -1
- data/lib-backcompat/chef/chef_fs/file_system/operation_failed_error.rb +1 -1
- data/lib-backcompat/chef/chef_fs/file_system/operation_not_allowed_error.rb +1 -1
- data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +1 -1
- data/lib-backcompat/chef/chef_fs/file_system/repository/file_system_root_dir.rb +1 -1
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +1 -1
- data/lib/chef/application/exit_code.rb +3 -3
- data/lib/chef/chef_class.rb +15 -5
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +12 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +19 -0
- data/lib/chef/client.rb +1 -0
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/cookbook_version.rb +4 -4
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/data_collector.rb +20 -13
- data/lib/chef/data_collector/messages.rb +0 -1
- data/lib/chef/data_collector/messages/helpers.rb +2 -2
- data/lib/chef/decorator/unchain.rb +2 -2
- data/lib/chef/deprecated.rb +190 -0
- data/lib/chef/deprecation/provider/remote_directory.rb +1 -1
- data/lib/chef/deprecation/warnings.rb +3 -4
- data/lib/chef/dsl/method_missing.rb +2 -2
- data/lib/chef/dsl/resources.rb +2 -2
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/formatters/base.rb +11 -1
- data/lib/chef/formatters/doc.rb +13 -4
- data/lib/chef/key.rb +1 -1
- data/lib/chef/knife/client_delete.rb +12 -9
- data/lib/chef/knife/configure.rb +1 -1
- data/lib/chef/knife/core/bootstrap_context.rb +25 -1
- data/lib/chef/knife/core/subcommand_loader.rb +3 -3
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/knife/node_delete.rb +6 -6
- data/lib/chef/log.rb +1 -1
- data/lib/chef/mixin/deprecation.rb +4 -10
- data/lib/chef/mixin/powershell_type_coercions.rb +19 -19
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/node.rb +2 -2
- data/lib/chef/node/attribute.rb +3 -4
- data/lib/chef/node/common_api.rb +1 -1
- data/lib/chef/node/mixin/state_tracking.rb +5 -2
- data/lib/chef/node_map.rb +2 -2
- data/lib/chef/org.rb +1 -1
- data/lib/chef/platform/rebooter.rb +3 -1
- data/lib/chef/policy_builder/expand_node_object.rb +1 -1
- data/lib/chef/property.rb +5 -5
- data/lib/chef/provider.rb +4 -4
- data/lib/chef/provider/launchd.rb +1 -1
- data/lib/chef/provider/link.rb +6 -0
- data/lib/chef/provider/mount.rb +2 -0
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/ohai.rb +5 -3
- data/lib/chef/provider/package/cab.rb +1 -1
- data/lib/chef/provider/package/chocolatey.rb +2 -2
- data/lib/chef/provider/package/easy_install.rb +2 -2
- data/lib/chef/provider/package/msu.rb +162 -0
- data/lib/chef/provider/package/powershell.rb +114 -0
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/yum_repository.rb +6 -7
- data/lib/chef/provider_resolver.rb +2 -2
- data/lib/chef/providers.rb +2 -0
- data/lib/chef/resource.rb +3 -5
- data/lib/chef/resource/apt_update.rb +1 -1
- data/lib/chef/resource/chef_gem.rb +2 -3
- data/lib/chef/resource/file/verification.rb +1 -1
- data/lib/chef/resource/launchd.rb +48 -8
- data/lib/chef/resource/mount.rb +1 -1
- data/lib/chef/resource/msu_package.rb +47 -0
- data/lib/chef/resource/ohai.rb +5 -25
- data/lib/chef/resource/powershell_package.rb +41 -0
- data/lib/chef/resource/reboot.rb +1 -1
- data/lib/chef/resource/user.rb +2 -2
- data/lib/chef/resource_builder.rb +4 -4
- data/lib/chef/resource_resolver.rb +2 -3
- data/lib/chef/resources.rb +2 -0
- data/lib/chef/rest.rb +1 -1
- data/lib/chef/role.rb +1 -1
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/shell/ext.rb +2 -2
- data/lib/chef/user.rb +3 -3
- data/lib/chef/user_v1.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/security.rb +12 -12
- data/spec/data/sample_msu1.xml +10 -0
- data/spec/data/sample_msu2.xml +14 -0
- data/spec/data/sample_msu3.xml +16 -0
- data/spec/functional/rebooter_spec.rb +3 -3
- data/spec/functional/resource/link_spec.rb +62 -1
- data/spec/functional/resource/msu_package_spec.rb +84 -0
- data/spec/functional/resource/registry_spec.rb +3 -3
- data/spec/functional/resource/rpm_spec.rb +7 -10
- data/spec/integration/solo/solo_spec.rb +50 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/platform_helpers.rb +16 -8
- data/spec/unit/application/exit_code_spec.rb +3 -15
- data/spec/unit/data_collector_spec.rb +6 -16
- data/spec/unit/deprecated_spec.rb +59 -0
- data/spec/unit/deprecation_spec.rb +1 -8
- data/spec/unit/handler_spec.rb +2 -2
- data/spec/unit/knife/client_delete_spec.rb +16 -0
- data/spec/unit/knife/configure_spec.rb +1 -1
- data/spec/unit/knife/cookbook_metadata_spec.rb +116 -113
- data/spec/unit/knife/core/bootstrap_context_spec.rb +55 -5
- data/spec/unit/knife/node_delete_spec.rb +19 -10
- data/spec/unit/mixin/shell_out_spec.rb +0 -1
- data/spec/unit/node/immutable_collections_spec.rb +5 -0
- data/spec/unit/node/vivid_mash_spec.rb +11 -0
- data/spec/unit/node_spec.rb +2 -2
- data/spec/unit/provider/launchd_spec.rb +81 -3
- data/spec/unit/provider/mount/mount_spec.rb +1 -1
- data/spec/unit/provider/mount_spec.rb +7 -0
- data/spec/unit/provider/package/chocolatey_spec.rb +5 -5
- data/spec/unit/provider/package/easy_install_spec.rb +6 -6
- data/spec/unit/provider/package/msu_spec.rb +283 -0
- data/spec/unit/provider/package/powershell_spec.rb +337 -0
- data/spec/unit/provider/service/macosx_spec.rb +1 -1
- data/spec/unit/provider/subversion_spec.rb +9 -0
- data/spec/unit/provider/user/linux_spec.rb +7 -1
- data/spec/unit/recipe_spec.rb +43 -11
- data/spec/unit/resource/apt_update_spec.rb +17 -25
- data/spec/unit/resource/file/verification_spec.rb +1 -1
- data/spec/unit/resource/mount_spec.rb +2 -1
- data/spec/unit/resource/msu_package_spec.rb +49 -0
- data/spec/unit/resource/ohai_spec.rb +1 -1
- data/spec/unit/resource/powershell_package_spec.rb +68 -0
- data/spec/unit/resource_reporter_spec.rb +4 -4
- data/spec/unit/run_status_spec.rb +1 -1
- data/tasks/announce.rb +58 -0
- data/tasks/changelog.rb +26 -6
- data/tasks/templates/prerelease.md.erb +35 -0
- data/tasks/templates/release.md.erb +34 -0
- metadata +21 -4
@@ -0,0 +1,337 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Dheeraj Dubey(<dheeraj.dubey@msystechnologies.com>)
|
3
|
+
# Copyright:: Copyright 2008-2016, Chef Software, Inc.
|
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
|
+
require "chef/mixin/powershell_out"
|
21
|
+
|
22
|
+
describe Chef::Provider::Package::Powershell do
|
23
|
+
include Chef::Mixin::PowershellOut
|
24
|
+
let(:timeout) { 900 }
|
25
|
+
|
26
|
+
let(:new_resource) { Chef::Resource::PowershellPackage.new("windows_test_pkg") }
|
27
|
+
|
28
|
+
let(:provider) do
|
29
|
+
node = Chef::Node.new
|
30
|
+
events = Chef::EventDispatch::Dispatcher.new
|
31
|
+
run_context = Chef::RunContext.new(node, {}, events)
|
32
|
+
Chef::Provider::Package::Powershell.new(new_resource, run_context)
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:package_xcertificate_installed) do
|
36
|
+
double("powershell_out", :stdout => "2.1.0.0\r\n")
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:package_xcertificate_installed_2_0_0_0) do
|
40
|
+
double("powershell_out", :stdout => "2.0.0.0\r\n")
|
41
|
+
end
|
42
|
+
|
43
|
+
let(:package_xcertificate_available) do
|
44
|
+
double("powershell_out", :stdout => "2.1.0.0\r\n")
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:package_xcertificate_available_2_0_0_0) do
|
48
|
+
double("powershell_out", :stdout => "2.0.0.0\r\n")
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:package_xcertificate_not_installed) do
|
52
|
+
double("powershell_out", :stdout => "")
|
53
|
+
end
|
54
|
+
|
55
|
+
let(:package_xcertificate_not_available) do
|
56
|
+
double("powershell_out", :stdout => "")
|
57
|
+
end
|
58
|
+
|
59
|
+
let(:package_xnetworking_installed) do
|
60
|
+
double("powershell_out", :stdout => "2.12.0.0\r\n")
|
61
|
+
end
|
62
|
+
|
63
|
+
let(:package_xnetworking_installed_2_11_0_0) do
|
64
|
+
double("powershell_out", :stdout => "2.11.0.0\r\n")
|
65
|
+
end
|
66
|
+
|
67
|
+
let(:package_xnetworking_available) do
|
68
|
+
double("powershell_out", :stdout => "2.12.0.0\r\n")
|
69
|
+
end
|
70
|
+
|
71
|
+
let(:package_xnetworking_available_2_11_0_0) do
|
72
|
+
double("powershell_out", :stdout => "2.11.0.0\r\n")
|
73
|
+
end
|
74
|
+
|
75
|
+
let(:package_xnetworking_not_installed) do
|
76
|
+
double("powershell_out", :stdout => "")
|
77
|
+
end
|
78
|
+
|
79
|
+
let(:package_xnetworking_not_available) do
|
80
|
+
double("powershell_out", :stdout => "")
|
81
|
+
end
|
82
|
+
|
83
|
+
let(:package_7zip_available) do
|
84
|
+
double("powershell_out", :stdout => "16.02\r\n")
|
85
|
+
end
|
86
|
+
|
87
|
+
let(:package_7zip_not_installed) do
|
88
|
+
double("powershell_out", :stdout => "")
|
89
|
+
end
|
90
|
+
|
91
|
+
let(:powershell_installed_version) do
|
92
|
+
double("powershell_out", :stdout => "5")
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#initialize" do
|
96
|
+
it "should return the correct class" do
|
97
|
+
expect(provider).to be_kind_of(Chef::Provider::Package::Powershell)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "#candidate_version" do
|
102
|
+
|
103
|
+
it "should set the candidate_version to the latest version when not pinning" do
|
104
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
|
105
|
+
new_resource.package_name(["xNetworking"])
|
106
|
+
new_resource.version(nil)
|
107
|
+
expect(provider.candidate_version).to eql(["2.12.0.0"])
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should set the candidate_version to the latest version when not pinning and package name is space seperated" do
|
111
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package '7-Zip 16.02 (x64)' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_7zip_available)
|
112
|
+
new_resource.package_name(["7-Zip 16.02 (x64)"])
|
113
|
+
new_resource.version(nil)
|
114
|
+
expect(provider.candidate_version).to eql(["16.02"])
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should set the candidate_version to pinned version if available" do
|
118
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -RequiredVersion 2.0.0.0 -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0)
|
119
|
+
new_resource.package_name(["xCertificate"])
|
120
|
+
new_resource.version(["2.0.0.0"])
|
121
|
+
expect(provider.candidate_version).to eql(["2.0.0.0"])
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should set the candidate_version to nil if there is no candidate" do
|
125
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
126
|
+
new_resource.package_name(["xCertificate"])
|
127
|
+
expect(provider.candidate_version).to eql([nil])
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should set the candidate_version correctly when there are two packages to install" do
|
131
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
132
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
|
133
|
+
new_resource.package_name(%w{xCertificate xNetworking})
|
134
|
+
new_resource.version(nil)
|
135
|
+
expect(provider.candidate_version).to eql(["2.1.0.0", "2.12.0.0"])
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should set the candidate_version correctly when only the first is installable" do
|
139
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
140
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
|
141
|
+
new_resource.package_name(%w{xCertificate xNetworking})
|
142
|
+
new_resource.version(nil)
|
143
|
+
expect(provider.candidate_version).to eql(["2.1.0.0", nil])
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should set the candidate_version correctly when only the last is installable" do
|
147
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
148
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
|
149
|
+
new_resource.package_name(%w{xCertificate xNetworking})
|
150
|
+
new_resource.version(nil)
|
151
|
+
expect(provider.candidate_version).to eql([nil, "2.12.0.0"])
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should set the candidate_version correctly when neither are is installable and version is passed as nil array" do
|
155
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
156
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
|
157
|
+
new_resource.package_name(%w{xNetworking xCertificate})
|
158
|
+
new_resource.version([nil, nil])
|
159
|
+
expect(provider.candidate_version).to eql([nil, nil])
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should set the candidate_version correctly when neither are is installable and version is not passed" do
|
163
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
164
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
|
165
|
+
new_resource.package_name(%w{xNetworking xCertificate})
|
166
|
+
new_resource.version(nil)
|
167
|
+
expect(provider.candidate_version).to eql([nil, nil])
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "#action_install" do
|
173
|
+
it "should install a single package" do
|
174
|
+
provider.load_current_resource
|
175
|
+
new_resource.package_name(["xCertificate"])
|
176
|
+
new_resource.version(nil)
|
177
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
178
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
179
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
180
|
+
expect(provider).to receive(:powershell_out).with("Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0", { :timeout => new_resource.timeout })
|
181
|
+
provider.run_action(:install)
|
182
|
+
expect(new_resource).to be_updated_by_last_action
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should install a single package when package name has space in between" do
|
186
|
+
provider.load_current_resource
|
187
|
+
new_resource.package_name(["7-Zip 16.02 (x64)"])
|
188
|
+
new_resource.version(nil)
|
189
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package '7-Zip 16.02 (x64)' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_7zip_available)
|
190
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name '7-Zip 16.02 (x64)' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_7zip_not_installed)
|
191
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
192
|
+
expect(provider).to receive(:powershell_out).with("Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -RequiredVersion 16.02", { :timeout => new_resource.timeout })
|
193
|
+
provider.run_action(:install)
|
194
|
+
expect(new_resource).to be_updated_by_last_action
|
195
|
+
end
|
196
|
+
|
197
|
+
context "when changing the timeout to 3600" do
|
198
|
+
let(:timeout) { 3600 }
|
199
|
+
it "sets the timeout on shell_out commands" do
|
200
|
+
new_resource.timeout(timeout)
|
201
|
+
provider.load_current_resource
|
202
|
+
new_resource.package_name(["xCertificate"])
|
203
|
+
new_resource.version(nil)
|
204
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
205
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
206
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
207
|
+
expect(provider).to receive(:powershell_out).with("Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0", { :timeout => new_resource.timeout })
|
208
|
+
provider.run_action(:install)
|
209
|
+
expect(new_resource).to be_updated_by_last_action
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
it "should not install packages that are up-to-date" do
|
214
|
+
new_resource.package_name(["xCertificate"])
|
215
|
+
new_resource.version(nil)
|
216
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
217
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
218
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
219
|
+
provider.load_current_resource
|
220
|
+
expect(provider).not_to receive(:install_package)
|
221
|
+
provider.run_action(:install)
|
222
|
+
expect(new_resource).not_to be_updated_by_last_action
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should not install packages that are up-to-date" do
|
226
|
+
new_resource.package_name(["xNetworking"])
|
227
|
+
new_resource.version(["2.11.0.0"])
|
228
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xNetworking' -RequiredVersion 2.11.0.0 -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
229
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xNetworking' -RequiredVersion 2.11.0.0 -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
|
230
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
231
|
+
provider.load_current_resource
|
232
|
+
expect(provider).not_to receive(:install_package)
|
233
|
+
provider.run_action(:install)
|
234
|
+
expect(new_resource).not_to be_updated_by_last_action
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should handle complicated cases when the name/version array is pruned" do
|
238
|
+
# implicitly test that we correctly pick up new_resource.version[1] instead of
|
239
|
+
# new_version.resource[0]
|
240
|
+
new_resource.package_name(%w{xCertificate xNetworking})
|
241
|
+
new_resource.version([nil, "2.11.0.0"])
|
242
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
243
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
244
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xNetworking' -RequiredVersion 2.11.0.0 -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
|
245
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xNetworking' -RequiredVersion 2.11.0.0 -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
|
246
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
247
|
+
expect(provider).to receive(:powershell_out).with("Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0", { :timeout => new_resource.timeout })
|
248
|
+
expect(provider).to receive(:powershell_out).with("Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0", { :timeout => new_resource.timeout })
|
249
|
+
provider.load_current_resource
|
250
|
+
provider.run_action(:install)
|
251
|
+
expect(new_resource).to be_updated_by_last_action
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should split up commands when given two packages, one with a version pin" do
|
255
|
+
new_resource.package_name(%w{xCertificate xNetworking})
|
256
|
+
new_resource.version(["2.1.0.0", nil])
|
257
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -RequiredVersion 2.1.0.0 -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
258
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xCertificate' -RequiredVersion 2.1.0.0 -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
259
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
|
260
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
|
261
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
262
|
+
expect(provider).to receive(:powershell_out).with("Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0", { :timeout => new_resource.timeout })
|
263
|
+
expect(provider).to receive(:powershell_out).with("Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0", { :timeout => new_resource.timeout })
|
264
|
+
|
265
|
+
provider.load_current_resource
|
266
|
+
provider.run_action(:install)
|
267
|
+
expect(new_resource).to be_updated_by_last_action
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should do multipackage installs when given two packages without constraints" do
|
271
|
+
new_resource.package_name(%w{xCertificate xNetworking})
|
272
|
+
new_resource.version(nil)
|
273
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
274
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
275
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
|
276
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
|
277
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
278
|
+
expect(provider).to receive(:powershell_out).with("Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0", { :timeout => new_resource.timeout })
|
279
|
+
expect(provider).to receive(:powershell_out).with("Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0", { :timeout => new_resource.timeout })
|
280
|
+
provider.load_current_resource
|
281
|
+
provider.run_action(:install)
|
282
|
+
expect(new_resource).to be_updated_by_last_action
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
describe "#action_remove" do
|
287
|
+
it "does nothing when the package is already removed" do
|
288
|
+
provider.load_current_resource
|
289
|
+
new_resource.package_name(["xCertificate"])
|
290
|
+
new_resource.version(["2.1.0.0"])
|
291
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -RequiredVersion 2.1.0.0 -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
292
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xCertificate' -RequiredVersion 2.1.0.0 -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
293
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
294
|
+
expect(provider).not_to receive(:remove_package)
|
295
|
+
provider.run_action(:remove)
|
296
|
+
expect(new_resource).not_to be_updated_by_last_action
|
297
|
+
end
|
298
|
+
|
299
|
+
it "does nothing when all the packages are already removed" do
|
300
|
+
new_resource.package_name(%w{xCertificate xNetworking})
|
301
|
+
new_resource.version(nil)
|
302
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
303
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
304
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
|
305
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xNetworking' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
|
306
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
307
|
+
provider.load_current_resource
|
308
|
+
expect(provider).not_to receive(:remove_package)
|
309
|
+
provider.run_action(:remove)
|
310
|
+
expect(new_resource).not_to be_updated_by_last_action
|
311
|
+
end
|
312
|
+
|
313
|
+
it "removes a package when version is specified" do
|
314
|
+
new_resource.package_name(["xCertificate"])
|
315
|
+
new_resource.version(["2.1.0.0"])
|
316
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -RequiredVersion 2.1.0.0 -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
317
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xCertificate' -RequiredVersion 2.1.0.0 -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
318
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
319
|
+
provider.load_current_resource
|
320
|
+
expect(provider).to receive(:powershell_out).with("Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0", { :timeout => new_resource.timeout })
|
321
|
+
provider.run_action(:remove)
|
322
|
+
expect(new_resource).to be_updated_by_last_action
|
323
|
+
end
|
324
|
+
|
325
|
+
it "removes a package when version is not specified" do
|
326
|
+
new_resource.package_name(["xCertificate"])
|
327
|
+
new_resource.version(nil)
|
328
|
+
allow(provider).to receive(:powershell_out).with("(Find-Package 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
329
|
+
allow(provider).to receive(:powershell_out).with("(Get-Package -Name 'xCertificate' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
|
330
|
+
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
331
|
+
provider.load_current_resource
|
332
|
+
expect(provider).to receive(:powershell_out).with("(Uninstall-Package 'xCertificate' -Force -ForceBootstrap | select version | Format-Table -HideTableHeaders | Out-String).Trim()", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
|
333
|
+
provider.run_action(:remove)
|
334
|
+
expect(new_resource).to be_updated_by_last_action
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
@@ -32,6 +32,15 @@ describe Chef::Provider::Subversion do
|
|
32
32
|
@events = Chef::EventDispatch::Dispatcher.new
|
33
33
|
@run_context = Chef::RunContext.new(@node, {}, @events)
|
34
34
|
@provider = Chef::Provider::Subversion.new(@resource, @run_context)
|
35
|
+
@original_env = ENV.to_hash
|
36
|
+
# Generated command lines would include any environmental proxies
|
37
|
+
ENV.delete("http_proxy")
|
38
|
+
ENV.delete("https_proxy")
|
39
|
+
end
|
40
|
+
|
41
|
+
after do
|
42
|
+
ENV.clear
|
43
|
+
ENV.update(@original_env)
|
35
44
|
end
|
36
45
|
|
37
46
|
it "converts resource attributes to options for run_command and popen4" do
|
@@ -67,9 +67,15 @@ describe Chef::Provider::User::Linux do
|
|
67
67
|
expect( @new_resource.supports[:non_unique] ).to be false
|
68
68
|
end
|
69
69
|
|
70
|
+
it "throws a deprecation warning on setting supports[:non_unique]" do
|
71
|
+
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
72
|
+
expect(Chef).to receive(:deprecated).with(:supports_property, "supports { non_unique: true } on the user resource is deprecated and will be removed in Chef 13, set non_unique true instead")
|
73
|
+
@new_resource.supports( { :non_unique => true } )
|
74
|
+
end
|
75
|
+
|
70
76
|
it "throws a deprecation warning on setting supports[:manage_home]" do
|
71
77
|
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
72
|
-
expect(Chef).to receive(:
|
78
|
+
expect(Chef).to receive(:deprecated).with(:supports_property, "supports { manage_home: true } on the user resource is deprecated and will be removed in Chef 13, set manage_home true instead")
|
73
79
|
@new_resource.supports( { :manage_home => true } )
|
74
80
|
end
|
75
81
|
|
data/spec/unit/recipe_spec.rb
CHANGED
@@ -193,9 +193,41 @@ describe Chef::Recipe do
|
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
196
|
+
describe "when resource cloning is disabled" do
|
197
|
+
def not_expect_warning
|
198
|
+
expect(Chef::Log).not_to receive(:warn).with(/3694/)
|
199
|
+
expect(Chef::Log).not_to receive(:warn).with(/Previous/)
|
200
|
+
expect(Chef::Log).not_to receive(:warn).with(/Current/)
|
201
|
+
end
|
202
|
+
|
203
|
+
before do
|
204
|
+
Chef::Config[:resource_cloning] = false
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should emit a 3694 warning when attributes change" do
|
208
|
+
recipe.zen_master "klopp" do
|
209
|
+
something "bvb"
|
210
|
+
end
|
211
|
+
not_expect_warning
|
212
|
+
recipe.zen_master "klopp" do
|
213
|
+
something "vbv"
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should not copy attributes from a prior resource" do
|
218
|
+
recipe.zen_master "klopp" do
|
219
|
+
something "bvb"
|
220
|
+
end
|
221
|
+
not_expect_warning
|
222
|
+
recipe.zen_master "klopp"
|
223
|
+
expect(run_context.resource_collection.first.something).to eql("bvb")
|
224
|
+
expect(run_context.resource_collection[1].something).to be nil
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
196
228
|
describe "when cloning resources" do
|
197
229
|
def expect_warning
|
198
|
-
expect(Chef).to receive(:
|
230
|
+
expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/)
|
199
231
|
end
|
200
232
|
|
201
233
|
it "should emit a 3694 warning when attributes change" do
|
@@ -242,7 +274,7 @@ describe Chef::Recipe do
|
|
242
274
|
|
243
275
|
it "should not emit a 3694 warning for completely trivial resource cloning" do
|
244
276
|
recipe.zen_master "klopp"
|
245
|
-
expect(Chef).to_not receive(:
|
277
|
+
expect(Chef).to_not receive(:deprecated)
|
246
278
|
recipe.zen_master "klopp"
|
247
279
|
end
|
248
280
|
|
@@ -250,7 +282,7 @@ describe Chef::Recipe do
|
|
250
282
|
recipe.zen_master "klopp" do
|
251
283
|
action :nothing
|
252
284
|
end
|
253
|
-
expect(Chef).to_not receive(:
|
285
|
+
expect(Chef).to_not receive(:deprecated)
|
254
286
|
recipe.zen_master "klopp" do
|
255
287
|
action :score
|
256
288
|
end
|
@@ -260,7 +292,7 @@ describe Chef::Recipe do
|
|
260
292
|
recipe.zen_master "klopp" do
|
261
293
|
action :score
|
262
294
|
end
|
263
|
-
expect(Chef).to_not receive(:
|
295
|
+
expect(Chef).to_not receive(:deprecated)
|
264
296
|
recipe.zen_master "klopp" do
|
265
297
|
action :nothing
|
266
298
|
end
|
@@ -283,7 +315,7 @@ describe Chef::Recipe do
|
|
283
315
|
|
284
316
|
it "does not emit 3694 when the name_property is unlazied by running it at compile_time" do
|
285
317
|
recipe.coerced "string"
|
286
|
-
expect(Chef).to_not receive(:
|
318
|
+
expect(Chef).to_not receive(:deprecated)
|
287
319
|
recipe.coerced "string"
|
288
320
|
end
|
289
321
|
|
@@ -319,7 +351,7 @@ describe Chef::Recipe do
|
|
319
351
|
end
|
320
352
|
|
321
353
|
it "will insert another resource if create_if_missing is not set (cloned resource as of Chef-12)" do
|
322
|
-
expect(Chef).to receive(:
|
354
|
+
expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/)
|
323
355
|
zm_resource
|
324
356
|
recipe.declare_resource(:zen_master, "klopp")
|
325
357
|
expect(run_context.resource_collection.count).to eql(2)
|
@@ -442,18 +474,18 @@ describe Chef::Recipe do
|
|
442
474
|
end
|
443
475
|
|
444
476
|
it "copies attributes from the first resource" do
|
445
|
-
expect(Chef).to receive(:
|
477
|
+
expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/)
|
446
478
|
expect(duplicated_resource.something).to eq("bvb09")
|
447
479
|
end
|
448
480
|
|
449
481
|
it "does not copy the action from the first resource" do
|
450
|
-
expect(Chef).to receive(:
|
482
|
+
expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/)
|
451
483
|
expect(original_resource.action).to eq([:score])
|
452
484
|
expect(duplicated_resource.action).to eq([:nothing])
|
453
485
|
end
|
454
486
|
|
455
487
|
it "does not copy the source location of the first resource" do
|
456
|
-
expect(Chef).to receive(:
|
488
|
+
expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/)
|
457
489
|
# sanity check source location:
|
458
490
|
expect(original_resource.source_line).to include(__FILE__)
|
459
491
|
expect(duplicated_resource.source_line).to include(__FILE__)
|
@@ -462,12 +494,12 @@ describe Chef::Recipe do
|
|
462
494
|
end
|
463
495
|
|
464
496
|
it "sets the cookbook name on the cloned resource to that resource's cookbook" do
|
465
|
-
expect(Chef).to receive(:
|
497
|
+
expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/)
|
466
498
|
expect(duplicated_resource.cookbook_name).to eq("second_cb")
|
467
499
|
end
|
468
500
|
|
469
501
|
it "sets the recipe name on the cloned resource to that resoure's recipe" do
|
470
|
-
expect(Chef).to receive(:
|
502
|
+
expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/)
|
471
503
|
expect(duplicated_resource.recipe_name).to eq("second_recipe")
|
472
504
|
end
|
473
505
|
|