From c32a77840fbe09abf01ff2510aecdc30a6012812 Mon Sep 17 00:00:00 2001 From: piyushawasthi Date: Mon, 9 Jul 2018 05:32:04 -0700 Subject: [PATCH] Removed store validation Signed-off-by: piyushawasthi --- lib/win32/certstore/mixin/assertions.rb | 4 ++-- spec/win32/unit/certstore_spec.rb | 12 ++++++------ spec/win32/unit/store/assertions_spec.rb | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) 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..a5a7c2b 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 + context "When passing new certificate store name" do let(:store_name) { "Chef" } - it "raises ArgumentError" do - expect { certstore.validate_store(store_name) }.to raise_error("Invalid Certificate Store.") + it "not raises ArgumentError" do + expect { certstore.validate_store(store_name) }.not_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