mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
Rewrite authentication error messages more English
This commit is contained in:
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
Reference in New Issue
Block a user