mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Removed public/private groups from the wire protocol.
The distinction between inbox groups and other groups can be maintained internally, there's no need to represent it on the wire.
This commit is contained in:
@@ -95,7 +95,7 @@ public class ProtocolIntegrationTest extends BriarTestCase {
|
||||
new Random().nextBytes(secret);
|
||||
// Create a group
|
||||
GroupFactory groupFactory = i.getInstance(GroupFactory.class);
|
||||
group = groupFactory.createGroup("Group", false);
|
||||
group = groupFactory.createGroup("Group");
|
||||
// Create an author
|
||||
AuthorFactory authorFactory = i.getInstance(AuthorFactory.class);
|
||||
CryptoComponent crypto = i.getInstance(CryptoComponent.class);
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
|
||||
public DatabaseComponentTest() {
|
||||
groupId = new GroupId(TestUtils.getRandomId());
|
||||
group = new Group(groupId, "Group", new byte[GROUP_SALT_LENGTH], false);
|
||||
group = new Group(groupId, "Group", new byte[GROUP_SALT_LENGTH]);
|
||||
authorId = new AuthorId(TestUtils.getRandomId());
|
||||
author = new Author(authorId, "Alice", new byte[MAX_PUBLIC_KEY_LENGTH]);
|
||||
localAuthorId = new AuthorId(TestUtils.getRandomId());
|
||||
@@ -465,9 +465,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
} catch(NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
Group privateGroup = new Group(groupId, "Group",
|
||||
new byte[GROUP_SALT_LENGTH], true);
|
||||
db.setInboxGroup(contactId, privateGroup);
|
||||
db.setInboxGroup(contactId, group);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
|
||||
@@ -559,7 +557,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
} catch(NoSuchSubscriptionException expected) {}
|
||||
|
||||
try {
|
||||
db.setVisibility(group, Collections.<ContactId>emptyList());
|
||||
db.setVisibility(groupId, Collections.<ContactId>emptyList());
|
||||
fail();
|
||||
} catch(NoSuchSubscriptionException expected) {}
|
||||
|
||||
@@ -1339,8 +1337,8 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
will(returnValue(both));
|
||||
oneOf(database).getContactIds(txn);
|
||||
will(returnValue(both));
|
||||
oneOf(database).removeVisibility(txn, contactId1, group);
|
||||
oneOf(database).setVisibleToAll(txn, group, false);
|
||||
oneOf(database).removeVisibility(txn, contactId1, groupId);
|
||||
oneOf(database).setVisibleToAll(txn, groupId, false);
|
||||
oneOf(database).commitTransaction(txn);
|
||||
oneOf(listener).eventOccurred(with(any(
|
||||
LocalSubscriptionsUpdatedEvent.class)));
|
||||
@@ -1349,7 +1347,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
shutdown);
|
||||
|
||||
db.addListener(listener);
|
||||
db.setVisibility(group, Arrays.asList(contactId));
|
||||
db.setVisibility(groupId, Arrays.asList(contactId));
|
||||
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
@@ -1374,14 +1372,14 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
will(returnValue(both));
|
||||
oneOf(database).getContactIds(txn);
|
||||
will(returnValue(both));
|
||||
oneOf(database).setVisibleToAll(txn, group, false);
|
||||
oneOf(database).setVisibleToAll(txn, groupId, false);
|
||||
oneOf(database).commitTransaction(txn);
|
||||
}});
|
||||
DatabaseComponent db = createDatabaseComponent(database, cleaner,
|
||||
shutdown);
|
||||
|
||||
db.addListener(listener);
|
||||
db.setVisibility(group, both);
|
||||
db.setVisibility(groupId, both);
|
||||
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
@@ -1407,8 +1405,8 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
will(returnValue(Collections.emptyList()));
|
||||
oneOf(database).getContactIds(txn);
|
||||
will(returnValue(both));
|
||||
oneOf(database).addVisibility(txn, contactId, group);
|
||||
oneOf(database).setVisibleToAll(txn, group, false);
|
||||
oneOf(database).addVisibility(txn, contactId, groupId);
|
||||
oneOf(database).setVisibleToAll(txn, groupId, false);
|
||||
oneOf(database).commitTransaction(txn);
|
||||
oneOf(listener).eventOccurred(with(any(
|
||||
LocalSubscriptionsUpdatedEvent.class)));
|
||||
@@ -1417,12 +1415,12 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
will(returnValue(txn));
|
||||
oneOf(database).containsGroup(txn, groupId);
|
||||
will(returnValue(true));
|
||||
oneOf(database).setVisibleToAll(txn, group, true);
|
||||
oneOf(database).setVisibleToAll(txn, groupId, true);
|
||||
oneOf(database).getVisibility(txn, groupId);
|
||||
will(returnValue(Arrays.asList(contactId)));
|
||||
oneOf(database).getContactIds(txn);
|
||||
will(returnValue(both));
|
||||
oneOf(database).addVisibility(txn, contactId1, group);
|
||||
oneOf(database).addVisibility(txn, contactId1, groupId);
|
||||
oneOf(database).commitTransaction(txn);
|
||||
oneOf(listener).eventOccurred(with(any(
|
||||
LocalSubscriptionsUpdatedEvent.class)));
|
||||
@@ -1431,8 +1429,8 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
shutdown);
|
||||
|
||||
db.addListener(listener);
|
||||
db.setVisibility(group, Arrays.asList(contactId));
|
||||
db.setVisibleToAll(group, true);
|
||||
db.setVisibility(groupId, Arrays.asList(contactId));
|
||||
db.setVisibleToAll(groupId, true);
|
||||
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
|
||||
public H2DatabaseTest() throws Exception {
|
||||
groupId = new GroupId(TestUtils.getRandomId());
|
||||
group = new Group(groupId, "Group", new byte[GROUP_SALT_LENGTH], false);
|
||||
group = new Group(groupId, "Group", new byte[GROUP_SALT_LENGTH]);
|
||||
authorId = new AuthorId(TestUtils.getRandomId());
|
||||
author = new Author(authorId, "Alice", new byte[MAX_PUBLIC_KEY_LENGTH]);
|
||||
localAuthorId = new AuthorId(TestUtils.getRandomId());
|
||||
@@ -166,7 +166,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.setGroups(txn, contactId, Arrays.asList(group), 1);
|
||||
db.addMessage(txn, message, false);
|
||||
|
||||
@@ -203,7 +203,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.addMessage(txn, message, false);
|
||||
db.addStatus(txn, contactId, messageId, false);
|
||||
|
||||
@@ -240,7 +240,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.setGroups(txn, contactId, Arrays.asList(group), 1);
|
||||
db.addMessage(txn, message, false);
|
||||
db.addStatus(txn, contactId, messageId, false);
|
||||
@@ -283,7 +283,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
assertFalse(it.hasNext());
|
||||
|
||||
// Making the subscription visible should make the message sendable
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
assertTrue(db.containsSendableMessages(txn, contactId));
|
||||
it = db.getSendableMessages(txn, contactId, ONE_MEGABYTE).iterator();
|
||||
assertTrue(it.hasNext());
|
||||
@@ -356,7 +356,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.setGroups(txn, contactId, Arrays.asList(group), 1);
|
||||
db.addMessage(txn, message, false);
|
||||
db.addStatus(txn, contactId, messageId, false);
|
||||
@@ -654,7 +654,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.setGroups(txn, contactId, Arrays.asList(group), 1);
|
||||
|
||||
// The message is not in the database
|
||||
@@ -673,7 +673,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.setGroups(txn, contactId, Arrays.asList(group), 1);
|
||||
db.addMessage(txn, message, false);
|
||||
|
||||
@@ -697,7 +697,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.setGroups(txn, contactId, Arrays.asList(group), 1);
|
||||
db.setRetentionTime(txn, contactId, timestamp + 1, 1);
|
||||
db.addMessage(txn, message, false);
|
||||
@@ -721,7 +721,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.setGroups(txn, contactId, Arrays.asList(group), 1);
|
||||
db.addMessage(txn, message, false);
|
||||
|
||||
@@ -746,7 +746,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.setGroups(txn, contactId, Arrays.asList(group), 1);
|
||||
|
||||
// The message is not in the database
|
||||
@@ -784,7 +784,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.addMessage(txn, message, false);
|
||||
db.addStatus(txn, contactId, messageId, false);
|
||||
|
||||
@@ -826,7 +826,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.setGroups(txn, contactId, Arrays.asList(group), 1);
|
||||
db.addMessage(txn, message, false);
|
||||
|
||||
@@ -849,7 +849,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
db.addGroup(txn, group);
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
db.setGroups(txn, contactId, Arrays.asList(group), 1);
|
||||
db.addMessage(txn, message, false);
|
||||
|
||||
@@ -876,11 +876,11 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
assertEquals(Collections.emptyList(), db.getVisibility(txn, groupId));
|
||||
|
||||
// Make the group visible to the contact
|
||||
db.addVisibility(txn, contactId, group);
|
||||
db.addVisibility(txn, contactId, groupId);
|
||||
assertEquals(Arrays.asList(contactId), db.getVisibility(txn, groupId));
|
||||
|
||||
// Make the group invisible again
|
||||
db.removeVisibility(txn, contactId, group);
|
||||
db.removeVisibility(txn, contactId, groupId);
|
||||
assertEquals(Collections.emptyList(), db.getVisibility(txn, groupId));
|
||||
|
||||
db.commitTransaction(txn);
|
||||
@@ -934,7 +934,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
throws Exception {
|
||||
GroupId groupId1 = new GroupId(TestUtils.getRandomId());
|
||||
Group group1 = new Group(groupId1, "Another group",
|
||||
new byte[GROUP_SALT_LENGTH], false);
|
||||
new byte[GROUP_SALT_LENGTH]);
|
||||
Database<Connection> db = open(false);
|
||||
Connection txn = db.startTransaction();
|
||||
|
||||
@@ -1134,7 +1134,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
db.addGroup(txn, group);
|
||||
GroupId groupId1 = new GroupId(TestUtils.getRandomId());
|
||||
Group group1 = new Group(groupId1, "Another group",
|
||||
new byte[GROUP_SALT_LENGTH], false);
|
||||
new byte[GROUP_SALT_LENGTH]);
|
||||
db.addGroup(txn, group1);
|
||||
|
||||
// Store two messages in the first group
|
||||
@@ -1188,7 +1188,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
for(int i = 0; i < 100; i++) {
|
||||
GroupId id = new GroupId(TestUtils.getRandomId());
|
||||
String name = "Group " + i;
|
||||
groups.add(new Group(id, name, new byte[GROUP_SALT_LENGTH], false));
|
||||
groups.add(new Group(id, name, new byte[GROUP_SALT_LENGTH]));
|
||||
}
|
||||
|
||||
Database<Connection> db = open(false);
|
||||
@@ -1201,12 +1201,13 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
|
||||
// Make the groups visible to the contact
|
||||
Collections.shuffle(groups);
|
||||
for(Group g : groups) db.addVisibility(txn, contactId, g);
|
||||
for(Group g : groups) db.addVisibility(txn, contactId, g.getId());
|
||||
|
||||
// Make some of the groups invisible to the contact and remove them all
|
||||
Collections.shuffle(groups);
|
||||
for(Group g : groups) {
|
||||
if(Math.random() < 0.5) db.removeVisibility(txn, contactId, g);
|
||||
if(Math.random() < 0.5)
|
||||
db.removeVisibility(txn, contactId, g.getId());
|
||||
db.removeGroup(txn, g.getId());
|
||||
}
|
||||
|
||||
@@ -1571,7 +1572,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
|
||||
// Make the group visible to all contacts - it should be available,
|
||||
// subscribed, visible to all
|
||||
db.setVisibleToAll(txn, group, true);
|
||||
db.setVisibleToAll(txn, groupId, true);
|
||||
assertEquals(Arrays.asList(group), db.getGroups(txn));
|
||||
it = db.getAvailableGroups(txn).iterator();
|
||||
assertTrue(it.hasNext());
|
||||
@@ -1636,10 +1637,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
// Add a contact and an inbox group - no headers should be returned
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
Group inbox = new Group(groupId, "Group", new byte[GROUP_SALT_LENGTH],
|
||||
true);
|
||||
db.addGroup(txn, inbox);
|
||||
db.setInboxGroup(txn, contactId, inbox);
|
||||
db.addGroup(txn, group);
|
||||
db.setInboxGroup(txn, contactId, group);
|
||||
assertEquals(Collections.emptyList(),
|
||||
db.getInboxMessageHeaders(txn, contactId));
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public class ConstantsTest extends BriarTestCase {
|
||||
MessageId parent = new MessageId(TestUtils.getRandomId());
|
||||
// Create a maximum-length group
|
||||
String groupName = TestUtils.createRandomString(MAX_GROUP_NAME_LENGTH);
|
||||
Group group = groupFactory.createGroup(groupName, false);
|
||||
Group group = groupFactory.createGroup(groupName);
|
||||
// Create a maximum-length author
|
||||
String authorName =
|
||||
TestUtils.createRandomString(MAX_AUTHOR_NAME_LENGTH);
|
||||
@@ -180,7 +180,7 @@ public class ConstantsTest extends BriarTestCase {
|
||||
Collection<Group> groups = new ArrayList<Group>();
|
||||
for(int i = 0; i < MAX_SUBSCRIPTIONS; i++) {
|
||||
String name = TestUtils.createRandomString(MAX_GROUP_NAME_LENGTH);
|
||||
groups.add(groupFactory.createGroup(name, false));
|
||||
groups.add(groupFactory.createGroup(name));
|
||||
}
|
||||
// Create a maximum-length subscription update
|
||||
SubscriptionUpdate u = new SubscriptionUpdate(groups, Long.MAX_VALUE);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
|
||||
public SimplexMessagingIntegrationTest() throws Exception {
|
||||
GroupId groupId = new GroupId(TestUtils.getRandomId());
|
||||
group = new Group(groupId, "Group", new byte[GROUP_SALT_LENGTH], true);
|
||||
group = new Group(groupId, "Group", new byte[GROUP_SALT_LENGTH]);
|
||||
transportId = new TransportId(TestUtils.getRandomId());
|
||||
// Create matching secrets for Alice and Bob
|
||||
initialSecret = new byte[32];
|
||||
|
||||
Reference in New Issue
Block a user