mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 19:37:38 -02:30
improve sanitation of empty credential values to match API v1 behavior
This is mostly backwards compatability to avoid surprises: in 3.1.x if you submit a field value with `null` or an empty string to a CharField, it's treated as an empty string (and SSH key validation is skipped). For boolean field values (`net.authorize`), `null` and empty string are coerced to `False`. see: #7216 see: #7218
This commit is contained in:
@@ -457,6 +457,13 @@ class CredentialType(CommonModelNameNotUnique):
|
||||
if field.get('ask_at_runtime', False) is True
|
||||
]
|
||||
|
||||
def default_for_field(self, field_id):
|
||||
for field in self.inputs.get('fields', []):
|
||||
if field['id'] == field_id:
|
||||
if 'choices' in field:
|
||||
return field['choices'][0]
|
||||
return {'string': '', 'boolean': False}[field['type']]
|
||||
|
||||
@classmethod
|
||||
def default(cls, f):
|
||||
func = functools.partial(f, cls)
|
||||
|
||||
Reference in New Issue
Block a user