diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-03-11 00:12:37 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 23:25:46 +0200 |
commit | 6099ec04bd0d98b9e75f5b55b1215c94ccf20202 (patch) | |
tree | 9a551e8e723cde057610d6071587bc76b4a6af19 /tests | |
parent | 0e62cb8e5ed06d906ad84321cdda22acfcc952c9 (diff) |
Add operation to allow users to be added to group
WARNING! Lazy implementation everywhere, does not handle out-of-order
packets
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
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()); |