Merge pull request #275 from alphagov/fix-auth-bug

This pull request fixes a bug in authentication.
This commit is contained in:
Rebecca Law
2016-04-29 14:52:20 +01:00
3 changed files with 25 additions and 2 deletions

View File

@@ -273,6 +273,27 @@ def test_authentication_returns_error_when_api_client_has_no_secrets(notify_api,
notify_api.config['ADMIN_CLIENT_SECRET'] = api_secret
def test_authentication_returns_error_when_service_has_no_secrets(notify_api,
notify_db,
notify_db_session,
sample_service,
fake_uuid):
with notify_api.test_request_context():
with notify_api.test_client() as client:
token = create_jwt_token(
request_method="GET",
request_path='/service',
secret=fake_uuid,
client_id=str(sample_service.id))
response = client.get(
'/service',
headers={'Authorization': 'Bearer {}'.format(token)})
assert response.status_code == 403
error_message = json.loads(response.get_data())
assert error_message['message'] == 'Invalid token: signature'
def __create_get_token(service_id):
if service_id:
return create_jwt_token(request_method="GET",