Skip to content

Commit

Permalink
Improve some user facing AuthenticationError msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
mloughran committed Jun 21, 2012
1 parent 5d60ec9 commit 52aae61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/signature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 52aae61

Please sign in to comment.