Merge "Fix getting secret for vault plugin"

This commit is contained in:
Zuul 2018-07-27 17:07:32 +00:00 committed by Gerrit Code Review
commit 4885ce18ae
3 changed files with 17 additions and 5 deletions

View File

@ -67,7 +67,9 @@ class CastellanSecretStore(ss.SecretStoreBase):
secret = self.key_manager.get(
self.context,
secret_ref)
return secret.get_encoded()
return ss.SecretDTO(secret_type, secret.get_encoded(),
ss.KeySpec(), secret_metadata['content_type'])
except Exception as e:
LOG.exception("Error retrieving secret {}: {}".format(
secret_ref, six.text_type(e)))

View File

@ -155,19 +155,24 @@ class WhenTestingVaultSecretStore(utils.BaseTestCase):
)
def test_get_secret(self):
secret_metadata = {css.CastellanSecretStore.KEY_ID: key_ref1}
secret_metadata = {
css.CastellanSecretStore.KEY_ID: key_ref1,
"content_type": "application/octet-stream"
}
response = self.plugin.get_secret(
ss.SecretType.SYMMETRIC,
secret_metadata
)
self.assertIsInstance(response, ss.SecretDTO)
self.assertEqual(ss.SecretType.SYMMETRIC, response.type)
self.assertEqual(secret_passphrase, response.secret)
self.plugin.key_manager.get.assert_called_once_with(
mock.ANY,
key_ref1
)
self.assertEqual(response, secret_passphrase)
def test_get_secret_throws_exception(self):
secret_metadata = {css.CastellanSecretStore.KEY_ID: key_ref1}
self.plugin.key_manager.get.side_effect = exception.Forbidden()

View File

@ -597,8 +597,13 @@ function install_vault {
echo "Wah! Need to throw an error code here!"
fi
#debug code follows:
export VAULT_ADDR="http://${HOST_IP}:8200"
# Enable kv version 1
vault secrets disable secret/
vault secrets enable -version=1 -path=secret -description "kv version 1" kv
#debug code follows:
vault status
vault kv put secret/hello foo=world
vault kv get secret/hello