mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 03:30:02 -03:30
Removed extraneous warning when using garbage credentials for ssh_key_data
added in logic to check if there was an existing error before checking form field entry for ssh_key_unlock, also added a test to ensure that garbage data entered would not trigger the error message for both the incorrect ssh_key_data and the incorrect ssh_key_unlock, rather just the incorrect ssh_key_data
This commit is contained in:
@@ -688,16 +688,18 @@ class CredentialInputField(JSONSchemaField):
|
||||
model_instance.inputs['ssh_key_data'] = model_instance.__class__.objects.get(
|
||||
pk=model_instance.pk
|
||||
).inputs.get('ssh_key_data')
|
||||
|
||||
|
||||
if model_instance.has_encrypted_ssh_key_data and not value.get('ssh_key_unlock'):
|
||||
errors['ssh_key_unlock'] = [_('must be set when SSH key is encrypted.')]
|
||||
|
||||
if all([
|
||||
model_instance.inputs.get('ssh_key_data'),
|
||||
value.get('ssh_key_unlock'),
|
||||
not model_instance.has_encrypted_ssh_key_data
|
||||
not model_instance.has_encrypted_ssh_key_data,
|
||||
'ssh_key_data' not in errors
|
||||
]):
|
||||
errors['ssh_key_unlock'] = [_('should not be set when SSH key is not encrypted.')]
|
||||
|
||||
|
||||
if errors:
|
||||
raise serializers.ValidationError({
|
||||
'inputs': errors
|
||||
|
||||
Reference in New Issue
Block a user