mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 08:21:13 -05:00
Merge pull request #477 from alphagov/remove-default-key-type
remove default key_type
This commit is contained in:
@@ -165,7 +165,7 @@ class NotificationsStatisticsSchema(BaseSchema):
|
||||
class ApiKeySchema(BaseSchema):
|
||||
|
||||
created_by = field_for(models.ApiKey, 'created_by', required=True)
|
||||
key_type = field_for(models.ApiKey, 'key_type', required=True, missing=models.KEY_TYPE_NORMAL)
|
||||
key_type = field_for(models.ApiKey, 'key_type', required=True)
|
||||
|
||||
class Meta:
|
||||
model = models.ApiKey
|
||||
|
||||
@@ -40,7 +40,7 @@ def test_api_key_should_return_error_when_service_does_not_exist(notify_api, sam
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
def test_create_api_key_should_set_default_key_type_of_normal(notify_api, sample_service):
|
||||
def test_create_api_key_without_key_type_rejects(notify_api, sample_service):
|
||||
with notify_api.test_request_context(), notify_api.test_client() as client:
|
||||
data = {
|
||||
'name': 'some secret name',
|
||||
@@ -50,8 +50,10 @@ def test_create_api_key_should_set_default_key_type_of_normal(notify_api, sample
|
||||
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.one().key_type == KEY_TYPE_NORMAL
|
||||
assert response.status_code == 400
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
assert json_resp['result'] == 'error'
|
||||
assert json_resp['message'] == {'key_type': ['Missing data for required field.']}
|
||||
|
||||
|
||||
def test_revoke_should_expire_api_key_for_service(notify_api, sample_api_key):
|
||||
|
||||
Reference in New Issue
Block a user