Skip to content
Snippets Groups Projects
Commit 3c3731a5 authored by akwizgran's avatar akwizgran
Browse files

Merge branch '876-group-invitation-not-marked-unavailable' into 'master'

Mark invitation unavailable to answer when creator dissolved the group after the invitation.

Closes #876

See merge request !468
parents 79fc4147 6a94785d
No related branches found
No related tags found
No related merge requests found
......@@ -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(),
......
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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment