Merge pull request #477 from alphagov/remove-default-key-type

remove default key_type
This commit is contained in:
Leo Hemsted
2016-06-28 15:15:19 +01:00
committed by GitHub
2 changed files with 6 additions and 4 deletions

View File

@@ -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

View File

@@ -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):