1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

fix a bug in the CredentialType field validator that breaks required

see: #6769
This commit is contained in:
Ryan Petrello 2017-06-30 12:23:44 -04:00
parent de84f3cf4a
commit dade5c12a7
2 changed files with 28 additions and 0 deletions

View File

@ -542,6 +542,10 @@ class CredentialTypeInputField(JSONSchemaField):
'type': 'object',
'additionalProperties': False,
'properties': {
'required': {
'type': 'array',
'items': {'type': 'string'}
},
'fields': {
'type': 'array',
'items': {

View File

@ -170,6 +170,30 @@ def test_create_with_valid_inputs(get, post, admin):
assert fields[0]['type'] == 'string'
@pytest.mark.django_db
def test_create_with_required_inputs(get, post, admin):
response = post(reverse('api:credential_type_list'), {
'kind': 'cloud',
'name': 'MyCloud',
'inputs': {
'fields': [{
'id': 'api_token',
'label': 'API Token',
'type': 'string',
'secret': True
}],
'required': ['api_token'],
},
'injectors': {}
}, admin)
assert response.status_code == 201
response = get(reverse('api:credential_type_list'), admin)
assert response.data['count'] == 1
required = response.data['results'][0]['inputs']['required']
assert required == ['api_token']
@pytest.mark.django_db
@pytest.mark.parametrize('inputs', [
True,