Page MenuHomePhabricator

D3687.id11548.diff
No OneTemporary

D3687.id11548.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,43 @@
Aws::ShutdownAPI({});
}
};
+
+TEST_F(DatabaseManagerTest, TestOperationsOnSessionSignItem) {
+ const database::SessionSignItem item(
+ "bB3OSLdKlY60KPBpw6VoGKX7Lmw3SA07FmNhnqnclvVeaxXueAQ0dpQSpiQTtlGn",
+ "mobile:EMQNoQ7b2ueEmQ4QsevRWlXxFCNt055y20T1PHdoYAQRt0S6TLzZWNM6XSvdWqxm";
+ EXPECT_EQ(
+ database::DatabaseManager::getInstance().isTableAvailable(
+ item.getTableName()),
+ true);
+ database::DatabaseManager::getInstance().putSessionSignItem(item);
+ std::shared_ptr<database::SessionSignItem> foundItem =
+ database::DatabaseManager::getInstance().findSessionSignItem(
+ item.getDeviceID());
+ EXPECT_NE(foundItem, nullptr);
+ EXPECT_EQ(item.getSign(), foundItem->getSign());
+ database::DatabaseManager::getInstance().removeSessionSignItem(
+ item.getDeviceID());
+}
+
+TEST_F(DatabaseManagerTest, TestOperationsOnSessionSignItemGenerated) {
+ const database::SessionSignItem item(
+ tools::generateRandomString(SIGNATURE_REQUEST_LENGTH),
+ "mobile:" + tools::generateRandomString(DEVICEID_CHAR_LENGTH));
+ EXPECT_EQ(
+ database::DatabaseManager::getInstance().isTableAvailable(
+ item.getTableName()),
+ true);
+ database::DatabaseManager::getInstance().putSessionSignItem(item);
+ std::shared_ptr<database::SessionSignItem> foundItem =
+ database::DatabaseManager::getInstance().findSessionSignItem(
+ item.getDeviceID());
+ EXPECT_NE(foundItem, nullptr) << "Item with the key of deviceID \""
+ << item.getDeviceID() << "\" is not found";
+ EXPECT_EQ(item.getSign(), foundItem->getSign())
+ << "Generated signature value \"" << item.getSign()
+ << "\" is not equal of \"" + foundItem->getSign() +
+ "\" from the database value";
+ database::DatabaseManager::getInstance().removeSessionSignItem(
+ item.getDeviceID());
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 4:14 PM (21 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605504
Default Alt Text
D3687.id11548.diff (2 KB)

Event Timeline