diff options
author | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-02-14 14:43:50 +0530 |
---|---|---|
committer | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-02-14 14:43:50 +0530 |
commit | be801c5e0b4fc2e88d540712ff7ff6a93b887125 (patch) | |
tree | de615db1ffbd485ec94a1905030e7317ac10d785 | |
parent | 661bb89cad49656711cac0ee40003b4856f999dc (diff) | |
download | chef-be801c5e0b4fc2e88d540712ff7ff6a93b887125.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.rb | 29 |
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 |