From 369c0f19ec2475b87b6245a203cd9a9bef37646c Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 21 Jul 2017 10:24:34 -0400 Subject: [PATCH 1/2] Keep the 'machine' credential name for user/password & key credentials. --- awx/main/migrations/0040_v320_add_credentialtype_model.py | 2 +- awx/main/models/credential.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/awx/main/migrations/0040_v320_add_credentialtype_model.py b/awx/main/migrations/0040_v320_add_credentialtype_model.py index 626f061d10..3331b40e24 100644 --- a/awx/main/migrations/0040_v320_add_credentialtype_model.py +++ b/awx/main/migrations/0040_v320_add_credentialtype_model.py @@ -23,7 +23,7 @@ class Migration(migrations.Migration): ('modified', models.DateTimeField(default=None, editable=False)), ('description', models.TextField(default=b'', blank=True)), ('name', models.CharField(max_length=512)), - ('kind', models.CharField(max_length=32, choices=[(b'ssh', 'SSH'), (b'vault', 'Vault'), (b'net', 'Network'), (b'scm', 'Source Control'), (b'cloud', 'Cloud'), (b'insights', 'Insights')])), + ('kind', models.CharField(max_length=32, choices=[(b'ssh', 'Machine'), (b'vault', 'Vault'), (b'net', 'Network'), (b'scm', 'Source Control'), (b'cloud', 'Cloud'), (b'insights', 'Insights')])), ('managed_by_tower', models.BooleanField(default=False, editable=False)), ('inputs', awx.main.fields.CredentialTypeInputField(default={}, blank=True, help_text='Enter inputs using either JSON or YAML syntax. Use the radio button to toggle between the two. Refer to the Ansible Tower documentation for example syntax.')), ('injectors', awx.main.fields.CredentialTypeInjectorField(default={}, blank=True, help_text='Enter injectors using either JSON or YAML syntax. Use the radio button to toggle between the two. Refer to the Ansible Tower documentation for example syntax.')), diff --git a/awx/main/models/credential.py b/awx/main/models/credential.py index 2797abdab4..7f6b875ae8 100644 --- a/awx/main/models/credential.py +++ b/awx/main/models/credential.py @@ -401,7 +401,7 @@ class CredentialType(CommonModelNameNotUnique): unique_together = (('name', 'kind'),) KIND_CHOICES = ( - ('ssh', _('SSH')), + ('ssh', _('Machine')), ('vault', _('Vault')), ('net', _('Network')), ('scm', _('Source Control')), @@ -588,7 +588,7 @@ class CredentialType(CommonModelNameNotUnique): def ssh(cls): return cls( kind='ssh', - name='SSH', + name='Machine', managed_by_tower=True, inputs={ 'fields': [{ From 836dc7d7f594ea65bb1e1bfc8e02670e84a0a85a Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 21 Jul 2017 11:45:02 -0400 Subject: [PATCH 2/2] Fixup unit tests --- awx/main/tests/functional/test_credential_migration.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awx/main/tests/functional/test_credential_migration.py b/awx/main/tests/functional/test_credential_migration.py index 578fa2974f..b5453c9a0d 100644 --- a/awx/main/tests/functional/test_credential_migration.py +++ b/awx/main/tests/functional/test_credential_migration.py @@ -45,7 +45,7 @@ def test_ssh_migration(): 'become_password': 'superpassword', }) - assert cred.credential_type.name == 'SSH' + assert cred.credential_type.name == 'Machine' assert cred.inputs['username'] == 'bob' assert cred.inputs['password'].startswith('$encrypted$') assert decrypt_field(cred, 'password') == 'secret' @@ -117,9 +117,9 @@ def test_vault_with_ssh_migration(): assert cred.inputs['vault_password'].startswith('$encrypted$') assert decrypt_field(cred, 'vault_password') == 'vault' - ssh_cred = Credential.objects.filter(credential_type__name='SSH').get() + ssh_cred = Credential.objects.filter(credential_type__name='Machine').get() assert sorted(ssh_cred.inputs.keys()) == sorted(CredentialType.from_v1_kind('ssh').defined_fields) - assert ssh_cred.credential_type.name == 'SSH' + assert ssh_cred.credential_type.name == 'Machine' assert ssh_cred.inputs['username'] == 'bob' assert ssh_cred.inputs['password'].startswith('$encrypted$') assert decrypt_field(ssh_cred, 'password') == 'secret'