diff --git a/awx/main/models/credential.py b/awx/main/models/credential.py index 97103855c2..89ad3cf4e2 100644 --- a/awx/main/models/credential.py +++ b/awx/main/models/credential.py @@ -736,7 +736,8 @@ def net(cls): 'dependencies': { 'ssh_key_unlock': ['ssh_key_data'], 'authorize_password': ['authorize'], - } + }, + 'required': ['username'], } ) @@ -862,7 +863,8 @@ def satellite6(cls): 'label': 'Password', 'type': 'string', 'secret': True, - }] + }], + 'required': ['host', 'username', 'password'], } ) @@ -890,7 +892,8 @@ def cloudforms(cls): 'label': 'Password', 'type': 'string', 'secret': True, - }] + }], + 'required': ['host', 'username', 'password'], } ) @@ -925,7 +928,8 @@ def gce(cls): 'multiline': True, 'help_text': ('Paste the contents of the PEM file associated ' 'with the service account email.') - }] + }], + 'required': ['username', 'ssh_key_data'], } ) @@ -953,7 +957,8 @@ def azure(cls): 'help_text': ('Paste the contents of the PEM file that corresponds ' 'to the certificate you uploaded in the Microsoft ' 'Azure console.') - }] + }], + 'required': ['username', 'ssh_key_data'], } ) @@ -993,7 +998,8 @@ def azure_rm(cls): 'id': 'tenant', 'label': 'Tenant ID', 'type': 'string' - }] + }], + 'required': ['subscription'], } ) diff --git a/awx/main/tests/functional/api/test_credential.py b/awx/main/tests/functional/api/test_credential.py index 201732a7b9..1bddd26f8f 100644 --- a/awx/main/tests/functional/api/test_credential.py +++ b/awx/main/tests/functional/api/test_credential.py @@ -748,6 +748,7 @@ def test_falsey_field_data(get, post, organization, admin, field_value): 'credential_type': net.pk, 'organization': organization.id, 'inputs': { + 'username': 'joe-user', # username is required 'authorize': field_value } } diff --git a/awx/main/tests/functional/test_credential.py b/awx/main/tests/functional/test_credential.py index cdb54c2265..4a51565d04 100644 --- a/awx/main/tests/functional/test_credential.py +++ b/awx/main/tests/functional/test_credential.py @@ -226,7 +226,7 @@ def test_credential_creation_validation_failure(organization_factory, inputs): [EXAMPLE_PRIVATE_KEY.replace('=', '\u003d'), None, True], # automatically fix JSON-encoded GCE keys ]) def test_ssh_key_data_validation(organization, kind, ssh_key_data, ssh_key_unlock, valid): - inputs = {} + inputs = {'username': 'joe-user'} if ssh_key_data: inputs['ssh_key_data'] = ssh_key_data if ssh_key_unlock: