aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-05-15 20:39:12 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-05-15 20:39:15 +0200
commit9163d30c3c62598e4177d57e0fc088e74def1c66 (patch)
tree1af4f1b09c142ef1afbba7df371e72de02e9de06 /tests
parentd8e5c76c364450179f12fa985d50b7e4bfb5aa78 (diff)
Allow storing user without nodes
Diffstat (limited to 'tests')
-rw-r--r--tests/main.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
index d2e49f9..5374c2d 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -202,6 +202,9 @@ int main()
string username = "dec05eba";
string password = "secretPassword";
+ if(database.doesStoredUserExist(username))
+ fail("Expected stored to not exist until it has been added");
+
database.storeUserPasswordEncrypted(*databaseNode.getRequestHash(), username, password, *adminUserKey);
try
{
@@ -213,6 +216,9 @@ int main()
Log::debug("Failed with sql exception as expected, since we already have an user in the node: %s", e.what());
}
+ if(!database.doesStoredUserExist(username))
+ fail("Expected stored to exist after it has been added");
+
auto nodeUserData = database.getStoredUserNodeDataDecrypted(username, password);
assertEquals((size_t)1, nodeUserData.size());
if(nodeUserData[0].nodeHash != *databaseNode.getRequestHash())
@@ -221,6 +227,20 @@ int main()
fail("Expected stored public key to match admin user public key");
if(nodeUserData[0].keyPair.getPrivateKey() != adminUserKey->getPrivateKey())
fail("Expected stored private key to match admin user private key");
+
+ try
+ {
+ database.storeUserWithoutNodes(username, password);
+ fail("Expected store user to fail since the user already exists in database");
+ }
+ catch(SqlExecException &e)
+ {
+
+ }
+
+ database.storeUserWithoutNodes("anotherUser", password);
+ if(!database.doesStoredUserExist("anotherUser"))
+ fail("Added user 'anotherUser' to database without any nodes, but it doesn't seem to be stored");
}
Log::debug("Callback works when adding data while connected, now testing to reconnect and check if data remains...");
{