clarify valid CredentialType field types

almost all of our current credential values are strings, but under the
v1 Credential model, `authorize` is boolean

additionally, if a field is specified with no type, fall back to
`string` as a default (this is almost always what people creating custom
types will want)

see: #6406
This commit is contained in:
Ryan Petrello
2017-06-01 12:01:37 -04:00
parent e7d1e2d3a4
commit af457ad8eb
3 changed files with 34 additions and 19 deletions
+13 -1
View File
@@ -529,7 +529,7 @@ class CredentialTypeInputField(JSONSchemaField):
'items': {
'type': 'object',
'properties': {
'type': {'enum': ['string', 'number']},
'type': {'enum': ['string', 'boolean']},
'format': {'enum': ['ssh_private_key']},
'choices': {
'type': 'array',
@@ -578,6 +578,18 @@ class CredentialTypeInputField(JSONSchemaField):
)
ids[id_] = True
if 'type' not in field:
# If no type is specified, default to string
field['type'] = 'string'
for key in ('choices', 'multiline', 'format'):
if key in field and field['type'] != 'string':
raise django_exceptions.ValidationError(
_('%s not allowed for %s type (%s)' % (key, field['type'], field['id'])),
code='invalid',
params={'value': value},
)
class CredentialTypeInjectorField(JSONSchemaField):