From 7f19b686cc7b47346ba8bab89bb34188f366db10 Mon Sep 17 00:00:00 2001 From: dec05eba <0xdec05eba@gmail.com> Date: Wed, 16 May 2018 09:47:31 +0200 Subject: Store node encryption key with user data, fix encryption bug when using additional data --- tests/main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/main.cpp b/tests/main.cpp index 3f9bbf9..e4438e7 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -205,10 +205,10 @@ int main() if(database.doesStoredUserExist(username)) fail("Expected stored to not exist until it has been added"); - database.storeUserPasswordEncrypted(*databaseNode.getRequestHash(), username, password, *adminUserKey); + database.storeNodeInfoForUserEncrypted(databaseNode, username, password, *adminUserKey); try { - database.storeUserPasswordEncrypted(*databaseNode.getRequestHash(), username, password, localUserKeyPair); + database.storeNodeInfoForUserEncrypted(databaseNode, username, password, localUserKeyPair); fail("Expected store user password to fail since we have already stored an user in the node"); } catch(SqlExecException &e) @@ -219,15 +219,17 @@ int main() if(!database.doesStoredUserExist(username)) fail("Expected stored to exist after it has been added"); - auto nodeUserData = database.getStoredUserNodeDataDecrypted(username, password); + auto nodeUserData = database.getStoredNodeUserInfoDecrypted(username, password); assertEquals((size_t)1, nodeUserData.size()); auto userDataIt = nodeUserData.find(*databaseNode.getRequestHash()); if(userDataIt == nodeUserData.end()) fail("Expected stored node hash to match node hash"); - if(userDataIt->second.getPublicKey() != adminUserKey->getPublicKey()) + if(userDataIt->second.userKeyPair->getPublicKey() != adminUserKey->getPublicKey()) fail("Expected stored public key to match admin user public key"); - if(userDataIt->second.getPrivateKey() != adminUserKey->getPrivateKey()) + if(userDataIt->second.userKeyPair->getPrivateKey() != adminUserKey->getPrivateKey()) fail("Expected stored private key to match admin user private key"); + if(userDataIt->second.nodeEncryptionKey->getView() != databaseCreateResponse->getNodeEncryptionKey()->getView()) + fail("Expected stored node encryption key to match node encryption key"); try { -- cgit v1.2.3