From fcdcd5968ef6e9426925eb03412c6306c6fe4e17 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 14 Dec 2017 14:28:05 -0300 Subject: [test] ciphertext size function tests --- tests/client/test_crypto.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/client/test_crypto.py b/tests/client/test_crypto.py index 5b647b73..8a040cd4 100644 --- a/tests/client/test_crypto.py +++ b/tests/client/test_crypto.py @@ -126,6 +126,19 @@ class BlobTestCase(unittest.TestCase): decrypted = yield decryptor.decrypt() assert decrypted.getvalue() == snowden1 + @defer.inlineCallbacks + def test_get_unarmored_ciphertext_size(self): + for size_to_test in xrange(-1, 400): + test_content = '\x00' * size_to_test + size = _crypto.get_unarmored_ciphertext_size(len(test_content)) + inf = BytesIO(test_content) + blob = _crypto.BlobEncryptor( + self.doc_info, inf, + armor=False, + secret='A' * 96) + encrypted = yield blob.encrypt() + assert len(encrypted.getvalue()) == size, size_to_test + @defer.inlineCallbacks def test_default_armored_blob_encrypt(self): encrypted = yield self.blob.encrypt() -- cgit v1.2.3