From 1328d943c5016dd1662a4e46d4a408bca010cffc Mon Sep 17 00:00:00 2001 From: Aleksi Lindeman <0xdec05eba@gmail.com> Date: Sun, 11 Mar 2018 00:12:37 +0100 Subject: Add operation to allow users to be added to group WARNING! Lazy implementation everywhere, does not handle out-of-order packets --- tests/main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tests/main.cpp') diff --git a/tests/main.cpp b/tests/main.cpp index 0218c8c..4d3bcc3 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -83,16 +83,20 @@ void testEncryption() int main() { printf("Starting tests...\n"); - LocalUser *localUser = LocalUser::create(Signature::KeyPair(), "dec05eba"); + LocalUser *localUser = LocalUser::create(Signature::KeyPair(), "dec05eba", nullptr); testSignData(localUser); testEncryption(); testHash(); // TODO: Setup local bootstrap node for tests Database database("bootstrap.ring.cx", 4222, "storage"); - auto databaseCreateResponse = database.create("dec05eba", "latenight"); - const char *data = "hello, world!"; - database.add(databaseCreateResponse, DataView{ (void*)data, strlen(data) }); + auto databaseCreateResponse = database.create("adminUserName", "latenight"); + DatabaseNode databaseNode(databaseCreateResponse->getNodeEncryptionKey(), databaseCreateResponse->getRequestHash()); + auto adminUser = (LocalUser*)databaseCreateResponse->getNodeAdminUser(); + database.addData(databaseNode, adminUser, DataView{ (void*)"hello, world!", 13 }); + database.addUserToGroup(databaseNode, adminUser, localUser->getName(), localUser->getPublicKey(), adminUser->getGroups()[0]); + localUser->addToGroup(adminUser->getGroups()[0]); + database.addData(databaseNode, localUser, DataView{ (void*)"hello, aaald!", 13 }); database.commit(); database.seed(databaseCreateResponse->getRequestHash(), databaseCreateResponse->getNodeEncryptionKey()); -- cgit v1.2.3