From 2a05d9f26247c9134134ce7251d8797536d3a6e1 Mon Sep 17 00:00:00 2001 From: zhangbaojun Date: Sat, 4 Apr 2026 15:14:47 +0800 Subject: [PATCH] feat(encryption): add encrypt unit test for plaintext shorter than the magic header --- openviking/utils/summarizer.py | 2 +- tests/unit/crypto/test_encryptor.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/openviking/utils/summarizer.py b/openviking/utils/summarizer.py index 41d2c4664..4e6129668 100644 --- a/openviking/utils/summarizer.py +++ b/openviking/utils/summarizer.py @@ -56,7 +56,7 @@ async def summarize( enqueued_count = 0 telemetry = get_current_telemetry() - for uri, temp_uri in zip(resource_uris, temp_uris, strict=True): + for uri, temp_uri in zip(resource_uris, temp_uris, strict=False): # Determine context_type based on URI context_type = get_context_type_for_uri(uri) diff --git a/tests/unit/crypto/test_encryptor.py b/tests/unit/crypto/test_encryptor.py index a4f4a61f5..b37b27cc6 100644 --- a/tests/unit/crypto/test_encryptor.py +++ b/tests/unit/crypto/test_encryptor.py @@ -60,6 +60,16 @@ async def test_decrypt_unencrypted_data(encryptor): assert decrypted == plaintext +@pytest.mark.asyncio +@pytest.mark.parametrize("plaintext", [b"", b"a", b"ab", b"abc"]) +async def test_decrypt_unencrypted_short_plaintext(encryptor, plaintext): + """Test decrypting unencrypted plaintext shorter than the magic header.""" + account_id = "test_account" + + decrypted = await encryptor.decrypt(account_id, plaintext) + assert decrypted == plaintext + + @pytest.mark.asyncio async def test_decrypt_corrupted_ciphertext(encryptor): """Test decrypting corrupted ciphertext."""