diff --git a/barbican/crypto/extension_manager.py b/barbican/crypto/extension_manager.py index 13e6104c0..310df23b0 100644 --- a/barbican/crypto/extension_manager.py +++ b/barbican/crypto/extension_manager.py @@ -249,10 +249,13 @@ class CryptoExtensionManager(named.NamedExtensionManager): # Create an encrypted datum instance and add the encrypted cypher text. datum = models.EncryptedDatum(secret, kek_datum) datum.content_type = content_type - datum.cypher_text, datum.kek_meta_extended = encrypting_plugin.encrypt( + response_dto = encrypting_plugin.encrypt( encrypt_dto, kek_meta_dto, tenant.keystone_id ) + datum.cypher_text = response_dto.cypher_text + datum.kek_meta_extended = response_dto.kek_meta_extended + # Convert binary data into a text-based format. #TODO(jwood) Figure out by storing binary (BYTEA) data in Postgres # isn't working. diff --git a/barbican/tests/crypto/test_extension_manager.py b/barbican/tests/crypto/test_extension_manager.py index 6bc74d249..3652b895a 100644 --- a/barbican/tests/crypto/test_extension_manager.py +++ b/barbican/tests/crypto/test_extension_manager.py @@ -275,6 +275,18 @@ class WhenTestingCryptoExtensionManager(testtools.TestCase): mock.MagicMock(), ) + def test_encrypt_response_dto(self): + plugin = SimpleCryptoPlugin() + plugin_mock = mock.MagicMock(obj=plugin) + self.manager.extensions = [plugin_mock] + + response_dto = self.manager.encrypt( + 'payload', 'text/plain', None, mock.MagicMock(), mock.MagicMock(), + mock.MagicMock(), False + ) + + self.assertIsNotNone(response_dto) + def test_decrypt_no_plugin_found(self): """ Passing mocks here causes CryptoPluginNotFound because the mock won't match any of the available plugins diff --git a/barbican/tests/crypto/test_plugin.py b/barbican/tests/crypto/test_plugin.py index 024f66dcb..e2adbed65 100644 --- a/barbican/tests/crypto/test_plugin.py +++ b/barbican/tests/crypto/test_plugin.py @@ -31,7 +31,7 @@ class TestCryptoPlugin(plugin.CryptoPluginBase): def encrypt(self, encrypt_dto, kek_meta_dto, keystone_id): cypher_text = b'cypher_text' - return cypher_text, None + return plugin.ResponseDTO(cypher_text, None) def decrypt(self, decrypt_dto, kek_meta_dto, kek_meta_extended, keystone_id):