Skip to content

Commit

Permalink
Reverting the error handling for a missing item on cert_lookup
Browse files Browse the repository at this point in the history
Signed-off-by: John McCrae <[email protected]>
  • Loading branch information
John McCrae committed May 9, 2022
1 parent 0ae9ca2 commit 7f7c461
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/win32/certstore/store_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def cert_lookup_by_token(search_token, store_name: @store_name, store_location:
powershell_exec!(powershell_cmd, :powershell, timeout: timeout).result

rescue ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed
raise ArgumentError, "Certificate not found while looking for certificate : #{search_token} in store : #{store_name} at this location : #{store_location}"
return "Certificate not found"
end

# To close and destroy pointer of open certificate store handler
Expand Down
10 changes: 10 additions & 0 deletions spec/win32/unit/certstore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@
end
end

describe "#cert_lookup_by_token" do
context "when searching for a certificate that does not exist" do
let(:store_name) { "root" }
it "returns a message of Certificate not found" do
store = certstore.open(store_name, store_location: store_location)
expect(store.cert_lookup_by_token("nunya")).to eql("Certificate not found")
end
end
end

describe "#cert_validate" do
context "When passing empty certificate store name to the CurrentUser store" do
let(:store_name) { "" }
Expand Down

0 comments on commit 7f7c461

Please sign in to comment.