mirror of
https://github.com/ansible/awx.git
synced 2026-04-04 17:55:06 -02: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:
@@ -542,6 +542,10 @@ class CredentialTypeInputField(JSONSchemaField):
|
|||||||
'type': 'object',
|
'type': 'object',
|
||||||
'additionalProperties': False,
|
'additionalProperties': False,
|
||||||
'properties': {
|
'properties': {
|
||||||
|
'required': {
|
||||||
|
'type': 'array',
|
||||||
|
'items': {'type': 'string'}
|
||||||
|
},
|
||||||
'fields': {
|
'fields': {
|
||||||
'type': 'array',
|
'type': 'array',
|
||||||
'items': {
|
'items': {
|
||||||
|
|||||||
@@ -170,6 +170,30 @@ def test_create_with_valid_inputs(get, post, admin):
|
|||||||
assert fields[0]['type'] == 'string'
|
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.django_db
|
||||||
@pytest.mark.parametrize('inputs', [
|
@pytest.mark.parametrize('inputs', [
|
||||||
True,
|
True,
|
||||||
|
|||||||
Reference in New Issue
Block a user