From 25896a8772e8b88efde27a39b8ec24972987a5c3 Mon Sep 17 00:00:00 2001 From: Peter Braun Date: Tue, 2 Sep 2025 14:36:46 +0200 Subject: [PATCH] Fix credential types no org (#7078) * Allow creating galaxy credential types without an organization (#16077) * remove requirement for galaxy credentials to belong to an organization * remove organization check for galaxy credential type * add functional test --- .../tests/functional/api/test_credential.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/awx/main/tests/functional/api/test_credential.py b/awx/main/tests/functional/api/test_credential.py index 65e8074241..285ab413e4 100644 --- a/awx/main/tests/functional/api/test_credential.py +++ b/awx/main/tests/functional/api/test_credential.py @@ -1236,6 +1236,30 @@ def test_custom_credential_type_create(get, post, organization, admin): assert decrypt_field(cred, 'api_token') == 'secret' +@pytest.mark.django_db +def test_galaxy_create_ok(post, organization, admin): + params = { + 'credential_type': 1, + 'name': 'Galaxy credential', + 'inputs': { + 'url': 'https://galaxy.ansible.com', + 'token': 'some_galaxy_token', + }, + } + galaxy = CredentialType.defaults['galaxy_api_token']() + galaxy.save() + params['user'] = admin.id + params['credential_type'] = galaxy.pk + response = post(reverse('api:credential_list'), params, admin) + assert response.status_code == 201 + + assert Credential.objects.count() == 1 + cred = Credential.objects.all()[:1].get() + assert cred.credential_type == galaxy + assert cred.inputs['url'] == 'https://galaxy.ansible.com' + assert decrypt_field(cred, 'token') == 'some_galaxy_token' + + # # misc xfail conditions #