mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 00:57:48 -02:30
Update unit test, edit credential module to pass sanity tests
This commit is contained in:
@@ -31,7 +31,7 @@ options:
|
|||||||
new_name:
|
new_name:
|
||||||
description:
|
description:
|
||||||
- Setting this option will change the existing name (looked up via the name field.
|
- Setting this option will change the existing name (looked up via the name field.
|
||||||
required: True
|
required: False
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
||||||
@@ -336,7 +336,7 @@ def main():
|
|||||||
team_id = module.resolve_name_to_id('teams', team)
|
team_id = module.resolve_name_to_id('teams', team)
|
||||||
|
|
||||||
if kind:
|
if kind:
|
||||||
module.deprecate(msg='The kind parameter has been depricated, please use credential_type instead', version="3.6")
|
module.deprecate(msg='The kind parameter has been deprecated, please use credential_type instead', version="3.6")
|
||||||
|
|
||||||
cred_type_id = module.resolve_name_to_id('credential_types', credential_type if credential_type else KIND_CHOICES[kind])
|
cred_type_id = module.resolve_name_to_id('credential_types', credential_type if credential_type else KIND_CHOICES[kind])
|
||||||
|
|
||||||
@@ -353,7 +353,7 @@ def main():
|
|||||||
credential_inputs = {}
|
credential_inputs = {}
|
||||||
for legacy_input in OLD_INPUT_NAMES:
|
for legacy_input in OLD_INPUT_NAMES:
|
||||||
if module.params.get(legacy_input) is not None:
|
if module.params.get(legacy_input) is not None:
|
||||||
module.deprecate(msg='{0} parameter has been depricated, please use inputs instead'.format(legacy_input), version="3.6")
|
module.deprecate(msg='{0} parameter has been deprecated, please use inputs instead'.format(legacy_input), version="3.6")
|
||||||
credential_inputs[legacy_input] = module.params.get(legacy_input)
|
credential_inputs[legacy_input] = module.params.get(legacy_input)
|
||||||
if inputs:
|
if inputs:
|
||||||
credential_inputs.update(inputs)
|
credential_inputs.update(inputs)
|
||||||
|
|||||||
@@ -118,24 +118,27 @@ def test_ct_precedence_over_kind(run_module, admin_user, organization, cred_type
|
|||||||
|
|
||||||
cred = Credential.objects.get(name='A credential')
|
cred = Credential.objects.get(name='A credential')
|
||||||
|
|
||||||
assert cred.credential_type == cred_type.name
|
assert cred.credential_type == cred_type
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_input_overrides_old_fields(run_module, admin_user, organization):
|
def test_input_overrides_old_fields(run_module, admin_user, organization):
|
||||||
|
# create the vault credential type
|
||||||
|
ct = CredentialType.defaults['vault']()
|
||||||
|
ct.save()
|
||||||
result = run_module('tower_credential', dict(
|
result = run_module('tower_credential', dict(
|
||||||
name='A Vault credential',
|
name='A Vault credential',
|
||||||
organization=organization.name,
|
organization=organization.name,
|
||||||
kind='Vault',
|
kind='vault',
|
||||||
inputs={'vault_id': 'asdf'},
|
|
||||||
vault_id='1234',
|
vault_id='1234',
|
||||||
state='present'
|
inputs={'vault_id': 'asdf'},
|
||||||
|
state='present',
|
||||||
), admin_user)
|
), admin_user)
|
||||||
assert not result.get('failed', False), result
|
assert not result.get('failed', False), result.get('msg', result)
|
||||||
|
|
||||||
cred = Credential.objects.get(name='A Vault credential')
|
cred = Credential.objects.get(name='A Vault credential')
|
||||||
|
|
||||||
assert cred.inputs.vault_id == 'asdf'
|
assert cred.inputs['vault_id'] == 'asdf'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
set_fact:
|
set_fact:
|
||||||
ssh_key_data: "{{ lookup('file', tempdir.stdout + '/id_rsa') }}"
|
ssh_key_data: "{{ lookup('file', tempdir.stdout + '/id_rsa') }}"
|
||||||
|
|
||||||
- name: Test deprication warnings
|
- name: Test deprecation warnings
|
||||||
tower_credential:
|
tower_credential:
|
||||||
name: "{{ ssh_cred_name1 }}"
|
name: "{{ ssh_cred_name1 }}"
|
||||||
organization: Default
|
organization: Default
|
||||||
|
|||||||
Reference in New Issue
Block a user