From b5a5246b52a0597948b1458d2c587d4576620754 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Thu, 28 Dec 2017 12:32:28 -0500 Subject: Add a test for distinct master keys in a single PSK_DB --- src/tests/test_psk_db.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tests/test_psk_db.cpp b/src/tests/test_psk_db.cpp index f9eb9d7e8..87a0b4381 100644 --- a/src/tests/test_psk_db.cpp +++ b/src/tests/test_psk_db.cpp @@ -181,6 +181,8 @@ class PSK_DB_Tests final : public Test Test::Result result("PSK_DB SQL"); const Botan::secure_vector zeros(32); + const Botan::secure_vector not_zeros = Test::rng().random_vec(32); + const std::string table_name = "bobby"; std::shared_ptr sqldb = std::make_shared(":memory:"); @@ -211,6 +213,15 @@ class PSK_DB_Tests final : public Test test_entry(result, sqldb, table_name, "KyYo272vlSjClM2F0OZBMlRYjr33ZXv2jN1oY8OfCEs=", "tCl1qShSTsXi9tA5Kpo9vg=="); result.test_eq("DB read", db.get_str("leroy jeeeeeeeenkins"), "chicken"); + /* + * Test that we can have another database in the same table with distinct key + * without any problems. + */ + Botan::Encrypted_PSK_Database_SQL db2(not_zeros, sqldb, table_name); + db2.set_str("name", "price&value"); + result.test_eq("DB read", db2.get_str("name"), "price&value"); + result.test_eq("DB2 size", db2.list_names().size(), 1); + std::set all_names = db.list_names(); result.test_eq("Expected number of names", all_names.size(), 3); -- cgit v1.2.3