aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-05-15 18:24:50 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-05-15 18:24:53 +0200
commitd8e5c76c364450179f12fa985d50b7e4bfb5aa78 (patch)
tree567259ef8e3e662d6b742b9d33ad67f5c9f7545e /tests
parent66ec8dd9b9d3f1f71ce2158c2603586814cc7b8d (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...");
{