mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Move post/message creation into clients
This way the forum and private group client do not need to keep track of message timestamps themselves and do not need to interact with post/message factories.
This commit is contained in:
@@ -3,16 +3,14 @@ package org.briarproject;
|
||||
import net.jodah.concurrentunit.Waiter;
|
||||
|
||||
import org.briarproject.api.Bytes;
|
||||
import org.briarproject.api.clients.MessageQueueManager;
|
||||
import org.briarproject.api.clients.ContactGroupFactory;
|
||||
import org.briarproject.api.clients.MessageQueueManager;
|
||||
import org.briarproject.api.clients.SessionId;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.crypto.KeyPair;
|
||||
import org.briarproject.api.crypto.KeyParser;
|
||||
import org.briarproject.api.crypto.PrivateKey;
|
||||
import org.briarproject.api.crypto.SecretKey;
|
||||
import org.briarproject.api.data.BdfList;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
@@ -820,12 +818,10 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
||||
|
||||
// sharer posts into the forum
|
||||
long time = clock.currentTimeMillis();
|
||||
byte[] body = TestUtils.getRandomBytes(42);
|
||||
KeyParser keyParser = cryptoComponent.getSignatureKeyParser();
|
||||
PrivateKey key = keyParser.parsePrivateKey(author0.getPrivateKey());
|
||||
String body = TestUtils.getRandomString(42);
|
||||
ForumPost p = forumPostFactory
|
||||
.createPseudonymousPost(forum0.getId(), time, null, author0,
|
||||
"text/plain", body, key);
|
||||
body);
|
||||
forumManager0.addLocalPost(p);
|
||||
|
||||
// sync forum post
|
||||
@@ -841,11 +837,10 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
||||
|
||||
// now invitee creates a post
|
||||
time = clock.currentTimeMillis();
|
||||
body = TestUtils.getRandomBytes(42);
|
||||
key = keyParser.parsePrivateKey(author1.getPrivateKey());
|
||||
body = TestUtils.getRandomString(42);
|
||||
p = forumPostFactory
|
||||
.createPseudonymousPost(forum0.getId(), time, null, author1,
|
||||
"text/plain", body, key);
|
||||
body);
|
||||
forumManager1.addLocalPost(p);
|
||||
|
||||
// sync forum post
|
||||
@@ -886,11 +881,10 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
||||
|
||||
// now invitee creates a post
|
||||
time = clock.currentTimeMillis();
|
||||
body = TestUtils.getRandomBytes(42);
|
||||
key = keyParser.parsePrivateKey(author1.getPrivateKey());
|
||||
body = TestUtils.getRandomString(42);
|
||||
p = forumPostFactory
|
||||
.createPseudonymousPost(forum0.getId(), time, null, author1,
|
||||
"text/plain", body, key);
|
||||
body);
|
||||
forumManager1.addLocalPost(p);
|
||||
|
||||
// sync forum post
|
||||
|
||||
@@ -6,8 +6,8 @@ import org.briarproject.api.crypto.PrivateKey;
|
||||
import org.briarproject.api.forum.ForumConstants;
|
||||
import org.briarproject.api.forum.ForumPost;
|
||||
import org.briarproject.api.forum.ForumPostFactory;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorFactory;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
import org.briarproject.api.messaging.MessagingConstants;
|
||||
import org.briarproject.api.messaging.PrivateMessage;
|
||||
import org.briarproject.api.messaging.PrivateMessageFactory;
|
||||
@@ -68,17 +68,17 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
|
||||
String authorName = TestUtils.getRandomString(
|
||||
MAX_AUTHOR_NAME_LENGTH);
|
||||
byte[] authorPublic = new byte[MAX_PUBLIC_KEY_LENGTH];
|
||||
Author author = authorFactory.createAuthor(authorName, authorPublic);
|
||||
PrivateKey privateKey = crypto.generateSignatureKeyPair().getPrivate();
|
||||
LocalAuthor author = authorFactory
|
||||
.createLocalAuthor(authorName, authorPublic,
|
||||
privateKey.getEncoded());
|
||||
// Create a maximum-length forum post
|
||||
GroupId groupId = new GroupId(TestUtils.getRandomId());
|
||||
long timestamp = Long.MAX_VALUE;
|
||||
MessageId parent = new MessageId(TestUtils.getRandomId());
|
||||
String contentType = TestUtils.getRandomString(
|
||||
ForumConstants.MAX_CONTENT_TYPE_LENGTH);
|
||||
byte[] body = new byte[MAX_FORUM_POST_BODY_LENGTH];
|
||||
PrivateKey privateKey = crypto.generateSignatureKeyPair().getPrivate();
|
||||
String body = TestUtils.getRandomString(MAX_FORUM_POST_BODY_LENGTH);
|
||||
ForumPost post = forumPostFactory.createPseudonymousPost(groupId,
|
||||
timestamp, parent, author, contentType, body, privateKey);
|
||||
timestamp, parent, author, body);
|
||||
// Check the size of the serialised message
|
||||
int length = post.getMessage().getRaw().length;
|
||||
assertTrue(length > UniqueId.LENGTH + 8 + UniqueId.LENGTH
|
||||
|
||||
Reference in New Issue
Block a user