Fixed http 500 due to mismatch between ResponseDTO and tuple from plugin encrypt
Change-Id: Ib206c0cc17d71013ffb30af08b4cce4392171b08 Closes-Bug: #1320001
This commit is contained in:
parent
f5768ec79a
commit
2b1914a730
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user