mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
Update python client to version 1.0.0.
This version of the client removed the request method, path and body from the encode and decode methods. The biggest changes here is to the unit tests.
This commit is contained in:
@@ -16,10 +16,7 @@ def test_api_key_should_create_new_api_key_for_service(notify_api, notify_db,
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
data = {'name': 'some secret name', 'created_by': str(sample_service.created_by.id)}
|
||||
auth_header = create_authorization_header(path=url_for('service.renew_api_key',
|
||||
service_id=sample_service.id),
|
||||
method='POST',
|
||||
request_body=json.dumps(data))
|
||||
auth_header = create_authorization_header()
|
||||
response = client.post(url_for('service.renew_api_key', service_id=sample_service.id),
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
@@ -36,9 +33,7 @@ def test_api_key_should_return_error_when_service_does_not_exist(notify_api, not
|
||||
with notify_api.test_client() as client:
|
||||
import uuid
|
||||
missing_service_id = uuid.uuid4()
|
||||
auth_header = create_authorization_header(path=url_for('service.renew_api_key',
|
||||
service_id=missing_service_id),
|
||||
method='POST')
|
||||
auth_header = create_authorization_header()
|
||||
response = client.post(url_for('service.renew_api_key', service_id=missing_service_id),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
assert response.status_code == 404
|
||||
@@ -49,10 +44,7 @@ def test_revoke_should_expire_api_key_for_service(notify_api, notify_db, notify_
|
||||
with notify_api.test_request_context():
|
||||
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,
|
||||
api_key_id=sample_api_key.id),
|
||||
method='POST')
|
||||
auth_header = create_authorization_header()
|
||||
response = client.post(url_for('service.revoke_api_key',
|
||||
service_id=sample_api_key.service_id,
|
||||
api_key_id=sample_api_key.id),
|
||||
@@ -69,20 +61,14 @@ def test_api_key_should_create_multiple_new_api_key_for_service(notify_api, noti
|
||||
with notify_api.test_client() as client:
|
||||
assert ApiKey.query.count() == 0
|
||||
data = {'name': 'some secret name', 'created_by': str(sample_service.created_by.id)}
|
||||
auth_header = create_authorization_header(path=url_for('service.renew_api_key',
|
||||
service_id=sample_service.id),
|
||||
method='POST',
|
||||
request_body=json.dumps(data))
|
||||
auth_header = create_authorization_header()
|
||||
response = client.post(url_for('service.renew_api_key', service_id=sample_service.id),
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
assert response.status_code == 201
|
||||
assert ApiKey.query.count() == 1
|
||||
data = {'name': 'another secret name', 'created_by': str(sample_service.created_by.id)}
|
||||
auth_header = create_authorization_header(path=url_for('service.renew_api_key',
|
||||
service_id=sample_service.id),
|
||||
method='POST',
|
||||
request_body=json.dumps(data))
|
||||
auth_header = create_authorization_header()
|
||||
response2 = client.post(url_for('service.renew_api_key', service_id=sample_service.id),
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
@@ -115,9 +101,7 @@ def test_get_api_keys_should_return_all_keys_for_service(notify_api, notify_db,
|
||||
|
||||
assert ApiKey.query.count() == 4
|
||||
|
||||
auth_header = create_authorization_header(path=url_for('service.get_api_keys',
|
||||
service_id=sample_api_key.service_id),
|
||||
method='GET')
|
||||
auth_header = create_authorization_header()
|
||||
response = client.get(url_for('service.get_api_keys',
|
||||
service_id=sample_api_key.service_id),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
@@ -131,10 +115,7 @@ def test_get_api_keys_should_return_one_key_for_service(notify_api, notify_db,
|
||||
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')
|
||||
auth_header = create_authorization_header()
|
||||
response = client.get(url_for('service.get_api_keys',
|
||||
service_id=sample_api_key.service_id,
|
||||
key_id=sample_api_key.id),
|
||||
|
||||
Reference in New Issue
Block a user