Skip to content

Commit

Permalink
Changes what kaggle_secrets expects to receive from Web Tier, looks f…
Browse files Browse the repository at this point in the history
…or wasSuccessful field.
  • Loading branch information
vimota committed Feb 26, 2019
1 parent ed0dea4 commit a16bc4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions patches/kaggle_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def _make_post_request(self, data):
try:
with urllib.request.urlopen(req) as response:
response_json = json.loads(response.read())
return response_json
if not response_json.get('wasSuccessful') or 'result' not in response_json:
raise BackendError(
'Unexpected response from the service.')
return response_json['result']
except urllib.error.HTTPError as e:
if e.code == 401 or e.code == 403:
raise CredentialError(f'Service responded with error code {e.code}.'
Expand All @@ -57,7 +60,7 @@ def get_bigquery_access_token(self):
'Target': self.BIGQUERY_TARGET_VALUE
}
response_json = self._make_post_request(request_body)
if 'Secret' not in response_json:
if 'secret' not in response_json:
raise BackendError(
'Unexpected response from the service.')
return response_json['Secret']
return response_json['secret']
2 changes: 1 addition & 1 deletion tests/test_user_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def set_request(self):
_request['headers'] = self.headers

def get_response(self):
return {"Secret": secret}
return {'result': {'secret': secret, 'secretType': 'refreshToken', 'secretProvider': 'google'}, 'wasSuccessful': True}

env = EnvironmentVarGuard()
env.set(_KAGGLE_USER_SECRETS_TOKEN_ENV_VAR_NAME, _TEST_JWT)
Expand Down

0 comments on commit a16bc4b

Please sign in to comment.