Skip to content

Commit

Permalink
Merge pull request collectiveidea#30 from gfeil/master
Browse files Browse the repository at this point in the history
Treat an invalid subdomain as an authentication failure
  • Loading branch information
danielmorrison committed Oct 10, 2011
2 parents a6b2b0d + 3355796 commit 6df5073
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/faraday/response/raise_on_authentication_failure.rb
Expand Up @@ -4,7 +4,7 @@
module Faraday
class Response::RaiseOnAuthenticationFailure < Response::Middleware
def on_complete(response)
raise Tinder::AuthenticationFailed if response[:status] == 401
raise Tinder::AuthenticationFailed if [401, 404].include?(response[:status])
end
end
end
9 changes: 9 additions & 0 deletions spec/tinder/connection_spec.rb
Expand Up @@ -12,6 +12,15 @@
lambda { connection.get('/rooms.json') }.should raise_error(Tinder::AuthenticationFailed)
end

it "should raise an exception when an invalid subdomain is specified" do
stub_connection(Tinder::Connection) do |stub|
stub.get("/rooms.json") {[404, {}, "Not found"]}
end

connection = Tinder::Connection.new('test', :token => 'foo')
lambda { connection.get('/rooms.json') }.should raise_error(Tinder::AuthenticationFailed)
end

it "should lookup token when username/password provided" do
stub_connection(Tinder::Connection) do |stub|
stub.get("/users/me.json") {[200, {}, fixture('users/me.json')]}
Expand Down

0 comments on commit 6df5073

Please sign in to comment.