From e2f52c53ad4aa72ca04c3499fa3498855701d12d Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 29 Jan 2020 11:53:15 +0100 Subject: [PATCH] fix incorrect unit test description The process() method signals the caller that the maximum data length has been reached by returning a ciphertext that is shorter than the plaintext. The caller must then continue by finalizing the current object and starting a new one. The behavior in this case was changed in cb7a3911f8 to not propagate the exception from Cryptography, but the unit test retained the erroneous description. --- testing/test_crypto.py | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/testing/test_crypto.py b/testing/test_crypto.py index f4d9254..7efb195 100644 --- a/testing/test_crypto.py +++ b/testing/test_crypto.py @@ -432,8 +432,10 @@ class AESGCMTest (CryptoLayerTest): def test_crypto_aes_gcm_enc_length_cap (self): """ Artificially lower the maximum allowable data length and attempt to - encrypt a larger object. Verify that the crypto handler aborts with and - exception. + encrypt a larger object. Verify that the crypto handler only encrypts + data up to the size limit. A downstream user detects that condition by + testing whether the encryption step yielded less bytes than the + plaintext. The sibling to this test is test_restore_backup_max_file_length() in test_delatar.py. Deltatar will transparently create a splitted object @@ -468,7 +470,10 @@ class AESGCMTest (CryptoLayerTest): assert (len (rest) == 0) if len (pt) > new_max: - assert n < len (pt) + # If the plaintext was longer than the artificially lowered + # maximum, then the number of ciphertext bytes must be clamped + # to the maximum. + assert n == new_max else: assert n == len (pt) == len (ct) -- 1.7.1