Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3393911
D3686.id11841.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D3686.id11841.diff
View Options
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
@@ -96,3 +96,80 @@
database::DatabaseManager::getInstance().removeMessageItem(
item.getMessageID());
}
+
+TEST_F(DatabaseManagerTest, TestOperationsOnDeviceSessionItem) {
+ const database::DeviceSessionItem item(
+ "bc0c1aa2-bf09-11ec-9d64-0242ac120002",
+ "mobile:EMQNoQ7b2ueEmQ4QsevRWlXxFCNt055y20T1PHdoYAQRt0S6TLzZWNM6XSvdWqxm",
+ "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9Q9wodsQdZNynbTnC35hA4mFW"
+ "mwZf9BhbI93aGAwPF9au0eYsawRz0jtYi4lSFXC9KleyQDg+6J+UW1kiWvE3ZRYG"
+ "ECqgx4zqajPTzVt7EAOGaIh/dPyQ6x2Ul1GlkkSYXUhhixEzExGp9g84eCyVkbCB"
+ "U3SK6SNKyR7anAXDVQIDAQAB",
+ "hbI93aGAwPF9au0eYsawRz0jtYi4lSFXC9KleyQDg+6J+UW1kiWvE3",
+ "phone",
+ "ios:1.1.1",
+ "iOS 99.99.99");
+ EXPECT_EQ(
+ database::DatabaseManager::getInstance().isTableAvailable(
+ item.getTableName()),
+ true);
+ database::DatabaseManager::getInstance().putSessionItem(item);
+ std::shared_ptr<database::DeviceSessionItem> foundItem =
+ database::DatabaseManager::getInstance().findSessionItem(
+ item.getSessionID());
+ EXPECT_NE(foundItem, nullptr);
+ EXPECT_EQ(item.getDeviceID(), foundItem->getDeviceID());
+ EXPECT_EQ(item.getPubKey(), foundItem->getPubKey());
+ EXPECT_EQ(item.getNotifyToken(), foundItem->getNotifyToken());
+ EXPECT_EQ(item.getDeviceType(), foundItem->getDeviceType());
+ EXPECT_EQ(item.getAppVersion(), foundItem->getAppVersion());
+ EXPECT_EQ(item.getDeviceOs(), foundItem->getDeviceOs());
+ database::DatabaseManager::getInstance().removeSessionItem(
+ item.getSessionID());
+}
+
+TEST_F(DatabaseManagerTest, TestOperationsOnDeviceSessionItemGenerated) {
+ const database::DeviceSessionItem item(
+ tools::generateUUID(),
+ "mobile:" + tools::generateRandomString(DEVICEID_CHAR_LENGTH),
+ tools::generateRandomString(451),
+ tools::generateRandomString(64),
+ tools::generateRandomString(12),
+ tools::generateRandomString(12),
+ tools::generateRandomString(12));
+ EXPECT_EQ(
+ database::DatabaseManager::getInstance().isTableAvailable(
+ item.getTableName()),
+ true);
+ database::DatabaseManager::getInstance().putSessionItem(item);
+ std::shared_ptr<database::DeviceSessionItem> foundItem =
+ database::DatabaseManager::getInstance().findSessionItem(
+ item.getSessionID());
+ EXPECT_NE(foundItem, nullptr);
+ EXPECT_EQ(item.getDeviceID(), foundItem->getDeviceID())
+ << "Generated DeviceID \"" << item.getDeviceID()
+ << "\" differs from what is found in the database "
+ << foundItem->getDeviceID();
+ EXPECT_EQ(item.getPubKey(), foundItem->getPubKey())
+ << "Generated PubKey \"" << item.getPubKey()
+ << "\" differs from what is found in the database "
+ << foundItem->getPubKey();
+ EXPECT_EQ(item.getNotifyToken(), foundItem->getNotifyToken())
+ << "Generated NotifyToken \"" << item.getNotifyToken()
+ << "\" differs from what is found in the database "
+ << foundItem->getNotifyToken();
+ EXPECT_EQ(item.getDeviceType(), foundItem->getDeviceType())
+ << "Generated DeviceType \"" << item.getDeviceType()
+ << "\" differs from what is found in the database "
+ << foundItem->getDeviceType();
+ EXPECT_EQ(item.getAppVersion(), foundItem->getAppVersion())
+ << "Generated AppVersion \"" << item.getAppVersion()
+ << "\" differs from what is found in the database "
+ << foundItem->getAppVersion();
+ EXPECT_EQ(item.getDeviceOs(), foundItem->getDeviceOs())
+ << "Generated DeviceOS \"" << item.getDeviceOs()
+ << "\" differs from what is found in the database "
+ << foundItem->getDeviceOs();
+ database::DatabaseManager::getInstance().removeSessionItem(
+ item.getSessionID());
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 1, 4:25 PM (21 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605560
Default Alt Text
D3686.id11841.diff (3 KB)
Attached To
Mode
D3686: [services] Tunnelbroker - Database SessionItem tests
Attached
Detach File
Event Timeline
Log In to Comment