Page MenuHomePhabricator

D3688.id11699.diff
No OneTemporary

D3688.id11699.diff

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,45 @@
Aws::ShutdownAPI({});
}
};
+
+TEST_F(DatabaseManagerTest, PutAndFoundPublicKeyItemsStaticDataIsSame) {
+ 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<database::PublicKeyItem> 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, PutAndFoundPublicKeyItemsGeneratedDataIsSame) {
+ 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<database::PublicKeyItem> foundItem =
+ database::DatabaseManager::getInstance().findPublicKeyItem(
+ item.getDeviceID());
+ EXPECT_NE(foundItem, nullptr);
+ EXPECT_EQ(item.getPublicKey(), foundItem->getPublicKey())
+ << "Generated PublicKey \"" << item.getPublicKey()
+ << "\" differs from what is found in the database "
+ << foundItem->getPublicKey();
+ database::DatabaseManager::getInstance().removePublicKeyItem(
+ item.getDeviceID());
+}

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 4, 11:31 AM (9 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2614119
Default Alt Text
D3688.id11699.diff (2 KB)

Event Timeline