Rewrite authentication error messages more English

This commit is contained in:
Chris Hill-Scott
2016-09-16 08:45:48 +01:00
parent 1ce91997e8
commit d44a0b72bb
2 changed files with 4 additions and 4 deletions

View File

@@ -46,7 +46,7 @@ def requires_auth():
continue continue
if api_key.expiry_date: if api_key.expiry_date:
raise AuthError("Invalid token: revoked", 403) raise AuthError("Invalid token: API key revoked", 403)
_request_ctx_stack.top.api_user = api_key _request_ctx_stack.top.api_user = api_key
return return
@@ -57,7 +57,7 @@ def requires_auth():
raise AuthError("Invalid token: service not found", 403) raise AuthError("Invalid token: service not found", 403)
if not api_keys: if not api_keys:
raise AuthError("Invalid token: no api keys for service", 403) raise AuthError("Invalid token: service has no API keys", 403)
else: else:
raise AuthError("Invalid token: signature", 403) raise AuthError("Invalid token: signature", 403)

View File

@@ -169,7 +169,7 @@ def test_authentication_returns_token_expired_when_service_uses_expired_key_and_
headers={'Authorization': 'Bearer {}'.format(token)}) headers={'Authorization': 'Bearer {}'.format(token)})
assert response.status_code == 403 assert response.status_code == 403
data = json.loads(response.get_data()) data = json.loads(response.get_data())
assert data['message'] == {"token": ['Invalid token: revoked']} assert data['message'] == {"token": ['Invalid token: API key revoked']}
def test_authentication_returns_error_when_admin_client_has_no_secrets(notify_api, def test_authentication_returns_error_when_admin_client_has_no_secrets(notify_api,
@@ -230,7 +230,7 @@ def test_authentication_returns_error_when_service_has_no_secrets(notify_api,
headers={'Authorization': 'Bearer {}'.format(token)}) headers={'Authorization': 'Bearer {}'.format(token)})
assert response.status_code == 403 assert response.status_code == 403
error_message = json.loads(response.get_data()) error_message = json.loads(response.get_data())
assert error_message['message'] == {'token': ['Invalid token: no api keys for service']} assert error_message['message'] == {'token': ['Invalid token: service has no API keys']}
def test_should_attach_the_current_api_key_to_current_app(notify_api, sample_service, sample_api_key): def test_should_attach_the_current_api_key_to_current_app(notify_api, sample_service, sample_api_key):