mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Mark invitation unavailable to answer when creator dissolved the group
after the invitation. Closes #876
This commit is contained in:
@@ -269,6 +269,8 @@ class InviteeProtocolEngine extends AbstractProtocolEngine<InviteeSession> {
|
||||
// The dependency, if any, must be the last remote message
|
||||
if (!isValidDependency(s, m.getPreviousMessageId()))
|
||||
return abort(txn, s);
|
||||
// Mark any invite messages in the session unavailable to answer
|
||||
markInvitesUnavailableToAnswer(txn, s);
|
||||
// Move to the DISSOLVED state
|
||||
return new InviteeSession(s.getContactGroupId(), s.getPrivateGroupId(),
|
||||
s.getLastLocalMessageId(), m.getId(), s.getLocalTimestamp(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.briar.privategroup;
|
||||
package org.briarproject.briar.privategroup.invitation;
|
||||
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.sync.Group;
|
||||
@@ -329,6 +329,9 @@ public class GroupInvitationIntegrationTest
|
||||
// Creator's leave message is delivered to invitee
|
||||
sync0To1(1, true);
|
||||
|
||||
// invitee should have no more open invitations
|
||||
assertTrue(groupInvitationManager1.getInvitations().isEmpty());
|
||||
|
||||
// Invitee declines invitation, but it's no longer open - no exception
|
||||
// as the action has succeeded
|
||||
assertEquals(0, groupManager1.getPrivateGroups().size());
|
||||
@@ -651,6 +651,7 @@ public class InviteeProtocolEngineTest extends AbstractProtocolEngineTest {
|
||||
assertTrue(session.getLastRemoteMessageId()
|
||||
.equals(properLeaveMessage.getPreviousMessageId()));
|
||||
|
||||
expectMarkInvitesUnavailableToAnswer();
|
||||
InviteeSession newSession =
|
||||
engine.onLeaveMessage(txn, session, properLeaveMessage);
|
||||
|
||||
@@ -680,6 +681,7 @@ public class InviteeProtocolEngineTest extends AbstractProtocolEngineTest {
|
||||
assertTrue(session.getLastRemoteMessageId()
|
||||
.equals(properLeaveMessage.getPreviousMessageId()));
|
||||
|
||||
expectMarkInvitesUnavailableToAnswer();
|
||||
InviteeSession newSession =
|
||||
engine.onLeaveMessage(txn, session, properLeaveMessage);
|
||||
|
||||
@@ -701,7 +703,7 @@ public class InviteeProtocolEngineTest extends AbstractProtocolEngineTest {
|
||||
public void testOnAbortMessageWhenNotSubscribed() throws Exception {
|
||||
InviteeSession session = getDefaultSession(START);
|
||||
|
||||
expectAbortWhenSubscribedToGroup();
|
||||
expectAbortWhenNotSubscribedToGroup();
|
||||
InviteeSession newSession =
|
||||
engine.onAbortMessage(txn, session, abortMessage);
|
||||
assertSessionAborted(session, newSession);
|
||||
@@ -711,7 +713,7 @@ public class InviteeProtocolEngineTest extends AbstractProtocolEngineTest {
|
||||
public void testOnAbortMessageWhenSubscribed() throws Exception {
|
||||
InviteeSession session = getDefaultSession(START);
|
||||
|
||||
expectAbortWhenNotSubscribedToGroup();
|
||||
expectAbortWhenSubscribedToGroup();
|
||||
InviteeSession newSession =
|
||||
engine.onAbortMessage(txn, session, abortMessage);
|
||||
assertSessionAborted(session, newSession);
|
||||
@@ -739,6 +741,17 @@ public class InviteeProtocolEngineTest extends AbstractProtocolEngineTest {
|
||||
}
|
||||
|
||||
private void expectAbort(boolean subscribed) throws Exception {
|
||||
expectMarkInvitesUnavailableToAnswer();
|
||||
if (subscribed) {
|
||||
expectIsSubscribedPrivateGroup();
|
||||
expectSetPrivateGroupVisibility(INVISIBLE);
|
||||
} else {
|
||||
expectIsNotSubscribedPrivateGroup();
|
||||
}
|
||||
expectSendAbortMessage();
|
||||
}
|
||||
|
||||
private void expectMarkInvitesUnavailableToAnswer() throws Exception {
|
||||
final BdfDictionary query = BdfDictionary.of(new BdfEntry("query", ""));
|
||||
final BdfDictionary meta = BdfDictionary.of(new BdfEntry("meta", ""));
|
||||
final Map<MessageId, BdfDictionary> invites =
|
||||
@@ -752,13 +765,6 @@ public class InviteeProtocolEngineTest extends AbstractProtocolEngineTest {
|
||||
will(returnValue(invites));
|
||||
}});
|
||||
expectMarkMessageAvailableToAnswer(lastRemoteMessageId, false);
|
||||
if (subscribed) {
|
||||
expectIsSubscribedPrivateGroup();
|
||||
expectSetPrivateGroupVisibility(INVISIBLE);
|
||||
} else {
|
||||
expectIsNotSubscribedPrivateGroup();
|
||||
}
|
||||
expectSendAbortMessage();
|
||||
}
|
||||
|
||||
private void assertSessionAborted(InviteeSession oldSession,
|
||||
|
||||
Reference in New Issue
Block a user