mirror of
https://github.com/ansible/awx.git
synced 2026-02-21 13:10:11 -03:30
AC-537 Add remaining API/field validation for credentials and other objects using credentials.
AC-630 Added validation of cloud_credential kind on job template and job, set environment variables based on cloud credential. AC-610 Require a credential for a cloud inventory source. AC-457 Do not set password when using hg over ssh.
This commit is contained in:
@@ -255,6 +255,22 @@ class Credential(CommonModelNameNotUnique):
|
||||
def get_absolute_url(self):
|
||||
return reverse('api:credential_detail', args=(self.pk,))
|
||||
|
||||
def clean_username(self):
|
||||
username = self.username or ''
|
||||
if not username and self.kind == 'aws':
|
||||
raise ValidationError('Access key required for "aws" credential')
|
||||
if not username and self.kind == 'rax':
|
||||
raise ValidationError('Username required for "rax" credential')
|
||||
return username
|
||||
|
||||
def clean_password(self):
|
||||
password = self.password or ''
|
||||
if not password and self.kind == 'aws':
|
||||
raise ValidationError('Secret key required for "aws" credential')
|
||||
if not password and self.kind == 'rax':
|
||||
raise ValidationError('API key required for "rax" credential')
|
||||
return password
|
||||
|
||||
def clean_ssh_key_unlock(self):
|
||||
if self.pk:
|
||||
ssh_key_data = decrypt_field(self, 'ssh_key_data')
|
||||
|
||||
Reference in New Issue
Block a user