diff --git a/src/common/dbpa_local_test.cpp b/src/common/dbpa_local_test.cpp index 3f1643d..74e1dae 100644 --- a/src/common/dbpa_local_test.cpp +++ b/src/common/dbpa_local_test.cpp @@ -49,6 +49,30 @@ TEST_F(LocalDataBatchProtectionAgentTest, SuccessfulEncryption) { EXPECT_GT(result->size(), 0); } +TEST_F(LocalDataBatchProtectionAgentTest, SuccessfulEncryptionCompressedDictionary) { + LocalDataBatchProtectionAgent agent; + + std::map connection_config; + std::string app_context = R"({"user_id": "test_user"})"; + + EXPECT_NO_THROW(agent.init("test_column", connection_config, app_context, "test_key", + Type::BYTE_ARRAY, std::nullopt, CompressionCodec::GZIP, std::nullopt)); + + // GZIP compressed data for strings "apple" and "banana" + std::vector test_data_gzip = { + 0x1F, 0x8B, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, + 0x63, 0x65, 0x60, 0x60, 0x48, 0x2C, 0x28, 0xC8, 0x49, 0x65, + 0x03, 0x32, 0x92, 0x12, 0xF3, 0x80, 0x10, 0x00, 0xC7, 0xB8, + 0x50, 0xFC, 0x13, 0x00, 0x00, 0x00 + }; + std::map encoding_attributes = {{"page_encoding", "PLAIN"}, {"page_type", "DICTIONARY_PAGE"}}; + auto result = agent.Encrypt(test_data_gzip, encoding_attributes); + + ASSERT_NE(result, nullptr); + EXPECT_TRUE(result->success()); + EXPECT_GT(result->size(), 0); +} + // Test successful initialization and decryption TEST_F(LocalDataBatchProtectionAgentTest, SuccessfulDecryption) { LocalDataBatchProtectionAgent agent; diff --git a/src/server/encryption_sequencer.cpp b/src/server/encryption_sequencer.cpp index 9d8591e..143160a 100644 --- a/src/server/encryption_sequencer.cpp +++ b/src/server/encryption_sequencer.cpp @@ -123,8 +123,7 @@ LevelAndValueBytes DataBatchEncryptionSequencer::DecompressAndSplit( } if (page_type == "DICTIONARY_PAGE") { - // TODO: Check whether dictionary pages can be compressed. - result.value_bytes = plaintext; + result.value_bytes = Decompress(plaintext); result.level_bytes = std::vector(); return result; }