Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

passing specs for rescuing the Rack::OAuth2::Client::Error and raisin…

…g a Shutl::Auth::InvalidCredentials error
  • Loading branch information...
commit e92e58a3c63893b994f1accf1befdfd7697e990e 1 parent a34d300
@markburns markburns authored
Showing with 14 additions and 14 deletions.
  1. +14 −14 lib/shutl/auth/access_token_request.rb
View
28 lib/shutl/auth/access_token_request.rb
@@ -9,14 +9,22 @@ def access_token!
end
def access_token_response!
+ c = client
+
Shutl::NetworkRetry.retry "Authentication Service Error" do
- client.access_token!
+ begin
+ c.access_token!
+ rescue Rack::OAuth2::Client::Error
+ raise_invalid_credentials
+ end
end
end
private
def client
+ check uri
+
Rack::OAuth2::Client.new \
identifier: Shutl::Auth.client_id,
secret: Shutl::Auth.client_secret,
@@ -24,28 +32,20 @@ def client
host: uri.host,
port: uri.port,
scheme: uri.scheme
-
- rescue Rack::OAuth2::Client::Error => e
- debugger
- puts e.message
- raise_invalid_credentials
-
- rescue Exception => e
- debugger
- puts e.message
-
end
- def uri
- check URI Shutl::Auth.url
- rescue URI::InvalidURIError
+ def uri
+ URI Shutl::Auth.url
+ rescue
raise_invalid_uri
end
def check uri
return uri if uri and uri.host and uri.scheme
+ raise_invalid_uri
+ rescue
raise_invalid_uri
end
Please sign in to comment.
Something went wrong with that request. Please try again.