aboutsummaryrefslogtreecommitdiff
path: root/tests/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/main.cpp')
-rw-r--r--tests/main.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
index 07e7131..d2e49f9 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -199,6 +199,28 @@ int main()
assertEquals(1, createNodeCounter);
assertEquals(2, addDataCounter);
assertEquals(1, addUserCounter);
+
+ string username = "dec05eba";
+ string password = "secretPassword";
+ database.storeUserPasswordEncrypted(*databaseNode.getRequestHash(), username, password, *adminUserKey);
+ try
+ {
+ database.storeUserPasswordEncrypted(*databaseNode.getRequestHash(), username, password, localUserKeyPair);
+ fail("Expected store user password to fail since we have already stored an user in the node");
+ }
+ catch(SqlExecException &e)
+ {
+ Log::debug("Failed with sql exception as expected, since we already have an user in the node: %s", e.what());
+ }
+
+ auto nodeUserData = database.getStoredUserNodeDataDecrypted(username, password);
+ assertEquals((size_t)1, nodeUserData.size());
+ if(nodeUserData[0].nodeHash != *databaseNode.getRequestHash())
+ fail("Expected stored node hash to match node hash");
+ if(nodeUserData[0].keyPair.getPublicKey() != adminUserKey->getPublicKey())
+ 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");
}
Log::debug("Callback works when adding data while connected, now testing to reconnect and check if data remains...");
{