mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 22:59:54 +01:00
Include client version in group ID derivation.
This commit is contained in:
@@ -12,18 +12,19 @@ public interface ContactGroupFactory {
|
|||||||
/**
|
/**
|
||||||
* Creates a group that is not shared with any contacts.
|
* Creates a group that is not shared with any contacts.
|
||||||
*/
|
*/
|
||||||
Group createLocalGroup(ClientId clientId);
|
Group createLocalGroup(ClientId clientId, int clientVersion);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a group for the given client to share with the given contact.
|
* Creates a group for the given client to share with the given contact.
|
||||||
*/
|
*/
|
||||||
Group createContactGroup(ClientId clientId, Contact contact);
|
Group createContactGroup(ClientId clientId, int clientVersion,
|
||||||
|
Contact contact);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a group for the given client to share between the given authors
|
* Creates a group for the given client to share between the given authors
|
||||||
* identified by their AuthorIds.
|
* identified by their AuthorIds.
|
||||||
*/
|
*/
|
||||||
Group createContactGroup(ClientId clientId, AuthorId authorId1,
|
Group createContactGroup(ClientId clientId, int clientVersion,
|
||||||
AuthorId authorId2);
|
AuthorId authorId1, AuthorId authorId2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ public interface TransportPropertyManager {
|
|||||||
*/
|
*/
|
||||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.properties");
|
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.properties");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current version of the transport property client.
|
||||||
|
*/
|
||||||
|
int CLIENT_VERSION = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the given properties received while adding a contact - they will
|
* Stores the given properties received while adding a contact - they will
|
||||||
* be superseded by any properties synced from the contact.
|
* be superseded by any properties synced from the contact.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|||||||
public interface GroupFactory {
|
public interface GroupFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a group with the given client ID and descriptor.
|
* Creates a group with the given client ID, client version and descriptor.
|
||||||
*/
|
*/
|
||||||
Group createGroup(ClientId c, byte[] descriptor);
|
Group createGroup(ClientId c, int clientVersion, byte[] descriptor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,23 +32,25 @@ class ContactGroupFactoryImpl implements ContactGroupFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group createLocalGroup(ClientId clientId) {
|
public Group createLocalGroup(ClientId clientId, int clientVersion) {
|
||||||
return groupFactory.createGroup(clientId, LOCAL_GROUP_DESCRIPTOR);
|
return groupFactory.createGroup(clientId, clientVersion,
|
||||||
|
LOCAL_GROUP_DESCRIPTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group createContactGroup(ClientId clientId, Contact contact) {
|
public Group createContactGroup(ClientId clientId, int clientVersion,
|
||||||
|
Contact contact) {
|
||||||
AuthorId local = contact.getLocalAuthorId();
|
AuthorId local = contact.getLocalAuthorId();
|
||||||
AuthorId remote = contact.getAuthor().getId();
|
AuthorId remote = contact.getAuthor().getId();
|
||||||
byte[] descriptor = createGroupDescriptor(local, remote);
|
byte[] descriptor = createGroupDescriptor(local, remote);
|
||||||
return groupFactory.createGroup(clientId, descriptor);
|
return groupFactory.createGroup(clientId, clientVersion, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group createContactGroup(ClientId clientId, AuthorId authorId1,
|
public Group createContactGroup(ClientId clientId, int clientVersion,
|
||||||
AuthorId authorId2) {
|
AuthorId authorId1, AuthorId authorId2) {
|
||||||
byte[] descriptor = createGroupDescriptor(authorId1, authorId2);
|
byte[] descriptor = createGroupDescriptor(authorId1, authorId2);
|
||||||
return groupFactory.createGroup(clientId, descriptor);
|
return groupFactory.createGroup(clientId, clientVersion, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] createGroupDescriptor(AuthorId local, AuthorId remote) {
|
private byte[] createGroupDescriptor(AuthorId local, AuthorId remote) {
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
|||||||
this.metadataParser = metadataParser;
|
this.metadataParser = metadataParser;
|
||||||
this.contactGroupFactory = contactGroupFactory;
|
this.contactGroupFactory = contactGroupFactory;
|
||||||
this.clock = clock;
|
this.clock = clock;
|
||||||
localGroup = contactGroupFactory.createLocalGroup(CLIENT_ID);
|
localGroup = contactGroupFactory.createLocalGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -287,7 +288,8 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Group getContactGroup(Contact c) {
|
private Group getContactGroup(Contact c) {
|
||||||
return contactGroupFactory.createContactGroup(CLIENT_ID, c);
|
return contactGroupFactory.createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeMessage(Transaction txn, GroupId g, TransportId t,
|
private void storeMessage(Transaction txn, GroupId g, TransportId t,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.briarproject.bramble.api.sync.ClientId;
|
|||||||
import org.briarproject.bramble.api.sync.Group;
|
import org.briarproject.bramble.api.sync.Group;
|
||||||
import org.briarproject.bramble.api.sync.GroupFactory;
|
import org.briarproject.bramble.api.sync.GroupFactory;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
|
import org.briarproject.bramble.util.ByteUtils;
|
||||||
import org.briarproject.bramble.util.StringUtils;
|
import org.briarproject.bramble.util.StringUtils;
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
@@ -13,6 +14,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import static org.briarproject.bramble.api.sync.GroupId.LABEL;
|
import static org.briarproject.bramble.api.sync.GroupId.LABEL;
|
||||||
import static org.briarproject.bramble.api.sync.SyncConstants.PROTOCOL_VERSION;
|
import static org.briarproject.bramble.api.sync.SyncConstants.PROTOCOL_VERSION;
|
||||||
|
import static org.briarproject.bramble.util.ByteUtils.INT_32_BYTES;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -26,9 +28,12 @@ class GroupFactoryImpl implements GroupFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group createGroup(ClientId c, byte[] descriptor) {
|
public Group createGroup(ClientId c, int clientVersion, byte[] descriptor) {
|
||||||
|
byte[] clientVersionBytes = new byte[INT_32_BYTES];
|
||||||
|
ByteUtils.writeUint32(clientVersion, clientVersionBytes, 0);
|
||||||
byte[] hash = crypto.hash(LABEL, new byte[] {PROTOCOL_VERSION},
|
byte[] hash = crypto.hash(LABEL, new byte[] {PROTOCOL_VERSION},
|
||||||
StringUtils.toUtf8(c.getString()), descriptor);
|
StringUtils.toUtf8(c.getString()), clientVersionBytes,
|
||||||
|
descriptor);
|
||||||
return new Group(new GroupId(hash), c, descriptor);
|
return new Group(new GroupId(hash), c, descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import java.util.Map;
|
|||||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||||
import static org.briarproject.bramble.api.properties.TransportPropertyManager.CLIENT_ID;
|
import static org.briarproject.bramble.api.properties.TransportPropertyManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.bramble.api.properties.TransportPropertyManager.CLIENT_VERSION;
|
||||||
import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;
|
import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;
|
||||||
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
||||||
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
||||||
@@ -78,7 +79,8 @@ public class TransportPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
|
|
||||||
private TransportPropertyManagerImpl createInstance() {
|
private TransportPropertyManagerImpl createInstance() {
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(contactGroupFactory).createLocalGroup(CLIENT_ID);
|
oneOf(contactGroupFactory).createLocalGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION);
|
||||||
will(returnValue(localGroup));
|
will(returnValue(localGroup));
|
||||||
}});
|
}});
|
||||||
return new TransportPropertyManagerImpl(db, clientHelper,
|
return new TransportPropertyManagerImpl(db, clientHelper,
|
||||||
@@ -98,12 +100,14 @@ public class TransportPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
oneOf(db).getContacts(txn);
|
oneOf(db).getContacts(txn);
|
||||||
will(returnValue(contacts));
|
will(returnValue(contacts));
|
||||||
// The first contact's group has already been set up
|
// The first contact's group has already been set up
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact1);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact1);
|
||||||
will(returnValue(contactGroup1));
|
will(returnValue(contactGroup1));
|
||||||
oneOf(db).containsGroup(txn, contactGroup1.getId());
|
oneOf(db).containsGroup(txn, contactGroup1.getId());
|
||||||
will(returnValue(true));
|
will(returnValue(true));
|
||||||
// The second contact's group hasn't been set up
|
// The second contact's group hasn't been set up
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact2);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact2);
|
||||||
will(returnValue(contactGroup2));
|
will(returnValue(contactGroup2));
|
||||||
oneOf(db).containsGroup(txn, contactGroup2.getId());
|
oneOf(db).containsGroup(txn, contactGroup2.getId());
|
||||||
will(returnValue(false));
|
will(returnValue(false));
|
||||||
@@ -130,7 +134,8 @@ public class TransportPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
|
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
// Create the group and share it with the contact
|
// Create the group and share it with the contact
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(db).containsGroup(txn, contactGroup.getId());
|
oneOf(db).containsGroup(txn, contactGroup.getId());
|
||||||
will(returnValue(false));
|
will(returnValue(false));
|
||||||
@@ -156,7 +161,8 @@ public class TransportPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
Group contactGroup = getGroup();
|
Group contactGroup = getGroup();
|
||||||
|
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(db).removeGroup(txn, contactGroup);
|
oneOf(db).removeGroup(txn, contactGroup);
|
||||||
}});
|
}});
|
||||||
@@ -297,7 +303,8 @@ public class TransportPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(db).getContact(txn, contact.getId());
|
oneOf(db).getContact(txn, contact.getId());
|
||||||
will(returnValue(contact));
|
will(returnValue(contact));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
}});
|
}});
|
||||||
expectStoreMessage(txn, contactGroup.getId(), "foo", fooPropertiesDict,
|
expectStoreMessage(txn, contactGroup.getId(), "foo", fooPropertiesDict,
|
||||||
@@ -431,13 +438,15 @@ public class TransportPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
will(returnValue(contacts));
|
will(returnValue(contacts));
|
||||||
// First contact: skipped because not active
|
// First contact: skipped because not active
|
||||||
// Second contact: no updates
|
// Second contact: no updates
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact2);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact2);
|
||||||
will(returnValue(contactGroup2));
|
will(returnValue(contactGroup2));
|
||||||
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
|
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
|
||||||
contactGroup2.getId());
|
contactGroup2.getId());
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
// Third contact: returns an update
|
// Third contact: returns an update
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact3);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact3);
|
||||||
will(returnValue(contactGroup3));
|
will(returnValue(contactGroup3));
|
||||||
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
|
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
|
||||||
contactGroup3.getId());
|
contactGroup3.getId());
|
||||||
@@ -507,7 +516,8 @@ public class TransportPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
// Store the new properties in each contact's group, version 1
|
// Store the new properties in each contact's group, version 1
|
||||||
oneOf(db).getContacts(txn);
|
oneOf(db).getContacts(txn);
|
||||||
will(returnValue(Collections.singletonList(contact)));
|
will(returnValue(Collections.singletonList(contact)));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
|
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
|
||||||
contactGroup.getId());
|
contactGroup.getId());
|
||||||
@@ -559,7 +569,8 @@ public class TransportPropertyManagerImplTest extends BrambleMockTestCase {
|
|||||||
// Store the merged properties in each contact's group, version 2
|
// Store the merged properties in each contact's group, version 2
|
||||||
oneOf(db).getContacts(txn);
|
oneOf(db).getContacts(txn);
|
||||||
will(returnValue(Collections.singletonList(contact)));
|
will(returnValue(Collections.singletonList(contact)));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
|
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
|
||||||
contactGroup.getId());
|
contactGroup.getId());
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import org.briarproject.bramble.api.transport.StreamReaderFactory;
|
|||||||
import org.briarproject.bramble.api.transport.StreamWriterFactory;
|
import org.briarproject.bramble.api.transport.StreamWriterFactory;
|
||||||
import org.briarproject.bramble.test.BrambleTestCase;
|
import org.briarproject.bramble.test.BrambleTestCase;
|
||||||
import org.briarproject.bramble.test.TestUtils;
|
import org.briarproject.bramble.test.TestUtils;
|
||||||
import org.briarproject.bramble.util.StringUtils;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@@ -37,6 +36,7 @@ import javax.inject.Inject;
|
|||||||
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
||||||
import static org.briarproject.bramble.api.transport.TransportConstants.PROTOCOL_VERSION;
|
import static org.briarproject.bramble.api.transport.TransportConstants.PROTOCOL_VERSION;
|
||||||
import static org.briarproject.bramble.api.transport.TransportConstants.TAG_LENGTH;
|
import static org.briarproject.bramble.api.transport.TransportConstants.TAG_LENGTH;
|
||||||
|
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@@ -79,9 +79,11 @@ public class SyncIntegrationTest extends BrambleTestCase {
|
|||||||
headerKey = TestUtils.getSecretKey();
|
headerKey = TestUtils.getSecretKey();
|
||||||
streamNumber = 123;
|
streamNumber = 123;
|
||||||
// Create a group
|
// Create a group
|
||||||
ClientId clientId = new ClientId(StringUtils.getRandomString(5));
|
ClientId clientId = new ClientId(getRandomString(123));
|
||||||
|
int clientVersion = 1234567890;
|
||||||
byte[] descriptor = new byte[MAX_GROUP_DESCRIPTOR_LENGTH];
|
byte[] descriptor = new byte[MAX_GROUP_DESCRIPTOR_LENGTH];
|
||||||
Group group = groupFactory.createGroup(clientId, descriptor);
|
Group group = groupFactory.createGroup(clientId, clientVersion,
|
||||||
|
descriptor);
|
||||||
// Add two messages to the group
|
// Add two messages to the group
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
byte[] body = "Hello world".getBytes("UTF-8");
|
byte[] body = "Hello world".getBytes("UTF-8");
|
||||||
|
|||||||
@@ -17,10 +17,15 @@ import javax.annotation.Nullable;
|
|||||||
public interface BlogManager {
|
public interface BlogManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unique ID of the blog client.
|
* The unique ID of the blog client.
|
||||||
*/
|
*/
|
||||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.blog");
|
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.blog");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current version of the blog client.
|
||||||
|
*/
|
||||||
|
int CLIENT_VERSION = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given {@link Blog).}
|
* Adds the given {@link Blog).}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,6 +5,13 @@ import org.briarproject.briar.api.sharing.SharingManager;
|
|||||||
|
|
||||||
public interface BlogSharingManager extends SharingManager<Blog> {
|
public interface BlogSharingManager extends SharingManager<Blog> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unique ID of the blog sharing client.
|
||||||
|
*/
|
||||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.blog.sharing");
|
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.blog.sharing");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current version of the blog sharing client.
|
||||||
|
*/
|
||||||
|
int CLIENT_VERSION = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ public interface FeedManager {
|
|||||||
*/
|
*/
|
||||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.feed");
|
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.feed");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current version of the RSS feed client.
|
||||||
|
*/
|
||||||
|
int CLIENT_VERSION = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an RSS feed as a new dedicated blog.
|
* Adds an RSS feed as a new dedicated blog.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ public interface ForumManager {
|
|||||||
*/
|
*/
|
||||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.forum");
|
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.forum");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current version of the forum client.
|
||||||
|
*/
|
||||||
|
int CLIENT_VERSION = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes to a forum.
|
* Subscribes to a forum.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,6 +5,13 @@ import org.briarproject.briar.api.sharing.SharingManager;
|
|||||||
|
|
||||||
public interface ForumSharingManager extends SharingManager<Forum> {
|
public interface ForumSharingManager extends SharingManager<Forum> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unique ID of the forum sharing client.
|
||||||
|
*/
|
||||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.forum.sharing");
|
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.forum.sharing");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current version of the forum sharing client.
|
||||||
|
*/
|
||||||
|
int CLIENT_VERSION = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,11 +86,6 @@ public interface IntroductionConstants {
|
|||||||
int TASK_ACTIVATE_CONTACT = 1;
|
int TASK_ACTIVATE_CONTACT = 1;
|
||||||
int TASK_ABORT = 2;
|
int TASK_ABORT = 2;
|
||||||
|
|
||||||
/**
|
|
||||||
* The current version of the introduction protocol.
|
|
||||||
*/
|
|
||||||
int PROTOCOL_VERSION = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Label for deriving the shared secret.
|
* Label for deriving the shared secret.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ public interface IntroductionManager extends ConversationClient {
|
|||||||
*/
|
*/
|
||||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.introduction");
|
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.introduction");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current version of the introduction client.
|
||||||
|
*/
|
||||||
|
int CLIENT_VERSION = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends two initial introduction messages.
|
* Sends two initial introduction messages.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ public interface MessagingManager extends ConversationClient {
|
|||||||
*/
|
*/
|
||||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.messaging");
|
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.messaging");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current version of the messaging client.
|
||||||
|
*/
|
||||||
|
int CLIENT_VERSION = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a local private message.
|
* Stores a local private message.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ public interface PrivateGroupManager {
|
|||||||
*/
|
*/
|
||||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.privategroup");
|
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.privategroup");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current version of the private group client.
|
||||||
|
*/
|
||||||
|
int CLIENT_VERSION = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new private group and joins it.
|
* Adds a new private group and joins it.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ public interface GroupInvitationManager extends ConversationClient {
|
|||||||
ClientId CLIENT_ID =
|
ClientId CLIENT_ID =
|
||||||
new ClientId("org.briarproject.briar.privategroup.invitation");
|
new ClientId("org.briarproject.briar.privategroup.invitation");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current version of the private group invitation client.
|
||||||
|
*/
|
||||||
|
int CLIENT_VERSION = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends an invitation to share the given private group with the given
|
* Sends an invitation to share the given private group with the given
|
||||||
* contact, including an optional message.
|
* contact, including an optional message.
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||||
|
import static org.briarproject.briar.api.blog.BlogManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.blog.BlogManager.CLIENT_VERSION;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -52,8 +54,8 @@ class BlogFactoryImpl implements BlogFactory {
|
|||||||
rssFeed
|
rssFeed
|
||||||
);
|
);
|
||||||
byte[] descriptor = clientHelper.toByteArray(blog);
|
byte[] descriptor = clientHelper.toByteArray(blog);
|
||||||
Group g = groupFactory
|
Group g = groupFactory.createGroup(CLIENT_ID, CLIENT_VERSION,
|
||||||
.createGroup(BlogManagerImpl.CLIENT_ID, descriptor);
|
descriptor);
|
||||||
return new Blog(g, a, rssFeed);
|
return new Blog(g, a, rssFeed);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ import static org.briarproject.briar.api.blog.BlogConstants.KEY_TIME_RECEIVED;
|
|||||||
import static org.briarproject.briar.api.blog.BlogConstants.KEY_TYPE;
|
import static org.briarproject.briar.api.blog.BlogConstants.KEY_TYPE;
|
||||||
import static org.briarproject.briar.api.blog.BlogConstants.MAX_BLOG_COMMENT_LENGTH;
|
import static org.briarproject.briar.api.blog.BlogConstants.MAX_BLOG_COMMENT_LENGTH;
|
||||||
import static org.briarproject.briar.api.blog.BlogConstants.MAX_BLOG_POST_BODY_LENGTH;
|
import static org.briarproject.briar.api.blog.BlogConstants.MAX_BLOG_POST_BODY_LENGTH;
|
||||||
|
import static org.briarproject.briar.api.blog.BlogManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.blog.BlogManager.CLIENT_VERSION;
|
||||||
import static org.briarproject.briar.api.blog.BlogPostFactory.SIGNING_LABEL_COMMENT;
|
import static org.briarproject.briar.api.blog.BlogPostFactory.SIGNING_LABEL_COMMENT;
|
||||||
import static org.briarproject.briar.api.blog.BlogPostFactory.SIGNING_LABEL_POST;
|
import static org.briarproject.briar.api.blog.BlogPostFactory.SIGNING_LABEL_POST;
|
||||||
import static org.briarproject.briar.api.blog.MessageType.COMMENT;
|
import static org.briarproject.briar.api.blog.MessageType.COMMENT;
|
||||||
@@ -199,8 +201,8 @@ class BlogPostValidator extends BdfMessageValidator {
|
|||||||
checkLength(signature, 1, MAX_SIGNATURE_LENGTH);
|
checkLength(signature, 1, MAX_SIGNATURE_LENGTH);
|
||||||
|
|
||||||
// Get and Validate the Wrapped Message
|
// Get and Validate the Wrapped Message
|
||||||
Group wGroup = groupFactory
|
Group wGroup = groupFactory.createGroup(CLIENT_ID, CLIENT_VERSION,
|
||||||
.createGroup(BlogManagerImpl.CLIENT_ID, descriptor);
|
descriptor);
|
||||||
Blog wBlog = blogFactory.parseBlog(wGroup);
|
Blog wBlog = blogFactory.parseBlog(wGroup);
|
||||||
BdfList wBodyList = BdfList.of(POST.getInt(), content, signature);
|
BdfList wBodyList = BdfList.of(POST.getInt(), content, signature);
|
||||||
byte[] wBody = clientHelper.toByteArray(wBodyList);
|
byte[] wBody = clientHelper.toByteArray(wBodyList);
|
||||||
@@ -262,8 +264,8 @@ class BlogPostValidator extends BdfMessageValidator {
|
|||||||
MessageId parentId = new MessageId(parentIdBytes);
|
MessageId parentId = new MessageId(parentIdBytes);
|
||||||
|
|
||||||
// Get and Validate the Wrapped Comment
|
// Get and Validate the Wrapped Comment
|
||||||
Group wGroup = groupFactory
|
Group wGroup = groupFactory.createGroup(CLIENT_ID, CLIENT_VERSION,
|
||||||
.createGroup(BlogManagerImpl.CLIENT_ID, descriptor);
|
descriptor);
|
||||||
BdfList wBodyList = BdfList.of(COMMENT.getInt(), comment, pOriginalId,
|
BdfList wBodyList = BdfList.of(COMMENT.getInt(), comment, pOriginalId,
|
||||||
oldId, signature);
|
oldId, signature);
|
||||||
byte[] wBody = clientHelper.toByteArray(wBodyList);
|
byte[] wBody = clientHelper.toByteArray(wBodyList);
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ class FeedManagerImpl implements FeedManager, Client, EventListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Group getLocalGroup() {
|
private Group getLocalGroup() {
|
||||||
return contactGroupFactory.createLocalGroup(CLIENT_ID);
|
return contactGroupFactory.createLocalGroup(CLIENT_ID, CLIENT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import javax.inject.Inject;
|
|||||||
import static org.briarproject.briar.api.forum.ForumConstants.FORUM_SALT_LENGTH;
|
import static org.briarproject.briar.api.forum.ForumConstants.FORUM_SALT_LENGTH;
|
||||||
import static org.briarproject.briar.api.forum.ForumConstants.MAX_FORUM_NAME_LENGTH;
|
import static org.briarproject.briar.api.forum.ForumConstants.MAX_FORUM_NAME_LENGTH;
|
||||||
import static org.briarproject.briar.api.forum.ForumManager.CLIENT_ID;
|
import static org.briarproject.briar.api.forum.ForumManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.forum.ForumManager.CLIENT_VERSION;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -52,7 +53,8 @@ class ForumFactoryImpl implements ForumFactory {
|
|||||||
try {
|
try {
|
||||||
BdfList forum = BdfList.of(name, salt);
|
BdfList forum = BdfList.of(name, salt);
|
||||||
byte[] descriptor = clientHelper.toByteArray(forum);
|
byte[] descriptor = clientHelper.toByteArray(forum);
|
||||||
Group g = groupFactory.createGroup(CLIENT_ID, descriptor);
|
Group g = groupFactory.createGroup(CLIENT_ID, CLIENT_VERSION,
|
||||||
|
descriptor);
|
||||||
return new Forum(g, name, salt);
|
return new Forum(g, name, salt);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ import static org.briarproject.briar.api.introduction.IntroductionConstants.OUR_
|
|||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.OUR_SIGNATURE;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.OUR_SIGNATURE;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.OUR_TIME;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.OUR_TIME;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.OUR_TRANSPORT;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.OUR_TRANSPORT;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.PROTOCOL_VERSION;
|
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.PUBLIC_KEY;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.PUBLIC_KEY;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.REMOTE_AUTHOR_ID;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.REMOTE_AUTHOR_ID;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.REMOTE_AUTHOR_IS_US;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.REMOTE_AUTHOR_IS_US;
|
||||||
@@ -97,6 +96,7 @@ import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE
|
|||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_ABORT;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_ABORT;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_ACK;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_ACK;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_RESPONSE;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_RESPONSE;
|
||||||
|
import static org.briarproject.briar.api.introduction.IntroductionManager.CLIENT_VERSION;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -435,7 +435,7 @@ class IntroduceeManager {
|
|||||||
// The shared secret is derived from the local ephemeral key pair
|
// The shared secret is derived from the local ephemeral key pair
|
||||||
// and the remote ephemeral public key
|
// and the remote ephemeral public key
|
||||||
byte[][] inputs = {
|
byte[][] inputs = {
|
||||||
new byte[] {PROTOCOL_VERSION},
|
new byte[] {CLIENT_VERSION},
|
||||||
alice ? ourPublicKeyBytes : theirPublicKeyBytes,
|
alice ? ourPublicKeyBytes : theirPublicKeyBytes,
|
||||||
alice ? theirPublicKeyBytes : ourPublicKeyBytes
|
alice ? theirPublicKeyBytes : ourPublicKeyBytes
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.briarproject.bramble.api.sync.Group;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionManager.CLIENT_ID;
|
import static org.briarproject.briar.api.introduction.IntroductionManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.introduction.IntroductionManager.CLIENT_VERSION;
|
||||||
|
|
||||||
class IntroductionGroupFactory {
|
class IntroductionGroupFactory {
|
||||||
|
|
||||||
@@ -16,14 +17,16 @@ class IntroductionGroupFactory {
|
|||||||
@Inject
|
@Inject
|
||||||
IntroductionGroupFactory(ContactGroupFactory contactGroupFactory) {
|
IntroductionGroupFactory(ContactGroupFactory contactGroupFactory) {
|
||||||
this.contactGroupFactory = contactGroupFactory;
|
this.contactGroupFactory = contactGroupFactory;
|
||||||
localGroup = contactGroupFactory.createLocalGroup(CLIENT_ID);
|
localGroup = contactGroupFactory.createLocalGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
Group createIntroductionGroup(Contact c) {
|
Group createIntroductionGroup(Contact c) {
|
||||||
return contactGroupFactory.createContactGroup(CLIENT_ID, c);
|
return contactGroupFactory.createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Group createLocalGroup() {
|
Group createLocalGroup() {
|
||||||
return localGroup;
|
return localGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ class MessagingManagerImpl extends ConversationClientImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group getContactGroup(Contact c) {
|
public Group getContactGroup(Contact c) {
|
||||||
return contactGroupFactory.createContactGroup(CLIENT_ID, c);
|
return contactGroupFactory.createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import javax.inject.Inject;
|
|||||||
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.GROUP_SALT_LENGTH;
|
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.GROUP_SALT_LENGTH;
|
||||||
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_NAME_LENGTH;
|
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_NAME_LENGTH;
|
||||||
import static org.briarproject.briar.api.privategroup.PrivateGroupManager.CLIENT_ID;
|
import static org.briarproject.briar.api.privategroup.PrivateGroupManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.privategroup.PrivateGroupManager.CLIENT_VERSION;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -64,7 +65,8 @@ class PrivateGroupFactoryImpl implements PrivateGroupFactory {
|
|||||||
salt
|
salt
|
||||||
);
|
);
|
||||||
byte[] descriptor = clientHelper.toByteArray(group);
|
byte[] descriptor = clientHelper.toByteArray(group);
|
||||||
Group g = groupFactory.createGroup(CLIENT_ID, descriptor);
|
Group g = groupFactory.createGroup(CLIENT_ID, CLIENT_VERSION,
|
||||||
|
descriptor);
|
||||||
return new PrivateGroup(g, name, author, salt);
|
return new PrivateGroup(g, name, author, salt);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager.CLIENT_ID;
|
import static org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager.CLIENT_VERSION;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -52,7 +53,7 @@ class GroupInvitationFactoryImpl implements GroupInvitationFactory {
|
|||||||
public BdfList createInviteToken(AuthorId creatorId, AuthorId memberId,
|
public BdfList createInviteToken(AuthorId creatorId, AuthorId memberId,
|
||||||
GroupId privateGroupId, long timestamp) {
|
GroupId privateGroupId, long timestamp) {
|
||||||
Group contactGroup = contactGroupFactory.createContactGroup(CLIENT_ID,
|
Group contactGroup = contactGroupFactory.createContactGroup(CLIENT_ID,
|
||||||
creatorId, memberId);
|
CLIENT_VERSION, creatorId, memberId);
|
||||||
return BdfList.of(
|
return BdfList.of(
|
||||||
timestamp,
|
timestamp,
|
||||||
contactGroup.getId(),
|
contactGroup.getId(),
|
||||||
|
|||||||
@@ -132,7 +132,8 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group getContactGroup(Contact c) {
|
public Group getContactGroup(Contact c) {
|
||||||
return contactGroupFactory.createContactGroup(CLIENT_ID, c);
|
return contactGroupFactory.createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ class BlogSharingManagerImpl extends SharingManagerImpl<Blog>
|
|||||||
return CLIENT_ID;
|
return CLIENT_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getClientVersion() {
|
||||||
|
return CLIENT_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called during each startup for each existing Contact.
|
* This is called during each startup for each existing Contact.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ class ForumSharingManagerImpl extends SharingManagerImpl<Forum>
|
|||||||
return CLIENT_ID;
|
return CLIENT_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getClientVersion() {
|
||||||
|
return CLIENT_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removingForum(Transaction txn, Forum f) throws DbException {
|
public void removingForum(Transaction txn, Forum f) throws DbException {
|
||||||
removingShareable(txn, f);
|
removingShareable(txn, f);
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ abstract class SharingManagerImpl<S extends Shareable>
|
|||||||
|
|
||||||
protected abstract ClientId getClientId();
|
protected abstract ClientId getClientId();
|
||||||
|
|
||||||
|
protected abstract int getClientVersion();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createLocalState(Transaction txn) throws DbException {
|
public void createLocalState(Transaction txn) throws DbException {
|
||||||
// Ensure we've set things up for any pre-existing contacts
|
// Ensure we've set things up for any pre-existing contacts
|
||||||
@@ -113,7 +115,8 @@ abstract class SharingManagerImpl<S extends Shareable>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group getContactGroup(Contact c) {
|
public Group getContactGroup(Contact c) {
|
||||||
return contactGroupFactory.createContactGroup(getClientId(), c);
|
return contactGroupFactory.createContactGroup(getClientId(),
|
||||||
|
getClientVersion(), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import org.briarproject.bramble.api.data.BdfList;
|
|||||||
import org.briarproject.bramble.api.data.MetadataEncoder;
|
import org.briarproject.bramble.api.data.MetadataEncoder;
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
import org.briarproject.bramble.api.identity.AuthorId;
|
import org.briarproject.bramble.api.identity.AuthorId;
|
||||||
import org.briarproject.bramble.api.sync.ClientId;
|
|
||||||
import org.briarproject.bramble.api.sync.Group;
|
import org.briarproject.bramble.api.sync.Group;
|
||||||
import org.briarproject.bramble.api.sync.GroupFactory;
|
import org.briarproject.bramble.api.sync.GroupFactory;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
@@ -40,6 +39,8 @@ import static org.briarproject.briar.api.blog.BlogConstants.KEY_PARENT_MSG_ID;
|
|||||||
import static org.briarproject.briar.api.blog.BlogConstants.KEY_PUBLIC_KEY;
|
import static org.briarproject.briar.api.blog.BlogConstants.KEY_PUBLIC_KEY;
|
||||||
import static org.briarproject.briar.api.blog.BlogConstants.KEY_READ;
|
import static org.briarproject.briar.api.blog.BlogConstants.KEY_READ;
|
||||||
import static org.briarproject.briar.api.blog.BlogConstants.KEY_RSS_FEED;
|
import static org.briarproject.briar.api.blog.BlogConstants.KEY_RSS_FEED;
|
||||||
|
import static org.briarproject.briar.api.blog.BlogManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.blog.BlogManager.CLIENT_VERSION;
|
||||||
import static org.briarproject.briar.api.blog.BlogPostFactory.SIGNING_LABEL_COMMENT;
|
import static org.briarproject.briar.api.blog.BlogPostFactory.SIGNING_LABEL_COMMENT;
|
||||||
import static org.briarproject.briar.api.blog.BlogPostFactory.SIGNING_LABEL_POST;
|
import static org.briarproject.briar.api.blog.BlogPostFactory.SIGNING_LABEL_POST;
|
||||||
import static org.briarproject.briar.api.blog.MessageType.COMMENT;
|
import static org.briarproject.briar.api.blog.MessageType.COMMENT;
|
||||||
@@ -54,7 +55,6 @@ public class BlogPostValidatorTest extends BriarTestCase {
|
|||||||
private final Mockery context = new Mockery();
|
private final Mockery context = new Mockery();
|
||||||
private final Blog blog, rssBlog;
|
private final Blog blog, rssBlog;
|
||||||
private final BdfDictionary authorDict;
|
private final BdfDictionary authorDict;
|
||||||
private final ClientId clientId;
|
|
||||||
private final byte[] descriptor;
|
private final byte[] descriptor;
|
||||||
private final Group group;
|
private final Group group;
|
||||||
private final Message message;
|
private final Message message;
|
||||||
@@ -69,9 +69,8 @@ public class BlogPostValidatorTest extends BriarTestCase {
|
|||||||
|
|
||||||
public BlogPostValidatorTest() {
|
public BlogPostValidatorTest() {
|
||||||
GroupId groupId = new GroupId(TestUtils.getRandomId());
|
GroupId groupId = new GroupId(TestUtils.getRandomId());
|
||||||
clientId = BlogManagerImpl.CLIENT_ID;
|
|
||||||
descriptor = TestUtils.getRandomBytes(42);
|
descriptor = TestUtils.getRandomBytes(42);
|
||||||
group = new Group(groupId, clientId, descriptor);
|
group = new Group(groupId, CLIENT_ID, descriptor);
|
||||||
AuthorId authorId =
|
AuthorId authorId =
|
||||||
new AuthorId(TestUtils.getRandomBytes(AuthorId.LENGTH));
|
new AuthorId(TestUtils.getRandomBytes(AuthorId.LENGTH));
|
||||||
byte[] publicKey = TestUtils.getRandomBytes(MAX_PUBLIC_KEY_LENGTH);
|
byte[] publicKey = TestUtils.getRandomBytes(MAX_PUBLIC_KEY_LENGTH);
|
||||||
@@ -215,7 +214,8 @@ public class BlogPostValidatorTest extends BriarTestCase {
|
|||||||
byte[] originalBody = TestUtils.getRandomBytes(42);
|
byte[] originalBody = TestUtils.getRandomBytes(42);
|
||||||
|
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(groupFactory).createGroup(clientId, descriptor);
|
oneOf(groupFactory).createGroup(CLIENT_ID, CLIENT_VERSION,
|
||||||
|
descriptor);
|
||||||
will(returnValue(b.getGroup()));
|
will(returnValue(b.getGroup()));
|
||||||
oneOf(blogFactory).parseBlog(b.getGroup());
|
oneOf(blogFactory).parseBlog(b.getGroup());
|
||||||
will(returnValue(b));
|
will(returnValue(b));
|
||||||
@@ -258,7 +258,8 @@ public class BlogPostValidatorTest extends BriarTestCase {
|
|||||||
byte[] originalBody = TestUtils.getRandomBytes(42);
|
byte[] originalBody = TestUtils.getRandomBytes(42);
|
||||||
|
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(groupFactory).createGroup(clientId, descriptor);
|
oneOf(groupFactory).createGroup(CLIENT_ID, CLIENT_VERSION,
|
||||||
|
descriptor);
|
||||||
will(returnValue(blog.getGroup()));
|
will(returnValue(blog.getGroup()));
|
||||||
oneOf(clientHelper).toByteArray(originalList);
|
oneOf(clientHelper).toByteArray(originalList);
|
||||||
will(returnValue(originalBody));
|
will(returnValue(originalBody));
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
|||||||
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
||||||
import static org.briarproject.briar.api.feed.FeedConstants.KEY_FEEDS;
|
import static org.briarproject.briar.api.feed.FeedConstants.KEY_FEEDS;
|
||||||
import static org.briarproject.briar.api.feed.FeedManager.CLIENT_ID;
|
import static org.briarproject.briar.api.feed.FeedManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.feed.FeedManager.CLIENT_VERSION;
|
||||||
|
|
||||||
public class FeedManagerImplTest extends BrambleMockTestCase {
|
public class FeedManagerImplTest extends BrambleMockTestCase {
|
||||||
|
|
||||||
@@ -133,7 +134,8 @@ public class FeedManagerImplTest extends BrambleMockTestCase {
|
|||||||
|
|
||||||
private void expectGetLocalGroup() {
|
private void expectGetLocalGroup() {
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(contactGroupFactory).createLocalGroup(CLIENT_ID);
|
oneOf(contactGroupFactory).createLocalGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION);
|
||||||
will(returnValue(localGroup));
|
will(returnValue(localGroup));
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ import static org.briarproject.briar.api.introduction.IntroductionConstants.MAC_
|
|||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAC_LABEL;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAC_LABEL;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.NAME;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.NAME;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.NONCE;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.NONCE;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.PROTOCOL_VERSION;
|
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.PUBLIC_KEY;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.PUBLIC_KEY;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.SESSION_ID;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.SESSION_ID;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.SHARED_SECRET_LABEL;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.SHARED_SECRET_LABEL;
|
||||||
@@ -76,6 +75,7 @@ import static org.briarproject.briar.api.introduction.IntroductionConstants.TRAN
|
|||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_REQUEST;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_REQUEST;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_RESPONSE;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_RESPONSE;
|
||||||
|
import static org.briarproject.briar.api.introduction.IntroductionManager.CLIENT_VERSION;
|
||||||
import static org.briarproject.briar.test.BriarTestUtils.assertGroupCount;
|
import static org.briarproject.briar.test.BriarTestUtils.assertGroupCount;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@@ -755,7 +755,7 @@ public class IntroductionIntegrationTest
|
|||||||
|
|
||||||
// Nonce 1
|
// Nonce 1
|
||||||
byte[][] inputs = {
|
byte[][] inputs = {
|
||||||
new byte[] {PROTOCOL_VERSION},
|
new byte[] {CLIENT_VERSION},
|
||||||
eKeyPair1.getPublic().getEncoded(),
|
eKeyPair1.getPublic().getEncoded(),
|
||||||
eKeyPair2.getPublic().getEncoded()
|
eKeyPair2.getPublic().getEncoded()
|
||||||
};
|
};
|
||||||
@@ -794,7 +794,7 @@ public class IntroductionIntegrationTest
|
|||||||
// replace ephemeral key pair and recalculate matching keys and nonce
|
// replace ephemeral key pair and recalculate matching keys and nonce
|
||||||
KeyPair eKeyPair1f = crypto.generateAgreementKeyPair();
|
KeyPair eKeyPair1f = crypto.generateAgreementKeyPair();
|
||||||
byte[][] fakeInputs = {
|
byte[][] fakeInputs = {
|
||||||
new byte[] {PROTOCOL_VERSION},
|
new byte[] {CLIENT_VERSION},
|
||||||
eKeyPair1f.getPublic().getEncoded(),
|
eKeyPair1f.getPublic().getEncoded(),
|
||||||
eKeyPair2.getPublic().getEncoded()
|
eKeyPair2.getPublic().getEncoded()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
|||||||
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.GROUP_SALT_LENGTH;
|
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.GROUP_SALT_LENGTH;
|
||||||
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_NAME_LENGTH;
|
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_NAME_LENGTH;
|
||||||
import static org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager.CLIENT_ID;
|
import static org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager.CLIENT_VERSION;
|
||||||
import static org.briarproject.briar.privategroup.invitation.GroupInvitationConstants.GROUP_KEY_CONTACT_ID;
|
import static org.briarproject.briar.privategroup.invitation.GroupInvitationConstants.GROUP_KEY_CONTACT_ID;
|
||||||
import static org.briarproject.briar.privategroup.invitation.MessageType.ABORT;
|
import static org.briarproject.briar.privategroup.invitation.MessageType.ABORT;
|
||||||
import static org.briarproject.briar.privategroup.invitation.MessageType.INVITE;
|
import static org.briarproject.briar.privategroup.invitation.MessageType.INVITE;
|
||||||
@@ -162,7 +163,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
private void expectAddingContact(Contact c, boolean contactExists)
|
private void expectAddingContact(Contact c, boolean contactExists)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, c);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, c);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(db).containsGroup(txn, contactGroup.getId());
|
oneOf(db).containsGroup(txn, contactGroup.getId());
|
||||||
will(returnValue(contactExists));
|
will(returnValue(contactExists));
|
||||||
@@ -188,7 +190,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
|
|
||||||
private void expectAddingMember(GroupId g, Contact c) throws Exception {
|
private void expectAddingMember(GroupId g, Contact c) throws Exception {
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, c);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, c);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
}});
|
}});
|
||||||
expectGetSession(noResults, new SessionId(g.getBytes()),
|
expectGetSession(noResults, new SessionId(g.getBytes()),
|
||||||
@@ -243,7 +246,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testRemovingContact() throws Exception {
|
public void testRemovingContact() throws Exception {
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(db).removeGroup(txn, contactGroup);
|
oneOf(db).removeGroup(txn, contactGroup);
|
||||||
}});
|
}});
|
||||||
@@ -457,7 +461,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getContact(txn, contactId);
|
oneOf(db).getContact(txn, contactId);
|
||||||
will(returnValue(contact));
|
will(returnValue(contact));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
}});
|
}});
|
||||||
expectCreateStorageId();
|
expectCreateStorageId();
|
||||||
@@ -488,7 +493,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getContact(txn, contactId);
|
oneOf(db).getContact(txn, contactId);
|
||||||
will(returnValue(contact));
|
will(returnValue(contact));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(sessionParser)
|
oneOf(sessionParser)
|
||||||
.parseCreatorSession(contactGroup.getId(), bdfSession);
|
.parseCreatorSession(contactGroup.getId(), bdfSession);
|
||||||
@@ -516,7 +522,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getContact(txn, contactId);
|
oneOf(db).getContact(txn, contactId);
|
||||||
will(returnValue(contact));
|
will(returnValue(contact));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
@@ -567,7 +574,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getContact(txn, contactId);
|
oneOf(db).getContact(txn, contactId);
|
||||||
will(returnValue(contact));
|
will(returnValue(contact));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(sessionParser)
|
oneOf(sessionParser)
|
||||||
.parseInviteeSession(contactGroup.getId(), bdfSession);
|
.parseInviteeSession(contactGroup.getId(), bdfSession);
|
||||||
@@ -588,7 +596,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getContact(txn, contactId);
|
oneOf(db).getContact(txn, contactId);
|
||||||
will(returnValue(contact));
|
will(returnValue(contact));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(sessionParser)
|
oneOf(sessionParser)
|
||||||
.parsePeerSession(contactGroup.getId(), bdfSession);
|
.parsePeerSession(contactGroup.getId(), bdfSession);
|
||||||
@@ -612,7 +621,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getContact(txn, contactId);
|
oneOf(db).getContact(txn, contactId);
|
||||||
will(returnValue(contact));
|
will(returnValue(contact));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
@@ -650,7 +660,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getContact(txn, contactId);
|
oneOf(db).getContact(txn, contactId);
|
||||||
will(returnValue(contact));
|
will(returnValue(contact));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(messageParser).getMessagesVisibleInUiQuery();
|
oneOf(messageParser).getMessagesVisibleInUiQuery();
|
||||||
will(returnValue(query));
|
will(returnValue(query));
|
||||||
@@ -726,7 +737,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getContacts(txn);
|
oneOf(db).getContacts(txn);
|
||||||
will(returnValue(Collections.singletonList(contact)));
|
will(returnValue(Collections.singletonList(contact)));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
|
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
|
||||||
contactGroup.getId(), query);
|
contactGroup.getId(), query);
|
||||||
@@ -793,7 +805,8 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
expectGetSession(oneResult, sessionId, contactGroup.getId());
|
expectGetSession(oneResult, sessionId, contactGroup.getId());
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
@@ -847,11 +860,14 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(db).getContacts(txn);
|
oneOf(db).getContacts(txn);
|
||||||
will(returnValue(contacts));
|
will(returnValue(contacts));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact2);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact2);
|
||||||
will(returnValue(contactGroup2));
|
will(returnValue(contactGroup2));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact3);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact3);
|
||||||
will(returnValue(contactGroup3));
|
will(returnValue(contactGroup3));
|
||||||
// session 1
|
// session 1
|
||||||
oneOf(sessionParser).getRole(bdfSession);
|
oneOf(sessionParser).getRole(bdfSession);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.briarproject.briar.api.blog.BlogSharingManager.CLIENT_ID;
|
import static org.briarproject.briar.api.blog.BlogSharingManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.blog.BlogSharingManager.CLIENT_VERSION;
|
||||||
import static org.briarproject.briar.test.BriarTestUtils.assertGroupCount;
|
import static org.briarproject.briar.test.BriarTestUtils.assertGroupCount;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@@ -125,7 +126,7 @@ public class BlogSharingIntegrationTest
|
|||||||
|
|
||||||
// get sharing group and assert group message count
|
// get sharing group and assert group message count
|
||||||
GroupId g = contactGroupFactory.createContactGroup(CLIENT_ID,
|
GroupId g = contactGroupFactory.createContactGroup(CLIENT_ID,
|
||||||
contact1From0).getId();
|
CLIENT_VERSION, contact1From0).getId();
|
||||||
assertGroupCount(messageTracker0, g, 1, 0);
|
assertGroupCount(messageTracker0, g, 1, 0);
|
||||||
|
|
||||||
// sync first request message
|
// sync first request message
|
||||||
@@ -200,7 +201,7 @@ public class BlogSharingIntegrationTest
|
|||||||
|
|
||||||
// get sharing group and assert group message count
|
// get sharing group and assert group message count
|
||||||
GroupId g = contactGroupFactory.createContactGroup(CLIENT_ID,
|
GroupId g = contactGroupFactory.createContactGroup(CLIENT_ID,
|
||||||
contact1From0).getId();
|
CLIENT_VERSION, contact1From0).getId();
|
||||||
assertGroupCount(messageTracker0, g, 1, 0);
|
assertGroupCount(messageTracker0, g, 1, 0);
|
||||||
|
|
||||||
// sync first request message
|
// sync first request message
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;
|
|||||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||||
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
||||||
import static org.briarproject.briar.api.blog.BlogSharingManager.CLIENT_ID;
|
import static org.briarproject.briar.api.blog.BlogSharingManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.blog.BlogSharingManager.CLIENT_VERSION;
|
||||||
import static org.briarproject.briar.sharing.SharingConstants.GROUP_KEY_CONTACT_ID;
|
import static org.briarproject.briar.sharing.SharingConstants.GROUP_KEY_CONTACT_ID;
|
||||||
|
|
||||||
public class BlogSharingManagerImplTest extends BrambleMockTestCase {
|
public class BlogSharingManagerImplTest extends BrambleMockTestCase {
|
||||||
@@ -152,7 +153,8 @@ public class BlogSharingManagerImplTest extends BrambleMockTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(db).getContacts(txn);
|
oneOf(db).getContacts(txn);
|
||||||
will(returnValue(contacts));
|
will(returnValue(contacts));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(db).containsGroup(txn, contactGroup.getId());
|
oneOf(db).containsGroup(txn, contactGroup.getId());
|
||||||
will(returnValue(false));
|
will(returnValue(false));
|
||||||
@@ -185,8 +187,8 @@ public class BlogSharingManagerImplTest extends BrambleMockTestCase {
|
|||||||
new Message(new MessageId(getRandomId()), contactGroup.getId(),
|
new Message(new MessageId(getRandomId()), contactGroup.getId(),
|
||||||
42L, getRandomBytes(1337));
|
42L, getRandomBytes(1337));
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(contactGroupFactory)
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
.createContactGroup(CLIENT_ID, contact);
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(sessionParser)
|
oneOf(sessionParser)
|
||||||
.getSessionQuery(new SessionId(blog.getId().getBytes()));
|
.getSessionQuery(new SessionId(blog.getId().getBytes()));
|
||||||
@@ -220,7 +222,8 @@ public class BlogSharingManagerImplTest extends BrambleMockTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(db).getContacts(txn);
|
oneOf(db).getContacts(txn);
|
||||||
will(returnValue(contacts));
|
will(returnValue(contacts));
|
||||||
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, contact);
|
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
|
||||||
|
CLIENT_VERSION, contact);
|
||||||
will(returnValue(contactGroup));
|
will(returnValue(contactGroup));
|
||||||
oneOf(sessionParser)
|
oneOf(sessionParser)
|
||||||
.getSessionQuery(new SessionId(blog.getId().getBytes()));
|
.getSessionQuery(new SessionId(blog.getId().getBytes()));
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import static junit.framework.Assert.assertNotNull;
|
import static junit.framework.Assert.assertNotNull;
|
||||||
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||||
|
import static org.briarproject.briar.api.forum.ForumSharingManager.CLIENT_ID;
|
||||||
|
import static org.briarproject.briar.api.forum.ForumSharingManager.CLIENT_VERSION;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -399,9 +401,8 @@ public class ForumSharingIntegrationTest
|
|||||||
assertTrue(listener0.responseReceived);
|
assertTrue(listener0.responseReceived);
|
||||||
|
|
||||||
// response and invitation got tracked
|
// response and invitation got tracked
|
||||||
Group group = contactGroupFactory
|
Group group = contactGroupFactory.createContactGroup(CLIENT_ID,
|
||||||
.createContactGroup(ForumSharingManager.CLIENT_ID,
|
CLIENT_VERSION, contact0From1);
|
||||||
contact0From1);
|
|
||||||
assertEquals(2, c1.getMessageTracker().getGroupCount(group.getId())
|
assertEquals(2, c1.getMessageTracker().getGroupCount(group.getId())
|
||||||
.getMsgCount());
|
.getMsgCount());
|
||||||
|
|
||||||
@@ -432,9 +433,8 @@ public class ForumSharingIntegrationTest
|
|||||||
assertEquals(1, forumSharingManager1.getInvitations().size());
|
assertEquals(1, forumSharingManager1.getInvitations().size());
|
||||||
|
|
||||||
// assert that the invitation arrived
|
// assert that the invitation arrived
|
||||||
Group group = contactGroupFactory
|
Group group = contactGroupFactory.createContactGroup(CLIENT_ID,
|
||||||
.createContactGroup(ForumSharingManager.CLIENT_ID,
|
CLIENT_VERSION, contact0From1);
|
||||||
contact0From1);
|
|
||||||
assertEquals(1, c1.getMessageTracker().getGroupCount(group.getId())
|
assertEquals(1, c1.getMessageTracker().getGroupCount(group.getId())
|
||||||
.getMsgCount());
|
.getMsgCount());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user