This is a temporary endpoint to get history of service and api key

updates. This will be surfaced on a simple log page on admin app
until product team work out who/how/when etc. of viewing history
data.
This commit is contained in:
Adam Shimali
2016-04-21 16:32:20 +01:00
parent 68eabd0676
commit 7378352c26
3 changed files with 74 additions and 0 deletions

View File

@@ -981,3 +981,28 @@ def test_cannot_remove_only_user_from_service(notify_api,
assert resp.status_code == 400
result = json.loads(resp.get_data(as_text=True))
assert result['message'] == 'You cannot remove the only user for a service'
# This test is just here verify get_service_and_api_key_history that is a temp solution
# until proper ui is sorted out on admin app
def test_get_service_and_api_key_history(notify_api, notify_db, notify_db_session, sample_service):
from tests.app.conftest import sample_api_key as create_sample_api_key
api_key = create_sample_api_key(notify_db, notify_db_session, service=sample_service)
with notify_api.test_request_context():
with notify_api.test_client() as client:
auth_header = create_authorization_header(
path='/service/{}/history'.format(sample_service.id),
method='GET'
)
response = client.get(
path='/service/{}/history'.format(sample_service.id),
headers=[auth_header]
)
assert response.status_code == 200
json_resp = json.loads(response.get_data(as_text=True))
assert json_resp['data']['service_history'][0]['id'] == str(sample_service.id)
assert json_resp['data']['api_key_history'][0]['id'] == str(api_key.id)