diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 919ad7d..b909cd2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,15 +1,15 @@ # This configuration was generated by `rubocop --auto-gen-config` -# on 2015-04-23 09:39:10 -0700 using RuboCop version 0.30.0. +# on 2015-04-23 11:18:24 -0700 using RuboCop version 0.30.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 4 +# Offense count: 3 Metrics/AbcSize: Max: 24 # Offense count: 6 # Configuration parameters: CountComments. Metrics/MethodLength: - Max: 12 + Max: 13 diff --git a/lib/googleauth/compute_engine.rb b/lib/googleauth/compute_engine.rb index 358130a..76fc92f 100644 --- a/lib/googleauth/compute_engine.rb +++ b/lib/googleauth/compute_engine.rb @@ -89,15 +89,16 @@ END c = options[:connection] || Faraday.default_connection c.headers = { 'Metadata-Flavor' => 'Google' } resp = c.get(COMPUTE_AUTH_TOKEN_URI) - if resp.status == 404 + case resp.status + when 200 + Signet::OAuth2.parse_credentials(resp.body, + resp.headers['content-type']) + when 404 fail(Signet::AuthorizationError, NO_METADATA_SERVER_ERROR) - end - if resp.status != 200 + else msg = "Unexpected error code #{resp.status}" + UNEXPECTED_ERROR_SUFFIX fail(Signet::AuthorizationError, msg) end - Signet::OAuth2.parse_credentials(resp.body, - resp.headers['content-type']) end end end