mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
rename renew_api_key to create_api_key
This commit is contained in:
@@ -95,9 +95,8 @@ def update_service(service_id):
|
|||||||
return jsonify(data=service_schema.dump(fetched_service).data), 200
|
return jsonify(data=service_schema.dump(fetched_service).data), 200
|
||||||
|
|
||||||
|
|
||||||
# is this used.
|
|
||||||
@service.route('/<uuid:service_id>/api-key', methods=['POST'])
|
@service.route('/<uuid:service_id>/api-key', methods=['POST'])
|
||||||
def renew_api_key(service_id=None):
|
def create_api_key(service_id=None):
|
||||||
fetched_service = dao_fetch_service_by_id(service_id=service_id)
|
fetched_service = dao_fetch_service_by_id(service_id=service_id)
|
||||||
valid_api_key = api_key_schema.load(request.get_json()).data
|
valid_api_key = api_key_schema.load(request.get_json()).data
|
||||||
valid_api_key.service = fetched_service
|
valid_api_key.service = fetched_service
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def test_api_key_should_create_new_api_key_for_service(notify_api, notify_db,
|
|||||||
with notify_api.test_client() as client:
|
with notify_api.test_client() as client:
|
||||||
data = {'name': 'some secret name', 'created_by': str(sample_service.created_by.id)}
|
data = {'name': 'some secret name', 'created_by': str(sample_service.created_by.id)}
|
||||||
auth_header = create_authorization_header()
|
auth_header = create_authorization_header()
|
||||||
response = client.post(url_for('service.renew_api_key', service_id=sample_service.id),
|
response = client.post(url_for('service.create_api_key', service_id=sample_service.id),
|
||||||
data=json.dumps(data),
|
data=json.dumps(data),
|
||||||
headers=[('Content-Type', 'application/json'), auth_header])
|
headers=[('Content-Type', 'application/json'), auth_header])
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
@@ -34,7 +34,7 @@ def test_api_key_should_return_error_when_service_does_not_exist(notify_api, not
|
|||||||
import uuid
|
import uuid
|
||||||
missing_service_id = uuid.uuid4()
|
missing_service_id = uuid.uuid4()
|
||||||
auth_header = create_authorization_header()
|
auth_header = create_authorization_header()
|
||||||
response = client.post(url_for('service.renew_api_key', service_id=missing_service_id),
|
response = client.post(url_for('service.create_api_key', service_id=missing_service_id),
|
||||||
headers=[('Content-Type', 'application/json'), auth_header])
|
headers=[('Content-Type', 'application/json'), auth_header])
|
||||||
assert response.status_code == 404
|
assert response.status_code == 404
|
||||||
|
|
||||||
@@ -62,14 +62,14 @@ def test_api_key_should_create_multiple_new_api_key_for_service(notify_api, noti
|
|||||||
assert ApiKey.query.count() == 0
|
assert ApiKey.query.count() == 0
|
||||||
data = {'name': 'some secret name', 'created_by': str(sample_service.created_by.id)}
|
data = {'name': 'some secret name', 'created_by': str(sample_service.created_by.id)}
|
||||||
auth_header = create_authorization_header()
|
auth_header = create_authorization_header()
|
||||||
response = client.post(url_for('service.renew_api_key', service_id=sample_service.id),
|
response = client.post(url_for('service.create_api_key', service_id=sample_service.id),
|
||||||
data=json.dumps(data),
|
data=json.dumps(data),
|
||||||
headers=[('Content-Type', 'application/json'), auth_header])
|
headers=[('Content-Type', 'application/json'), auth_header])
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
assert ApiKey.query.count() == 1
|
assert ApiKey.query.count() == 1
|
||||||
data = {'name': 'another secret name', 'created_by': str(sample_service.created_by.id)}
|
data = {'name': 'another secret name', 'created_by': str(sample_service.created_by.id)}
|
||||||
auth_header = create_authorization_header()
|
auth_header = create_authorization_header()
|
||||||
response2 = client.post(url_for('service.renew_api_key', service_id=sample_service.id),
|
response2 = client.post(url_for('service.create_api_key', service_id=sample_service.id),
|
||||||
data=json.dumps(data),
|
data=json.dumps(data),
|
||||||
headers=[('Content-Type', 'application/json'), auth_header])
|
headers=[('Content-Type', 'application/json'), auth_header])
|
||||||
assert response2.status_code == 201
|
assert response2.status_code == 201
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ def test_url_for_update_service(notify_api):
|
|||||||
assert str(url) == '/service/{}'.format(service_id)
|
assert str(url) == '/service/{}'.format(service_id)
|
||||||
|
|
||||||
|
|
||||||
def test_url_for_renew_api_key(notify_api):
|
def test_url_for_create_api_key(notify_api):
|
||||||
with notify_api.test_request_context():
|
with notify_api.test_request_context():
|
||||||
url = url_for('service.renew_api_key', service_id=service_id)
|
url = url_for('service.create_api_key', service_id=service_id)
|
||||||
assert str(url) == '/service/{}/api-key'.format(service_id)
|
assert str(url) == '/service/{}/api-key'.format(service_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user