From d7f5ded84912fc763dfb4937972346310c4fdde6 Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Mon, 18 Jul 2022 16:47:58 -0400 Subject: [PATCH] add new managed credential type for gpg pub key Signed-off-by: Hao Liu --- awx/main/models/credential/__init__.py | 19 +++++++ awx/main/tests/functional/test_credential.py | 59 ++++++++++---------- 2 files changed, 50 insertions(+), 28 deletions(-) diff --git a/awx/main/models/credential/__init__.py b/awx/main/models/credential/__init__.py index 53f6ffaa1f..6f132a0deb 100644 --- a/awx/main/models/credential/__init__.py +++ b/awx/main/models/credential/__init__.py @@ -1171,6 +1171,25 @@ ManagedCredentialType( }, ) +ManagedCredentialType( + namespace='gpg_public_key', + kind='cryptography', + name=gettext_noop('GPG Public Key'), + inputs={ + 'fields': [ + { + 'id': 'gpg_public_key', + 'label': gettext_noop('GPG Public Key'), + 'type': 'string', + 'secret': True, + 'multiline': True, + 'help_text': gettext_noop('GPG Public Key used to validate content signatures.'), + }, + ], + 'required': ['gpg_public_key'], + }, +) + class CredentialInputSource(PrimordialModel): class Meta: diff --git a/awx/main/tests/functional/test_credential.py b/awx/main/tests/functional/test_credential.py index ae5d99730f..d2937412da 100644 --- a/awx/main/tests/functional/test_credential.py +++ b/awx/main/tests/functional/test_credential.py @@ -74,34 +74,37 @@ GLqbpJyX2r3p/Rmo6mLY71SqpA== @pytest.mark.django_db def test_default_cred_types(): - assert sorted(CredentialType.defaults.keys()) == [ - 'aim', - 'aws', - 'azure_kv', - 'azure_rm', - 'centrify_vault_kv', - 'conjur', - 'controller', - 'galaxy_api_token', - 'gce', - 'github_token', - 'gitlab_token', - 'hashivault_kv', - 'hashivault_ssh', - 'insights', - 'kubernetes_bearer_token', - 'net', - 'openstack', - 'registry', - 'rhv', - 'satellite6', - 'scm', - 'ssh', - 'thycotic_dsv', - 'thycotic_tss', - 'vault', - 'vmware', - ] + assert sorted(CredentialType.defaults.keys()) == sorted( + [ + 'aim', + 'aws', + 'azure_kv', + 'azure_rm', + 'centrify_vault_kv', + 'conjur', + 'controller', + 'galaxy_api_token', + 'gce', + 'github_token', + 'gitlab_token', + 'gpg_public_key', + 'hashivault_kv', + 'hashivault_ssh', + 'insights', + 'kubernetes_bearer_token', + 'net', + 'openstack', + 'registry', + 'rhv', + 'satellite6', + 'scm', + 'ssh', + 'thycotic_dsv', + 'thycotic_tss', + 'vault', + 'vmware', + ] + ) for type_ in CredentialType.defaults.values(): assert type_().managed is True