From 9163d30c3c62598e4177d57e0fc088e74def1c66 Mon Sep 17 00:00:00 2001 From: dec05eba <0xdec05eba@gmail.com> Date: Tue, 15 May 2018 20:39:12 +0200 Subject: Allow storing user without nodes --- tests/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') 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..."); { -- cgit v1.2.3