Merge pull request #72 from ryanpetrello/fix-7293

improve private passphrase error when it's provided unnecessarily
This commit is contained in:
Ryan Petrello
2017-07-26 15:07:11 -04:00
committed by GitHub

View File

@@ -542,8 +542,11 @@ class CredentialInputField(JSONSchemaField):
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 not model_instance.has_encrypted_ssh_key_data and value.get('ssh_key_unlock'):
errors['ssh_key_unlock'] = [_('should not be set when SSH key is not encrypted.')]
if value.get('ssh_key_unlock'):
if not model_instance.ssh_key_data:
errors['ssh_key_unlock'] = [_('should not be set when SSH key is empty.')]
elif not model_instance.has_encrypted_ssh_key_data:
errors['ssh_key_unlock'] = [_('should not be set when SSH key is not encrypted.')]
if errors:
raise serializers.ValidationError({