rename renew_api_key to create_api_key

This commit is contained in:
Leo Hemsted
2016-06-23 16:44:57 +01:00
parent ed5bdb7be8
commit f371c393a2
3 changed files with 7 additions and 8 deletions

View File

@@ -95,9 +95,8 @@ def update_service(service_id):
return jsonify(data=service_schema.dump(fetched_service).data), 200
# is this used.
@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)
valid_api_key = api_key_schema.load(request.get_json()).data
valid_api_key.service = fetched_service

View File

@@ -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:
data = {'name': 'some secret name', 'created_by': str(sample_service.created_by.id)}
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),
headers=[('Content-Type', 'application/json'), auth_header])
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
missing_service_id = uuid.uuid4()
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])
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
data = {'name': 'some secret name', 'created_by': str(sample_service.created_by.id)}
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),
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()
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),
headers=[('Content-Type', 'application/json'), auth_header])
assert response2.status_code == 201

View File

@@ -34,7 +34,7 @@ def test_url_for_update_service(notify_api):
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():
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)