mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Look up auto-delete timer when creating private group invitation.
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.Collection;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
||||
import static org.briarproject.briar.api.identity.AuthorInfo.Status.OURSELVES;
|
||||
import static org.briarproject.briar.api.privategroup.Visibility.INVISIBLE;
|
||||
import static org.briarproject.briar.api.privategroup.Visibility.REVEALED_BY_CONTACT;
|
||||
@@ -220,8 +221,8 @@ public class PrivateGroupIntegrationTest
|
||||
byte[] signature = groupInvitationFactory
|
||||
.signInvitation(contact, groupId0, timestamp,
|
||||
author0.getPrivateKey());
|
||||
groupInvitationManager0
|
||||
.sendInvitation(groupId0, c, text, timestamp, signature);
|
||||
groupInvitationManager0.sendInvitation(groupId0, c, text, timestamp,
|
||||
signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
private GroupMember getGroupMember(PrivateGroupManager groupManager,
|
||||
|
||||
@@ -129,8 +129,8 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
|
||||
}
|
||||
|
||||
void expectSendInviteMessage(String text) throws Exception {
|
||||
expectCheckWhetherContactSupportsAutoDeletion(true);
|
||||
expectGetLocalTimestamp(messageTimestamp);
|
||||
expectCheckWhetherContactSupportsAutoDeletion();
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(messageEncoder).encodeInviteMessage(contactGroupId,
|
||||
privateGroupId, inviteTimestamp, privateGroup.getName(),
|
||||
@@ -143,8 +143,9 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
|
||||
|
||||
void expectSendJoinMessage(JoinMessage m, boolean visible)
|
||||
throws Exception {
|
||||
expectCheckWhetherContactSupportsAutoDeletion(visible);
|
||||
expectGetLocalTimestamp(messageTimestamp);
|
||||
expectCheckWhetherContactSupportsAutoDeletion();
|
||||
if (visible) expectGetAutoDeleteTimer();
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(messageEncoder).encodeJoinMessage(m.getContactGroupId(),
|
||||
m.getPrivateGroupId(), m.getTimestamp(),
|
||||
@@ -155,8 +156,9 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
|
||||
}
|
||||
|
||||
void expectSendLeaveMessage(boolean visible) throws Exception {
|
||||
expectCheckWhetherContactSupportsAutoDeletion(visible);
|
||||
expectGetLocalTimestamp(messageTimestamp);
|
||||
expectCheckWhetherContactSupportsAutoDeletion();
|
||||
if (visible) expectGetAutoDeleteTimer();
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(messageEncoder).encodeLeaveMessage(contactGroupId,
|
||||
privateGroupId, messageTimestamp, lastLocalMessageId,
|
||||
@@ -232,8 +234,7 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
|
||||
}});
|
||||
}
|
||||
|
||||
void expectCheckWhetherContactSupportsAutoDeletion(boolean visible)
|
||||
throws Exception {
|
||||
void expectCheckWhetherContactSupportsAutoDeletion() throws Exception {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(clientHelper).getContactId(txn, contactGroupId);
|
||||
will(returnValue(contactId));
|
||||
@@ -241,10 +242,13 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
|
||||
GroupInvitationManager.CLIENT_ID,
|
||||
GroupInvitationManager.MAJOR_VERSION);
|
||||
will(returnValue(GroupInvitationManager.MINOR_VERSION));
|
||||
if (visible) {
|
||||
oneOf(autoDeleteManager).getAutoDeleteTimer(txn, contactId);
|
||||
will(returnValue(NO_AUTO_DELETE_TIMER));
|
||||
}
|
||||
}});
|
||||
}
|
||||
|
||||
void expectGetAutoDeleteTimer() throws Exception {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(autoDeleteManager).getAutoDeleteTimer(txn, contactId);
|
||||
will(returnValue(NO_AUTO_DELETE_TIMER));
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class CreatorProtocolEngineTest extends AbstractProtocolEngineTest {
|
||||
expectOnLocalInvite(text);
|
||||
CreatorSession newSession =
|
||||
engine.onInviteAction(txn, session, text, inviteTimestamp,
|
||||
signature);
|
||||
signature, NO_AUTO_DELETE_TIMER);
|
||||
assertEquals(INVITED, newSession.getState());
|
||||
assertEquals(messageId, newSession.getLastLocalMessageId());
|
||||
assertNull(newSession.getLastRemoteMessageId());
|
||||
@@ -61,7 +61,7 @@ public class CreatorProtocolEngineTest extends AbstractProtocolEngineTest {
|
||||
expectOnLocalInvite(null);
|
||||
CreatorSession newSession =
|
||||
engine.onInviteAction(txn, session, null, inviteTimestamp,
|
||||
signature);
|
||||
signature, NO_AUTO_DELETE_TIMER);
|
||||
assertEquals(INVITED, newSession.getState());
|
||||
assertEquals(messageId, newSession.getLastLocalMessageId());
|
||||
assertNull(newSession.getLastRemoteMessageId());
|
||||
@@ -84,31 +84,31 @@ public class CreatorProtocolEngineTest extends AbstractProtocolEngineTest {
|
||||
@Test(expected = ProtocolStateException.class)
|
||||
public void testOnInviteActionFromInvited() throws Exception {
|
||||
engine.onInviteAction(txn, getDefaultSession(INVITED), null,
|
||||
inviteTimestamp, signature);
|
||||
inviteTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = ProtocolStateException.class)
|
||||
public void testOnInviteActionFromJoined() throws Exception {
|
||||
engine.onInviteAction(txn, getDefaultSession(JOINED), null,
|
||||
inviteTimestamp, signature);
|
||||
inviteTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = ProtocolStateException.class)
|
||||
public void testOnInviteActionFromLeft() throws Exception {
|
||||
engine.onInviteAction(txn, getDefaultSession(LEFT), null,
|
||||
inviteTimestamp, signature);
|
||||
inviteTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = ProtocolStateException.class)
|
||||
public void testOnInviteActionFromDissolved() throws Exception {
|
||||
engine.onInviteAction(txn, getDefaultSession(DISSOLVED), null,
|
||||
inviteTimestamp, signature);
|
||||
inviteTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = ProtocolStateException.class)
|
||||
public void testOnInviteActionFromError() throws Exception {
|
||||
engine.onInviteAction(txn, getDefaultSession(ERROR), null,
|
||||
inviteTimestamp, signature);
|
||||
inviteTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
// onJoinAction
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
||||
import static org.briarproject.briar.test.BriarTestUtils.assertGroupCount;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -687,7 +688,8 @@ public class GroupInvitationIntegrationTest
|
||||
byte[] signature = groupInvitationFactory.signInvitation(contact1From0,
|
||||
privateGroup.getId(), timestamp, author0.getPrivateKey());
|
||||
groupInvitationManager0.sendInvitation(privateGroup.getId(),
|
||||
contactId1From0, text, timestamp, signature);
|
||||
contactId1From0, text, timestamp, signature,
|
||||
NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(creatorEngine).onInviteAction(with(txn),
|
||||
with(any(CreatorSession.class)), with(text), with(time),
|
||||
with(signature));
|
||||
with(signature), with(NO_AUTO_DELETE_TIMER));
|
||||
will(returnValue(creatorSession));
|
||||
}});
|
||||
expectStoreSession(creatorSession, storageMessage.getId());
|
||||
@@ -491,7 +491,7 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
||||
oneOf(db).endTransaction(txn);
|
||||
}});
|
||||
groupInvitationManager.sendInvitation(privateGroup.getId(), contactId,
|
||||
text, time, signature);
|
||||
text, time, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -514,7 +514,7 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
||||
will(returnValue(creatorSession));
|
||||
oneOf(creatorEngine).onInviteAction(with(txn),
|
||||
with(any(CreatorSession.class)), with(text), with(time),
|
||||
with(signature));
|
||||
with(signature), with(NO_AUTO_DELETE_TIMER));
|
||||
will(returnValue(creatorSession));
|
||||
}});
|
||||
expectStoreSession(creatorSession, storageMessage.getId());
|
||||
@@ -523,7 +523,7 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
||||
oneOf(db).endTransaction(txn);
|
||||
}});
|
||||
groupInvitationManager.sendInvitation(privateGroup.getId(), contactId,
|
||||
text, time, signature);
|
||||
text, time, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
||||
@@ -58,43 +58,43 @@ public class InviteeProtocolEngineTest extends AbstractProtocolEngineTest {
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromStart() {
|
||||
engine.onInviteAction(txn, getDefaultSession(START), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromLeft() {
|
||||
engine.onInviteAction(txn, getDefaultSession(ACCEPTED), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromInvited() {
|
||||
engine.onInviteAction(txn, getDefaultSession(INVITED), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromDissolved() {
|
||||
engine.onInviteAction(txn, getDefaultSession(DISSOLVED), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromAccepted() {
|
||||
engine.onInviteAction(txn, getDefaultSession(ACCEPTED), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromJoined() {
|
||||
engine.onInviteAction(txn, getDefaultSession(JOINED), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromError() {
|
||||
engine.onInviteAction(txn, getDefaultSession(ERROR), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
// onJoinAction
|
||||
|
||||
@@ -40,43 +40,43 @@ public class PeerProtocolEngineTest extends AbstractProtocolEngineTest {
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromStart() {
|
||||
engine.onInviteAction(txn, getDefaultSession(START), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromAwaitMember() {
|
||||
engine.onInviteAction(txn, getDefaultSession(AWAIT_MEMBER), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromNeitherJoined() {
|
||||
engine.onInviteAction(txn, getDefaultSession(NEITHER_JOINED), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromLocalJoined() {
|
||||
engine.onInviteAction(txn, getDefaultSession(LOCAL_JOINED), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromBothJoined() {
|
||||
engine.onInviteAction(txn, getDefaultSession(BOTH_JOINED), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromLocalLeft() {
|
||||
engine.onInviteAction(txn, getDefaultSession(LOCAL_LEFT), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testOnInviteActionFromError() {
|
||||
engine.onInviteAction(txn, getDefaultSession(ERROR), null,
|
||||
messageTimestamp, signature);
|
||||
messageTimestamp, signature, NO_AUTO_DELETE_TIMER);
|
||||
}
|
||||
|
||||
// onJoinAction
|
||||
|
||||
Reference in New Issue
Block a user