mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Updated get_api_keys endpoint to return one or many given key_id or not.
This commit is contained in:
@@ -113,3 +113,21 @@ def test_get_api_keys_should_return_all_keys_for_service(notify_api, notify_db,
|
||||
assert response.status_code == 200
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
assert len(json_resp['apiKeys']) == 3
|
||||
|
||||
|
||||
def test_get_api_keys_should_return_one_key_for_service(notify_api, notify_db,
|
||||
notify_db_session,
|
||||
sample_api_key):
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
auth_header = create_authorization_header(path=url_for('service.get_api_keys',
|
||||
service_id=sample_api_key.service_id,
|
||||
key_id=sample_api_key.id),
|
||||
method='GET')
|
||||
response = client.get(url_for('service.get_api_keys',
|
||||
service_id=sample_api_key.service_id,
|
||||
key_id=sample_api_key.id),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
assert response.status_code == 200
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
assert len(json_resp['apiKeys']) == 1
|
||||
|
||||
@@ -281,11 +281,12 @@ def test_get_user_service_user_not_exists(notify_api, notify_db, notify_db_sessi
|
||||
with notify_api.test_client() as client:
|
||||
assert Service.query.count() == 2
|
||||
auth_header = create_authorization_header(service_id=sample_admin_service_id,
|
||||
path=url_for('user.get_service_by_user_id', user_id="123",
|
||||
path=url_for('user.get_service_by_user_id', user_id="123423",
|
||||
service_id=sample_service.id),
|
||||
method='GET')
|
||||
print('** service users{}'.format(sample_service.users[0].id))
|
||||
resp = client.get(
|
||||
url_for('user.get_service_by_user_id', user_id="123", service_id=sample_service.id),
|
||||
url_for('user.get_service_by_user_id', user_id="123423", service_id=sample_service.id),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
assert resp.status_code == 404
|
||||
json_resp = json.loads(resp.get_data(as_text=True))
|
||||
@@ -303,10 +304,10 @@ def test_get_user_service_service_not_exists(notify_api, notify_db, notify_db_se
|
||||
assert Service.query.count() == 2
|
||||
auth_header = create_authorization_header(service_id=sample_admin_service_id,
|
||||
path=url_for('user.get_service_by_user_id', user_id=user.id,
|
||||
service_id="123"),
|
||||
service_id="12323423"),
|
||||
method='GET')
|
||||
resp = client.get(
|
||||
url_for('user.get_service_by_user_id', user_id=user.id, service_id="123"),
|
||||
url_for('user.get_service_by_user_id', user_id=user.id, service_id="12323423"),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
assert resp.status_code == 404
|
||||
json_resp = json.loads(resp.get_data(as_text=True))
|
||||
|
||||
Reference in New Issue
Block a user