Retrieve approle_secret_id from correct relation

The existing comment in the code expresses the correct intent:
"fetch current secret-id, if any, from relation with barbican principle"
but then attempts to retrieve the secret-id from the vault
relation.

Change-Id: Ie2694ba38e08fd9e864bf9d8fa0b63f0e185b8bd
Closes-Bug: #1871981
This commit is contained in:
Liam Young 2020-11-27 15:49:27 +00:00 committed by Billy Olsen
parent 9a669fd1fe
commit 26ba0535ef
2 changed files with 3 additions and 5 deletions

View File

@ -77,9 +77,8 @@ def plugin_info_barbican_publish():
# fetch current secret-id, if any, from relation with barbican principle
current_secret_id = None
secrets = reactive.endpoint_from_flag('secrets.available')
if secrets:
for relation in secrets.relations:
if barbican:
for relation in barbican.relations:
data = relation.to_publish.get('data')
if data and data.get('approle_secret_id'):
current_secret_id = data.get('approle_secret_id')

View File

@ -119,8 +119,7 @@ class TestBarbicanVaultHandlers(test_utils.PatchHelper):
handlers.plugin_info_barbican_publish()
self.endpoint_from_flag.assert_has_calls([
mock.call('endpoint.secrets.joined'),
mock.call('secrets-storage.available'),
mock.call('secrets.available'),
mock.call('secrets-storage.available')
])
vault_data = {
'approle_role_id': secrets_storage.unit_role_id,