aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-12-28 12:32:28 -0500
committerJack Lloyd <[email protected]>2017-12-28 12:32:28 -0500
commitb5a5246b52a0597948b1458d2c587d4576620754 (patch)
tree60460a83e96c9c2e61608172dd08d67610d22dd1
parent308022200f690aa089080c41e87cd518e8ef1868 (diff)
Add a test for distinct master keys in a single PSK_DB
-rw-r--r--src/tests/test_psk_db.cpp11
1 files changed, 11 insertions, 0 deletions
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<uint8_t> zeros(32);
+ const Botan::secure_vector<uint8_t> not_zeros = Test::rng().random_vec(32);
+
const std::string table_name = "bobby";
std::shared_ptr<Botan::SQL_Database> sqldb = std::make_shared<Botan::Sqlite3_Database>(":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<std::string> all_names = db.list_names();
result.test_eq("Expected number of names", all_names.size(), 3);