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,42 @@ Aws::ShutdownAPI({}); } }; + +TEST_F(DatabaseManagerTest, TestOperationsOnPublicKeyItem) { + const database::PublicKeyItem item( + "mobile:EMQNoQ7b2ueEmQ4QsevRWlXxFCNt055y20T1PHdoYAQRt0S6TLzZWNM6XSvdWqxm", + "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9Q9wodsQdZNynbTnC35hA4mFW" + "mwZf9BhbI93aGAwPF9au0eYsawRz0jtYi4lSFXC9KleyQDg+6J+UW1kiWvE3ZRYG" + "ECqgx4zqajPTzVt7EAOGaIh/dPyQ6x2Ul1GlkkSYXUhhixEzExGp9g84eCyVkbCB" + "U3SK6SNKyR7anAXDVQIDAQAB"); + 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(item.getPublicKey(), foundItem->getPublicKey()); + database::DatabaseManager::getInstance().removePublicKeyItem( + item.getDeviceID()); +} + +TEST_F(DatabaseManagerTest, TestOperationsOnPublicKeyItemGenerated) { + 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(item.getPublicKey(), foundItem->getPublicKey()); + database::DatabaseManager::getInstance().removePublicKeyItem( + item.getDeviceID()); +}