diff --git a/lib/vmfloaty/auth.rb b/lib/vmfloaty/auth.rb index 2afc170..b68e22d 100644 --- a/lib/vmfloaty/auth.rb +++ b/lib/vmfloaty/auth.rb @@ -19,7 +19,7 @@ class Auth def self.delete_token(verbose, url, user, password, token) if token.nil? - STDERR.puts 'You did not provide a token' + raise TokenError, 'You did not provide a token' end conn = Http.get_conn_with_auth(verbose, url, user, password) @@ -35,7 +35,7 @@ class Auth def self.token_status(verbose, url, token) if token.nil? - STDERR.puts 'You did not provide a token' + raise TokenError, 'You did not provide a token' end conn = Http.get_conn(verbose, url) diff --git a/spec/vmfloaty/auth_spec.rb b/spec/vmfloaty/auth_spec.rb index c6e1d98..bcd246e 100644 --- a/spec/vmfloaty/auth_spec.rb +++ b/spec/vmfloaty/auth_spec.rb @@ -51,6 +51,10 @@ describe Pooler do expect{ Auth.delete_token(false, @vmpooler_url, "first.last", "password", @token) }.to raise_error(TokenError) end + + it "raises a token error if no token provided" do + expect{ Auth.delete_token(false, @vmpooler_url, "first.last", "password", nil) }.to raise_error(TokenError) + end end describe "#token_status" do @@ -74,5 +78,9 @@ describe Pooler do expect{ Auth.token_status(false, @vmpooler_url, @token) }.to raise_error(TokenError) end + + it "raises a token error if no token provided" do + expect{ Auth.token_status(false, @vmpooler_url, nil) }.to raise_error(TokenError) + end end end