summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-10-19 09:12:13 -0700
committerGitHub <noreply@github.com>2020-10-19 09:12:13 -0700
commit71990f4a440476743bd42912cf013af423f25a99 (patch)
tree2a5af027cec69a115802a5e1dade546d2c7ad3f0
parent564055b5c262599162de2b567465bc61a9921fd5 (diff)
parent031cf947d5f126be2b4b28f5521104f5f0291961 (diff)
downloadchef-71990f4a440476743bd42912cf013af423f25a99.tar.gz
Merge pull request #10526 from MsysTechnologiesllc/antima/functional_test_for_windows_package_with_remote_file_attributes
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--spec/functional/resource/windows_package_spec.rb46
1 files changed, 36 insertions, 10 deletions
diff --git a/spec/functional/resource/windows_package_spec.rb b/spec/functional/resource/windows_package_spec.rb
index 3294e1c509..5fed41e9ae 100644
--- a/spec/functional/resource/windows_package_spec.rb
+++ b/spec/functional/resource/windows_package_spec.rb
@@ -25,6 +25,10 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
let(:pkg_version) { nil }
let(:pkg_type) { nil }
let(:pkg_options) { nil }
+ let(:remote_file_attributes) { nil }
+ let(:run_context) do
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+ end
subject do
new_resource = Chef::Resource::WindowsPackage.new(pkg_name, run_context)
@@ -33,13 +37,14 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
new_resource.installer_type pkg_type
new_resource.options pkg_options
new_resource.checksum pkg_checksum
+ new_resource.remote_file_attributes
new_resource
end
describe "install package" do
let(:pkg_name) { "Microsoft Visual C++ 2005 Redistributable" }
- let(:pkg_checksum) { "d6832398e3bc9156a660745f427dc1c2392ce4e9a872e04f41f62d0c6bae07a8" }
- let(:pkg_path) { "https://download.microsoft.com/download/6/B/B/6BB661D6-A8AE-4819-B79F-236472F6070C/vcredist_x86.exe" }
+ let(:pkg_checksum) { "4ee4da0fe62d5fa1b5e80c6e6d88a4a2f8b3b140c35da51053d0d7b72a381d29" }
+ let(:pkg_path) { "https://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x86.EXE" }
let(:pkg_checksum) { nil }
let(:pkg_type) { :custom }
let(:pkg_options) { "/Q" }
@@ -55,9 +60,9 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
end
context "installing additional version" do
- let(:pkg_path) { "https://download.microsoft.com/download/e/1/c/e1c773de-73ba-494a-a5ba-f24906ecf088/vcredist_x86.exe" }
- let(:pkg_checksum) { "eb00f891919d4f894ab725b158459db8834470c382dc60cd3c3ee2c6de6da92c" }
- let(:pkg_version) { "8.0.56336" }
+ let(:pkg_path) { "https://download.microsoft.com/download/6/B/B/6BB661D6-A8AE-4819-B79F-236472F6070C/vcredist_x86.exe" }
+ let(:pkg_checksum) { "d6832398e3bc9156a660745f427dc1c2392ce4e9a872e04f41f62d0c6bae07a8" }
+ let(:pkg_version) { "8.0.59193" }
it "installs older version" do
subject.run_action(:install)
@@ -69,14 +74,14 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
subject { Chef::Resource::WindowsPackage.new(pkg_name, run_context) }
context "multiple versions and a version given to remove" do
- before { subject.version("8.0.56336") }
+ before { subject.version("8.0.59193") }
it "removes specified version" do
subject.run_action(:remove)
expect(subject).to be_updated_by_last_action
prov = subject.provider_for_action(:remove)
prov.load_current_resource
- expect(prov.current_version_array).to eq([["8.0.59193"]])
+ expect(prov.current_version_array).to eq([["8.0.61001"]])
end
end
@@ -101,8 +106,8 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
install1.run_action(:install)
install2 = Chef::Resource::WindowsPackage.new(pkg_name, run_context)
- install2.source "https://download.microsoft.com/download/e/1/c/e1c773de-73ba-494a-a5ba-f24906ecf088/vcredist_x86.exe"
- install2.version "8.0.56336"
+ install2.source "https://download.microsoft.com/download/6/B/B/6BB661D6-A8AE-4819-B79F-236472F6070C/vcredist_x86.exe"
+ install2.version "8.0.59193"
install2.installer_type pkg_type
install2.options pkg_options
install2.run_action(:install)
@@ -135,7 +140,7 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
context "inno" do
let(:pkg_name) { "Mercurial 3.6.1 (64-bit)" }
- let(:pkg_path) { "http://mercurial.selenic.com/release/windows/Mercurial-3.6.1-x64.exe" }
+ let(:pkg_path) { "https://www.mercurial-scm.org/release/windows/Mercurial-3.6.1-x64.exe" }
let(:pkg_checksum) { "febd29578cb6736163d232708b834a2ddd119aa40abc536b2c313fc5e1b5831d" }
it "finds the correct installer type" do
@@ -164,4 +169,25 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
expect(subject).to be_updated_by_last_action
end
end
+
+ describe "install package with remote_file_attributes" do
+ let(:pkg_name) { "7zip" }
+ let(:pkg_path) { "http://www.7-zip.org/a/7z938-x64.msi" }
+ let(:remote_file_attributes) {
+ {
+ path: ::File.join(Chef::Config[:file_cache_path], "7zip.msi"),
+ checksum: "7c8e873991c82ad9cfcdbdf45254ea6101e9a645e12977dcd518979e50fdedf3",
+ }
+ }
+
+ it "installs the package" do
+ subject.run_action(:install)
+ expect(subject).to be_updated_by_last_action
+ end
+
+ it "uninstalls the package" do
+ subject.run_action(:remove)
+ expect(subject).to be_updated_by_last_action
+ end
+ end
end