mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
Merge pull request #6830 from ryanpetrello/fix-6769
fix a bug in the CredentialType field validator that breaks `required`
This commit is contained in:
commit
e82596c0da
@ -542,6 +542,10 @@ class CredentialTypeInputField(JSONSchemaField):
|
||||
'type': 'object',
|
||||
'additionalProperties': False,
|
||||
'properties': {
|
||||
'required': {
|
||||
'type': 'array',
|
||||
'items': {'type': 'string'}
|
||||
},
|
||||
'fields': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user