convey OpenStack verify_ssl defaults in the CredentialType schema

This commit is contained in:
Ryan Petrello
2019-02-19 16:08:13 -05:00
parent 9f04fbe4a4
commit b1a33869dc
7 changed files with 132 additions and 5 deletions

View File

@@ -671,6 +671,7 @@ class CredentialTypeInputField(JSONSchemaField):
'multiline': {'type': 'boolean'},
'secret': {'type': 'boolean'},
'ask_at_runtime': {'type': 'boolean'},
'default': {},
},
'additionalProperties': False,
'required': ['id', 'label'],
@@ -714,6 +715,14 @@ class CredentialTypeInputField(JSONSchemaField):
# If no type is specified, default to string
field['type'] = 'string'
if 'default' in field:
default = field['default']
_type = {'string': str, 'boolean': bool}[field['type']]
if type(default) != _type:
raise django_exceptions.ValidationError(
_('{} is not a {}').format(default, field['type'])
)
for key in ('choices', 'multiline', 'format', 'secret',):
if key in field and field['type'] != 'string':
raise django_exceptions.ValidationError(