rename 'approle_auth_path' to 'default_auth_path' & fix kwargs.get

This commit is contained in:
Benoit Bayszczak
2020-09-07 14:40:30 +02:00
parent e8b54abec4
commit 08c9219f48
2 changed files with 6 additions and 9 deletions

View File

@@ -41,11 +41,12 @@ base_inputs = {
'secret': True, 'secret': True,
'help_text': _('The Secret ID for AppRole Authentication') 'help_text': _('The Secret ID for AppRole Authentication')
}, { }, {
'id': 'approle_auth_path', 'id': 'default_auth_path',
'label': _('Path to Approle Auth'), 'label': _('Path to Approle Auth'),
'type': 'string', 'type': 'string',
'multiline': False, 'multiline': False,
'help_text': _('The path where the AppRole Authentication method is mounted e.g, approle') 'default': 'approle',
'help_text': _('The AppRole Authentication path to use if one isn\'t provided in the metadata when linking to an input field. Defaults to \'approle\'')
} }
], ],
'metadata': [{ 'metadata': [{
@@ -126,10 +127,8 @@ def approle_auth(**kwargs):
role_id = kwargs['role_id'] role_id = kwargs['role_id']
secret_id = kwargs['secret_id'] secret_id = kwargs['secret_id']
# we first try to use the 'auth_path' from the metadata # we first try to use the 'auth_path' from the metadata
# if not found we try to fetch the 'approle_auth_path' from inputs # if not found we try to fetch the 'default_auth_path' from inputs
# if not found we use the default value 'approle' auth_path = kwargs.get('auth_path') or kwargs['default_auth_path']
auth_path = \
kwargs.get('auth_path', kwargs.get('approle_auth_path', "approle"))
url = urljoin(kwargs['url'], 'v1') url = urljoin(kwargs['url'], 'v1')
cacert = kwargs.get('cacert', None) cacert = kwargs.get('cacert', None)

View File

@@ -123,7 +123,7 @@ def source_cred_hashi_secret(organization):
"token": "myApiKey", "token": "myApiKey",
"role_id": "role", "role_id": "role",
"secret_id": "secret", "secret_id": "secret",
"approle_auth_path": "path-to-approle" "default_auth_path": "path-to-approle"
} }
) )
@@ -158,8 +158,6 @@ def test_hashi_secret_credential_source(run_module, admin_user, organization, so
assert cis.metadata['secret_backend'] == "backend" assert cis.metadata['secret_backend'] == "backend"
assert cis.metadata['secret_key'] == "a_key" assert cis.metadata['secret_key'] == "a_key"
assert cis.source_credential.name == source_cred_hashi_secret.name assert cis.source_credential.name == source_cred_hashi_secret.name
assert cis.source_credential.approle_auth_path == \
source_cred_hashi_secret.inputs["approle_auth_path"]
assert cis.target_credential.name == tgt_cred.name assert cis.target_credential.name == tgt_cred.name
assert cis.input_field_name == 'password' assert cis.input_field_name == 'password'
assert result['id'] == cis.pk assert result['id'] == cis.pk