summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJohn McCrae <jmccrae@chf.io>2022-05-09 19:22:57 +0600
committerJohn McCrae <jmccrae@chf.io>2022-05-24 08:31:24 +0600
commit70bfdf25cf7862ddb6aa53d17311ea3fe3fabd9c (patch)
tree742508725536cc209ce7f6b2f2905e3826bceb58 /spec
parentd04de476b9d58c2496adb09459573b93f0db537a (diff)
downloadchef-70bfdf25cf7862ddb6aa53d17311ea3fe3fabd9c.tar.gz
Updated windows_certificate resource to account for bugs and updates in the win32-certstore gem
Signed-off-by: John McCrae <jmccrae@chf.io>
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/resource/windows_certificate_spec.rb27
1 files changed, 15 insertions, 12 deletions
diff --git a/spec/functional/resource/windows_certificate_spec.rb b/spec/functional/resource/windows_certificate_spec.rb
index df2d1cbec8..9552d559b3 100644
--- a/spec/functional/resource/windows_certificate_spec.rb
+++ b/spec/functional/resource/windows_certificate_spec.rb
@@ -89,7 +89,9 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
end
- after { delete_store }
+ after do
+ delete_store
+ end
describe "action: create" do
it "starts with no certificates" do
@@ -195,7 +197,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
create_store
end
it "fails with no certificates in the store" do
- expect(Chef::Log).to receive(:info).with("Certificate not found")
+ expect(Chef::Log).to receive(:info).with("Certificate not valid")
resource.source = tests_thumbprint
resource.run_action(:verify)
@@ -219,7 +221,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
end
it "fails with an invalid thumbprint" do
- expect(Chef::Log).to receive(:info).with("Certificate not found")
+ expect(Chef::Log).to receive(:info).with("Certificate not valid")
resource.source = others_thumbprint
resource.run_action(:verify)
@@ -253,7 +255,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
end
it "fails with an invalid thumbprint" do
- expect(Chef::Log).to receive(:info).with("Certificate not found")
+ expect(Chef::Log).to receive(:info).with("Certificate not valid")
resource.source = others_thumbprint
resource.run_action(:verify)
@@ -265,11 +267,11 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
describe "action: fetch" do
context "with no certificate in the store" do
- it "throws an error with no certificates in the store" do
- expect(Chef::Log).not_to receive(:info)
+ it "logs a debug error with no certificates in the store" do
+ expect(Chef::Log).to receive(:debug).with("Certificate Not Found")
resource.source = others_thumbprint
resource.output_path = cert_output_path
- expect { resource.run_action :fetch }.to raise_error(ArgumentError)
+ resource.run_action(:fetch)
end
end
@@ -288,7 +290,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
end
it "fails with an invalid thumbprint" do
- expect(Chef::Log).not_to receive(:info)
+ expect(Chef::Log).to receive(:debug).with("Certificate Not Found")
resource.source = others_thumbprint
@@ -296,7 +298,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
path = File.join(dir, "test.pem")
resource.output_path = path
- expect { resource.run_action :fetch }.to raise_error(ArgumentError)
+ resource.run_action(:fetch)
end
end
@@ -340,9 +342,10 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
end
describe "action: delete" do
- it "throws an argument error when attempting to delete a certificate that doesn't exist" do
+ it "logs an error when attempting to delete a certificate that doesn't exist" do
+ expect(Chef::Log).to receive(:debug).with("Certificate Not Found")
resource.source = tests_thumbprint
- expect { resource.run_action :delete }.to raise_error(ArgumentError)
+ resource.run_action(:delete)
end
it "deletes an existing certificate while leaving other certificates alone" do
@@ -360,7 +363,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
expect(certificate_count).to eq(1)
expect(resource).to be_updated_by_last_action
- expect { resource.run_action :delete }.to raise_error(ArgumentError)
+ expect { resource.run_action :delete }.not_to raise_error
expect(certificate_count).to eq(1)
expect(resource).not_to be_updated_by_last_action