aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-15 18:24:50 +0200
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:25:46 +0200
commite52be3a6b82025b6795b73d448381953821d18bb (patch)
treec7dfaf9e2ed9020d5c6a595f803f501c4f20de54 /tests
parent0f95a9de53f23db735b7f1d1ecdb7acdd59bba0d (diff)
Add methods to store/retrieve encrypted user (using argon2 for hash)
Diffstat (limited to 'tests')
-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...");
{