diff --git a/lib/win32/certstore/mixin/assertions.rb b/lib/win32/certstore/mixin/assertions.rb index fcfba97..5aa4af4 100644 --- a/lib/win32/certstore/mixin/assertions.rb +++ b/lib/win32/certstore/mixin/assertions.rb @@ -22,8 +22,8 @@ module Mixin module Assertions # Validate certificate store name def validate_store(store_name) - unless valid_store_name.include?(store_name.to_s.upcase) - raise ArgumentError, "Invalid Certificate Store." + if store_name.to_s.strip.empty? + raise ArgumentError, "Empty Certificate Store." end end diff --git a/spec/win32/unit/certstore_spec.rb b/spec/win32/unit/certstore_spec.rb index 7aa0f7d..649a7ae 100644 --- a/spec/win32/unit/certstore_spec.rb +++ b/spec/win32/unit/certstore_spec.rb @@ -29,21 +29,21 @@ context "When passing empty certificate store name" do let(:store_name) { "" } it "raises ArgumentError" do - expect { certstore.open(store_name) }.to raise_error(ArgumentError, "Invalid Certificate Store.") + expect { certstore.open(store_name) }.to raise_error(ArgumentError, "Empty Certificate Store.") end end context "When passing invalid certificate store name" do let(:store_name) { "Chef" } it "raises ArgumentError" do - expect { certstore.open(store_name) }.to raise_error(ArgumentError, "Invalid Certificate Store.") + expect { certstore.open(store_name) }.not_to raise_error(ArgumentError, "Empty Certificate Store.") end end context "When passing nil certificate store name" do let(:store_name) { nil } it "raises ArgumentError" do - expect { certstore.open(store_name) }.to raise_error(ArgumentError, "Invalid Certificate Store.") + expect { certstore.open(store_name) }.to raise_error(ArgumentError, "Empty Certificate Store.") end end @@ -102,7 +102,7 @@ context "When passing empty certificate store name" do let(:store_name) { "" } it "raises ArgumentError" do - expect { certstore.open(store_name) }.to raise_error(ArgumentError, "Invalid Certificate Store.") + expect { certstore.open(store_name) }.to raise_error(ArgumentError, "Empty Certificate Store.") end end @@ -190,7 +190,7 @@ context "When passing empty certificate store name" do let(:store_name) { "" } it "raises ArgumentError" do - expect { certstore.open(store_name) }.to raise_error(ArgumentError, "Invalid Certificate Store.") + expect { certstore.open(store_name) }.to raise_error(ArgumentError, "Empty Certificate Store.") end end @@ -272,7 +272,7 @@ context "When passing empty certificate store name" do let(:store_name) { "" } it "raises ArgumentError" do - expect { certstore.open(store_name) }.to raise_error(ArgumentError, "Invalid Certificate Store.") + expect { certstore.open(store_name) }.to raise_error(ArgumentError, "Empty Certificate Store.") end end diff --git a/spec/win32/unit/store/assertions_spec.rb b/spec/win32/unit/store/assertions_spec.rb index f56c21a..e5fe4e4 100644 --- a/spec/win32/unit/store/assertions_spec.rb +++ b/spec/win32/unit/store/assertions_spec.rb @@ -31,21 +31,21 @@ class Store context "When passing empty certificate store name" do let(:store_name) { "" } it "raises ArgumentError" do - expect { certstore.validate_store(store_name) }.to raise_error("Invalid Certificate Store.") + expect { certstore.validate_store(store_name) }.to raise_error("Empty Certificate Store.") end end context "When passing invalid certificate store name" do let(:store_name) { "Chef" } it "raises ArgumentError" do - expect { certstore.validate_store(store_name) }.to raise_error("Invalid Certificate Store.") + expect { certstore.validate_store(store_name) }.to raise_error("Empty Certificate Store.") end end context "When passing empty certificate store name" do let(:store_name) { nil } it "raises ArgumentError" do - expect { certstore.validate_store(store_name) }.to raise_error("Invalid Certificate Store.") + expect { certstore.validate_store(store_name) }.to raise_error("Empty Certificate Store.") end end