diff --git a/services/tunnelbroker/test/DatabaseManagerTest.cpp b/services/tunnelbroker/test/DatabaseManagerTest.cpp --- a/services/tunnelbroker/test/DatabaseManagerTest.cpp +++ b/services/tunnelbroker/test/DatabaseManagerTest.cpp @@ -22,3 +22,26 @@ Aws::ShutdownAPI({}); } }; + +TEST_F(DatabaseManagerTest, TestOperationsOnPublicKeyItem) { + const database::PublicKeyItem item( + "mobile:" + tools::generateRandomString(DEVICEID_CHAR_LENGTH), + tools::generateRandomString(451)); + EXPECT_EQ( + database::DatabaseManager::getInstance().isTableAvailable( + item.getTableName()), + true); + database::DatabaseManager::getInstance().putPublicKeyItem(item); + std::shared_ptr foundItem = + database::DatabaseManager::getInstance().findPublicKeyItem( + item.getDeviceID()); + EXPECT_NE(foundItem, nullptr); + EXPECT_EQ( + memcmp( + item.getPublicKey().data(), + foundItem->getPublicKey().data(), + item.getPublicKey().size()), + 0); + database::DatabaseManager::getInstance().removePublicKeyItem( + item.getDeviceID()); +}