From 52aae615fa91d27e01948b9e5e1cfa06a32e239c Mon Sep 17 00:00:00 2001 From: Martyn Loughran Date: Thu, 21 Jun 2012 18:25:38 +0100 Subject: [PATCH] Improve some user facing AuthenticationError msgs --- lib/signature.rb | 4 ++-- spec/signature_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/signature.rb b/lib/signature.rb index 60f74fa..9c03289 100644 --- a/lib/signature.rb +++ b/lib/signature.rb @@ -99,10 +99,10 @@ def authenticate_by_token(token, timestamp_grace = 600) def authenticate(timestamp_grace = 600) raise ArgumentError, "Block required" unless block_given? key = @auth_hash['auth_key'] - raise AuthenticationError, "Authentication key required" unless key + raise AuthenticationError, "Missing parameter: auth_key" unless key token = yield key unless token - raise AuthenticationError, "Invalid authentication key" + raise AuthenticationError, "Unknown auth_key" end authenticate_by_token!(token, timestamp_grace) return token diff --git a/spec/signature_spec.rb b/spec/signature_spec.rb index 918974e..8b9ccc4 100644 --- a/spec/signature_spec.rb +++ b/spec/signature_spec.rb @@ -180,14 +180,14 @@ request = Signature::Request.new('POST', '/some/path', @params) lambda { request.authenticate { |key| nil } - }.should raise_error('Authentication key required') + }.should raise_error('Missing parameter: auth_key') end it "should raise error if block returns nil (i.e. key doesn't exist)" do request = Signature::Request.new('POST', '/some/path', @params) lambda { request.authenticate { |key| nil } - }.should raise_error('Invalid authentication key') + }.should raise_error('Unknown auth_key') end it "should raise unless block given" do