Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/common/dbpa_local_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,30 @@ TEST_F(LocalDataBatchProtectionAgentTest, SuccessfulEncryption) {
EXPECT_GT(result->size(), 0);
}

TEST_F(LocalDataBatchProtectionAgentTest, SuccessfulEncryptionCompressedDictionary) {
LocalDataBatchProtectionAgent agent;

std::map<std::string, std::string> 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<uint8_t> 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<std::string, std::string> 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;
Expand Down
3 changes: 1 addition & 2 deletions src/server/encryption_sequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>();
return result;
}
Expand Down