mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Merge pull request #5015 from AlanCoding/awx_awx_cp1
tower_credential: Missing 'kind' attribute (#61324) Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
9b09344bae
@ -255,7 +255,7 @@ OLD_INPUT_NAMES = (
|
||||
|
||||
def credential_type_for_kind(params):
|
||||
credential_type_res = tower_cli.get_resource('credential_type')
|
||||
kind = params.pop('kind')
|
||||
kind = params.get('kind')
|
||||
arguments = {'managed_by_tower': True}
|
||||
if kind == 'ssh':
|
||||
if params.get('vault_password'):
|
||||
|
||||
@ -7,20 +7,52 @@ from awx.main.models import Credential, CredentialType, Organization
|
||||
def test_create_machine_credential(run_module, admin_user):
|
||||
Organization.objects.create(name='test-org')
|
||||
# create the ssh credential type
|
||||
CredentialType.defaults['ssh']().save()
|
||||
ct = CredentialType.defaults['ssh']()
|
||||
ct.save()
|
||||
# Example from docs
|
||||
result = run_module('tower_credential', dict(
|
||||
name='Team Name',
|
||||
description='Team Description',
|
||||
name='Test Machine Credential',
|
||||
organization='test-org',
|
||||
kind='ssh',
|
||||
state='present'
|
||||
), admin_user)
|
||||
assert result.get('changed'), result
|
||||
|
||||
cred = Credential.objects.get(name='Team Name')
|
||||
cred = Credential.objects.get(name='Test Machine Credential')
|
||||
assert cred.credential_type == ct
|
||||
result.pop('invocation')
|
||||
assert result == {
|
||||
"credential": "Team Name",
|
||||
"credential": "Test Machine Credential",
|
||||
"state": "present",
|
||||
"id": cred.pk,
|
||||
"changed": True
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_create_vault_credential(run_module, admin_user):
|
||||
# https://github.com/ansible/ansible/issues/61324
|
||||
Organization.objects.create(name='test-org')
|
||||
ct = CredentialType.defaults['vault']()
|
||||
ct.save()
|
||||
|
||||
result = run_module('tower_credential', dict(
|
||||
name='Test Vault Credential',
|
||||
organization='test-org',
|
||||
kind='vault',
|
||||
vault_id='bar',
|
||||
vault_password='foobar',
|
||||
state='present'
|
||||
), admin_user)
|
||||
assert result.get('changed'), result
|
||||
|
||||
cred = Credential.objects.get(name='Test Vault Credential')
|
||||
assert cred.credential_type == ct
|
||||
assert 'vault_id' in cred.inputs
|
||||
assert 'vault_password' in cred.inputs
|
||||
result.pop('invocation')
|
||||
assert result == {
|
||||
"credential": "Test Vault Credential",
|
||||
"state": "present",
|
||||
"id": cred.pk,
|
||||
"changed": True
|
||||
@ -39,6 +71,7 @@ def test_create_custom_credential_type(run_module, admin_user):
|
||||
state='present',
|
||||
validate_certs='false'
|
||||
), admin_user)
|
||||
assert result.get('changed'), result
|
||||
|
||||
ct = CredentialType.objects.get(name='Nexus')
|
||||
result.pop('invocation')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user