Update api-key/revoke endpoint to expire the key for the service.

Previously we assumed there was only one api key that was valid.
This commit is contained in:
Rebecca Law
2016-01-20 14:48:44 +00:00
parent 4a3fae7580
commit 2689d908c1
4 changed files with 22 additions and 34 deletions

View File

@@ -43,12 +43,15 @@ def test_revoke_should_expire_api_key_for_service(notify_api, notify_db, notify_
with notify_api.test_client() as client:
assert ApiKey.query.count() == 1
auth_header = create_authorization_header(path=url_for('service.revoke_api_key',
service_id=sample_api_key.service_id),
service_id=sample_api_key.service_id,
api_key_id=sample_api_key.id),
method='POST')
response = client.post(url_for('service.revoke_api_key', service_id=sample_api_key.service_id),
response = client.post(url_for('service.revoke_api_key',
service_id=sample_api_key.service_id,
api_key_id=sample_api_key.id),
headers=[auth_header])
assert response.status_code == 202
api_keys_for_service = ApiKey.query.filter_by(service_id=sample_api_key.service_id).first()
api_keys_for_service = ApiKey.query.get(sample_api_key.id)
assert api_keys_for_service.expiry_date is not None