summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Singh <vivek.singh@msystechnologies.com>2019-02-14 14:43:50 +0530
committerTim Smith <tsmith@chef.io>2019-03-04 09:45:06 -0800
commit6e1b0e04a2bac0749c88f8044a97eaf40cf4c0e6 (patch)
treea1af1cc498873f2d67b59d34b7230053c53e211e
parent9fa266b8a3c86b770fe58324f20421743568874e (diff)
downloadchef-6e1b0e04a2bac0749c88f8044a97eaf40cf4c0e6.tar.gz
chocolatey_package private source spec
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
-rw-r--r--spec/unit/provider/package/chocolatey_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb
index 0b504b9a35..ac800212d8 100644
--- a/spec/unit/provider/package/chocolatey_spec.rb
+++ b/spec/unit/provider/package/chocolatey_spec.rb
@@ -313,6 +313,35 @@ describe Chef::Provider::Package::Chocolatey do
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
end
+
+ context "private source" do
+ it "installing a package without auth options throws an error" do
+ allow_remote_list(["package-without-auth"], " -source auth_source")
+ new_resource.package_name("package-without-auth")
+ new_resource.source("auth_source")
+ provider.load_current_resource
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
+ end
+
+ it "installing a package with invalid credentials throws an error" do
+ allow_remote_list(["package-invalid-auth"], " -source auth_source -u user -p password")
+ new_resource.package_name("package-invalid-auth")
+ new_resource.source("auth_source")
+ new_resource.options("-u user -p password")
+ provider.load_current_resource
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
+ end
+
+ it "installing a package with valid credentials" do
+ allow_remote_list(["git"], " -source auth_source -u user -p password")
+ new_resource.source("auth_source")
+ new_resource.options("-u user -p password")
+ provider.load_current_resource
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -u user -p password -source auth_source git", { returns: [0], timeout: timeout }).and_return(double)
+ provider.run_action(:install)
+ expect(new_resource).to be_updated_by_last_action
+ end
+ end
end
describe "#action_upgrade" do