aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-15 20:39:12 +0200
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:25:46 +0200
commit585d084fd3a5da06e04a5c95e41733009799a20e (patch)
tree2e16376897c238f25029d3c2dfc8641094b255e7 /tests
parente52be3a6b82025b6795b73d448381953821d18bb (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...");
{