aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAleksi Lindeman <0xdec05eba@gmail.com>2018-03-11 00:12:37 +0100
committerAleksi Lindeman <0xdec05eba@gmail.com>2018-03-11 00:13:38 +0100
commit1328d943c5016dd1662a4e46d4a408bca010cffc (patch)
tree8483ee99e3831fca474a2b7b3743e8dbd0e6ee52 /tests
parent230e61091b401b8b2bb9496d557a15660fb5072b (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.cpp12
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());