Mercurial > libervia-backend
changeset 1066:cbf917a90784
test (memory): fixes crypto encryption/decryption test
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 12 Jun 2014 15:57:22 +0200 (2014-06-12) |
parents | 9378c80e3408 |
children | f7f15d44fdfa |
files | src/test/test_memory_crypto.py |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/test/test_memory_crypto.py Thu Jun 12 15:56:41 2014 +0200 +++ b/src/test/test_memory_crypto.py Thu Jun 12 15:57:22 2014 +0200 @@ -34,14 +34,18 @@ def test_encrypt_decrypt(self): d_list = [] + + def test(key, message): + d = BlockCipher.encrypt(key, message) + d.addCallback(lambda ciphertext: BlockCipher.decrypt(key, ciphertext)) + d.addCallback(lambda decrypted: self.assertEqual(message, decrypted)) + d_list.append(d) + for key_len in (0, 2, 8, 10, 16, 24, 30, 32, 40): key = urandom(key_len) for message_len in (0, 2, 16, 24, 32, 100): message = urandom(message_len) - d = BlockCipher.encrypt(key, message) - d.addCallback(lambda ciphertext: lambda key, cipher: BlockCipher.decrypt(key, ciphertext)) - d.addCallback(lambda decrypted: lambda message, decrypted: self.assertEqual(message, decrypted)) - d_list.append(d) + test(key, message) return defer.DeferredList(d_list) def test_hash_verify(self):