mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Introduce SharingStatus to report more fine-grained status
This commit is contained in:
@@ -37,6 +37,7 @@ import org.briarproject.briar.api.privategroup.invitation.GroupInvitationItem;
|
||||
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager;
|
||||
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationRequest;
|
||||
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationResponse;
|
||||
import org.briarproject.briar.api.sharing.SharingManager.SharingStatus;
|
||||
import org.briarproject.briar.client.ConversationClientImpl;
|
||||
import org.briarproject.nullsafety.NotNullByDefault;
|
||||
|
||||
@@ -56,6 +57,7 @@ import javax.inject.Inject;
|
||||
import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;
|
||||
import static org.briarproject.bramble.api.sync.validation.IncomingMessageHook.DeliveryAction.ACCEPT_DO_NOT_SHARE;
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
||||
import static org.briarproject.briar.privategroup.invitation.CreatorState.JOINED;
|
||||
import static org.briarproject.briar.privategroup.invitation.CreatorState.START;
|
||||
import static org.briarproject.briar.privategroup.invitation.MessageType.ABORT;
|
||||
import static org.briarproject.briar.privategroup.invitation.MessageType.INVITE;
|
||||
@@ -511,7 +513,7 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvitationAllowed(Contact c, GroupId privateGroupId)
|
||||
public SharingStatus getSharingStatus(Contact c, GroupId privateGroupId)
|
||||
throws DbException {
|
||||
GroupId contactGroupId = getContactGroup(c).getId();
|
||||
SessionId sessionId = getSessionId(privateGroupId);
|
||||
@@ -523,13 +525,16 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
StoredSession ss = getSession(txn, contactGroupId, sessionId);
|
||||
db.commitTransaction(txn);
|
||||
// The group can't be shared unless the contact supports the client
|
||||
if (client != SHARED) return false;
|
||||
if (client != SHARED) return SharingStatus.NOT_SUPPORTED;
|
||||
// If there's no session, the contact can be invited
|
||||
if (ss == null) return true;
|
||||
if (ss == null) return SharingStatus.SHAREABLE;
|
||||
// If the session's in the start state, the contact can be invited
|
||||
CreatorSession session = sessionParser
|
||||
.parseCreatorSession(contactGroupId, ss.bdfSession);
|
||||
return session.getState() == START;
|
||||
CreatorState state = session.getState();
|
||||
if (state == START) return SharingStatus.SHAREABLE;
|
||||
if (state == JOINED) return SharingStatus.SHARING;
|
||||
return SharingStatus.INVITED;
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
} finally {
|
||||
|
||||
@@ -51,6 +51,7 @@ import javax.annotation.Nullable;
|
||||
import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;
|
||||
import static org.briarproject.bramble.api.sync.validation.IncomingMessageHook.DeliveryAction.ACCEPT_DO_NOT_SHARE;
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHAREABLE;
|
||||
import static org.briarproject.briar.sharing.MessageType.ABORT;
|
||||
import static org.briarproject.briar.sharing.MessageType.ACCEPT;
|
||||
import static org.briarproject.briar.sharing.MessageType.DECLINE;
|
||||
@@ -269,7 +270,7 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
SessionId sessionId = getSessionId(shareableId);
|
||||
try {
|
||||
Contact contact = db.getContact(txn, contactId);
|
||||
if (!canBeShared(txn, shareableId, contact))
|
||||
if (getSharingStatus(txn, shareableId, contact) != SHAREABLE)
|
||||
// we might have received an invitation in the meantime
|
||||
return;
|
||||
// Look up the session, if there is one
|
||||
@@ -467,34 +468,36 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeShared(GroupId g, Contact c) throws DbException {
|
||||
public SharingStatus getSharingStatus(GroupId g, Contact c) throws DbException {
|
||||
Transaction txn = db.startTransaction(true);
|
||||
try {
|
||||
boolean canBeShared = canBeShared(txn, g, c);
|
||||
SharingStatus sharingStatus = getSharingStatus(txn, g, c);
|
||||
db.commitTransaction(txn);
|
||||
return canBeShared;
|
||||
return sharingStatus;
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeShared(Transaction txn, GroupId g, Contact c)
|
||||
public SharingStatus getSharingStatus(Transaction txn, GroupId g, Contact c)
|
||||
throws DbException {
|
||||
// The group can't be shared unless the contact supports the client
|
||||
Visibility client = clientVersioningManager.getClientVisibility(txn,
|
||||
c.getId(), getShareableClientId(), getShareableMajorVersion());
|
||||
if (client != SHARED) return false;
|
||||
if (client != SHARED) return SharingStatus.NOT_SUPPORTED;
|
||||
GroupId contactGroupId = getContactGroup(c).getId();
|
||||
SessionId sessionId = getSessionId(g);
|
||||
try {
|
||||
StoredSession ss = getSession(txn, contactGroupId, sessionId);
|
||||
// If there's no session, we can share the group with the contact
|
||||
if (ss == null) return true;
|
||||
if (ss == null) return SharingStatus.SHAREABLE;
|
||||
// If the session's in the right state, the contact can be invited
|
||||
Session session =
|
||||
sessionParser.parseSession(contactGroupId, ss.bdfSession);
|
||||
return session.getState().canInvite();
|
||||
if (session.getState().canInvite()) return SharingStatus.SHAREABLE;
|
||||
if (session.getState().isSharing()) return SharingStatus.SHARING;
|
||||
return SharingStatus.INVITED;
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,10 @@ enum State {
|
||||
return this == START;
|
||||
}
|
||||
|
||||
public boolean isSharing() {
|
||||
return this == SHARING;
|
||||
}
|
||||
|
||||
public boolean isAwaitingResponse() {
|
||||
return this == LOCAL_INVITED || this == REMOTE_INVITED;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import javax.annotation.Nullable;
|
||||
import static org.briarproject.bramble.api.cleanup.CleanupManager.BATCH_DELAY_MS;
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.MIN_AUTO_DELETE_TIMER_MS;
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHAREABLE;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHARING;
|
||||
import static org.briarproject.briar.test.TestEventListener.assertEvent;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -157,8 +159,8 @@ public class AutoDeleteIntegrationTest extends AbstractAutoDeleteTest {
|
||||
waitForEvents(c1);
|
||||
|
||||
// 0 can invite 1 again
|
||||
assertTrue(groupInvitationManager0
|
||||
.isInvitationAllowed(contact1From0, privateGroup.getId()));
|
||||
assertEquals(SHAREABLE, groupInvitationManager0
|
||||
.getSharingStatus(contact1From0, privateGroup.getId()));
|
||||
|
||||
// Before 1's timer elapses, 1 should still see the auto-decline message
|
||||
c0.getTimeTravel().addCurrentTimeMillis(timerLatency - 1);
|
||||
@@ -194,8 +196,8 @@ public class AutoDeleteIntegrationTest extends AbstractAutoDeleteTest {
|
||||
assertEquals(0, getMessageHeaders(c0, contactId1From0).size());
|
||||
|
||||
// 0 can invite 1 again and really does invite
|
||||
assertTrue(groupInvitationManager0
|
||||
.isInvitationAllowed(contact1From0, privateGroup.getId()));
|
||||
assertEquals(SHAREABLE, groupInvitationManager0
|
||||
.getSharingStatus(contact1From0, privateGroup.getId()));
|
||||
sendInvitation(privateGroup, contact1From0.getId(),
|
||||
"Join this faster please!");
|
||||
sync0To1(1, true);
|
||||
@@ -395,8 +397,8 @@ public class AutoDeleteIntegrationTest extends AbstractAutoDeleteTest {
|
||||
// 1 joined the PrivateGroup
|
||||
assertEquals(pg,
|
||||
c1.getPrivateGroupManager().getPrivateGroup(pg.getId()));
|
||||
assertFalse(groupInvitationManager0
|
||||
.isInvitationAllowed(contact1From0, pg.getId()));
|
||||
assertEquals(SHARING, groupInvitationManager0
|
||||
.getSharingStatus(contact1From0, pg.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -29,6 +29,9 @@ import javax.annotation.Nullable;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.MIN_AUTO_DELETE_TIMER_MS;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.INVITED;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHAREABLE;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHARING;
|
||||
import static org.briarproject.briar.test.BriarTestUtils.assertGroupCount;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -319,8 +322,8 @@ public class GroupInvitationIntegrationTest
|
||||
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||
|
||||
// invitation is not allowed before the first hasn't been answered
|
||||
assertFalse(groupInvitationManager0
|
||||
.isInvitationAllowed(contact1From0, privateGroup.getId()));
|
||||
assertEquals(INVITED, groupInvitationManager0
|
||||
.getSharingStatus(contact1From0, privateGroup.getId()));
|
||||
|
||||
// deliver invitation and response
|
||||
sync0To1(1, true);
|
||||
@@ -329,8 +332,8 @@ public class GroupInvitationIntegrationTest
|
||||
sync1To0(1, true);
|
||||
|
||||
// after invitation was declined, inviting again is possible
|
||||
assertTrue(groupInvitationManager0
|
||||
.isInvitationAllowed(contact1From0, privateGroup.getId()));
|
||||
assertEquals(SHAREABLE, groupInvitationManager0
|
||||
.getSharingStatus(contact1From0, privateGroup.getId()));
|
||||
|
||||
// send and accept the second invitation
|
||||
sendInvitation(c0.getClock().currentTimeMillis(), "Second Invitation");
|
||||
@@ -340,8 +343,8 @@ public class GroupInvitationIntegrationTest
|
||||
sync1To0(1, true);
|
||||
|
||||
// invitation is not allowed since the member joined the group now
|
||||
assertFalse(groupInvitationManager0
|
||||
.isInvitationAllowed(contact1From0, privateGroup.getId()));
|
||||
assertEquals(SHARING, groupInvitationManager0
|
||||
.getSharingStatus(contact1From0, privateGroup.getId()));
|
||||
|
||||
// don't allow another invitation request
|
||||
try {
|
||||
@@ -723,8 +726,8 @@ public class GroupInvitationIntegrationTest
|
||||
sync1To0(1, true);
|
||||
|
||||
// inviting again is not possible
|
||||
assertFalse(groupInvitationManager0
|
||||
.isInvitationAllowed(contact1From0, privateGroup.getId()));
|
||||
assertEquals(SHARING, groupInvitationManager0
|
||||
.getSharingStatus(contact1From0, privateGroup.getId()));
|
||||
|
||||
// contacts remove each other
|
||||
removeAllContacts();
|
||||
@@ -737,8 +740,8 @@ public class GroupInvitationIntegrationTest
|
||||
addDefaultContacts();
|
||||
|
||||
// creator can still not invite again
|
||||
assertFalse(groupInvitationManager0
|
||||
.isInvitationAllowed(contact1From0, privateGroup.getId()));
|
||||
assertEquals(INVITED, groupInvitationManager0
|
||||
.getSharingStatus(contact1From0, privateGroup.getId()));
|
||||
|
||||
// finally invitee can remove group without issues
|
||||
groupManager1.removePrivateGroup(privateGroup.getId());
|
||||
|
||||
@@ -62,12 +62,14 @@ import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.GROU
|
||||
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.MAJOR_VERSION;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.INVITED;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHAREABLE;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHARING;
|
||||
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.JOIN;
|
||||
import static org.briarproject.briar.privategroup.invitation.MessageType.LEAVE;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
||||
@@ -871,31 +873,31 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
||||
@Test
|
||||
public void testIsInvitationAllowed() throws Exception {
|
||||
expectIsInvitationAllowed(CreatorState.START);
|
||||
assertTrue(groupInvitationManager
|
||||
.isInvitationAllowed(contact, privateGroup.getId()));
|
||||
assertEquals(SHAREABLE, groupInvitationManager
|
||||
.getSharingStatus(contact, privateGroup.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNotInvitationAllowed() throws Exception {
|
||||
expectIsInvitationAllowed(CreatorState.DISSOLVED);
|
||||
assertFalse(groupInvitationManager
|
||||
.isInvitationAllowed(contact, privateGroup.getId()));
|
||||
assertEquals(INVITED, groupInvitationManager
|
||||
.getSharingStatus(contact, privateGroup.getId()));
|
||||
|
||||
expectIsInvitationAllowed(CreatorState.ERROR);
|
||||
assertFalse(groupInvitationManager
|
||||
.isInvitationAllowed(contact, privateGroup.getId()));
|
||||
assertEquals(INVITED, groupInvitationManager
|
||||
.getSharingStatus(contact, privateGroup.getId()));
|
||||
|
||||
expectIsInvitationAllowed(CreatorState.INVITED);
|
||||
assertFalse(groupInvitationManager
|
||||
.isInvitationAllowed(contact, privateGroup.getId()));
|
||||
assertEquals(INVITED, groupInvitationManager
|
||||
.getSharingStatus(contact, privateGroup.getId()));
|
||||
|
||||
expectIsInvitationAllowed(CreatorState.JOINED);
|
||||
assertFalse(groupInvitationManager
|
||||
.isInvitationAllowed(contact, privateGroup.getId()));
|
||||
assertEquals(SHARING, groupInvitationManager
|
||||
.getSharingStatus(contact, privateGroup.getId()));
|
||||
|
||||
expectIsInvitationAllowed(CreatorState.LEFT);
|
||||
assertFalse(groupInvitationManager
|
||||
.isInvitationAllowed(contact, privateGroup.getId()));
|
||||
assertEquals(INVITED, groupInvitationManager
|
||||
.getSharingStatus(contact, privateGroup.getId()));
|
||||
}
|
||||
|
||||
private void expectIsInvitationAllowed(CreatorState state)
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.Collection;
|
||||
|
||||
import static org.briarproject.bramble.api.cleanup.CleanupManager.BATCH_DELAY_MS;
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.MIN_AUTO_DELETE_TIMER_MS;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHAREABLE;
|
||||
import static org.briarproject.briar.test.TestEventListener.assertEvent;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -146,8 +147,8 @@ public abstract class AbstractAutoDeleteIntegrationTest
|
||||
waitForEvents(c1);
|
||||
|
||||
// 0 can invite 1 again
|
||||
assertTrue(getSharingManager0()
|
||||
.canBeShared(getShareable().getId(), contact1From0));
|
||||
assertEquals(SHAREABLE, getSharingManager0().getSharingStatus(
|
||||
getShareable().getId(), contact1From0));
|
||||
|
||||
// Before 1's timer elapses, 1 should still see the auto-decline message
|
||||
c0.getTimeTravel().addCurrentTimeMillis(timerLatency - 1);
|
||||
@@ -183,8 +184,8 @@ public abstract class AbstractAutoDeleteIntegrationTest
|
||||
assertEquals(0, getMessageHeaders(c0, contactId1From0).size());
|
||||
|
||||
// 0 can invite 1 again and really does invite
|
||||
assertTrue(getSharingManager0()
|
||||
.canBeShared(getShareable().getId(), contact1From0));
|
||||
assertEquals(SHAREABLE, getSharingManager0()
|
||||
.getSharingStatus(getShareable().getId(), contact1From0));
|
||||
// Send invitation
|
||||
getSharingManager0()
|
||||
.sendInvitation(getShareable().getId(), contactId1From0,
|
||||
|
||||
@@ -33,6 +33,8 @@ import java.util.Collection;
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.MIN_AUTO_DELETE_TIMER_MS;
|
||||
import static org.briarproject.briar.api.blog.BlogSharingManager.CLIENT_ID;
|
||||
import static org.briarproject.briar.api.blog.BlogSharingManager.MAJOR_VERSION;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHAREABLE;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHARING;
|
||||
import static org.briarproject.briar.test.BriarTestUtils.assertGroupCount;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -106,14 +108,18 @@ public class BlogSharingIntegrationTest
|
||||
public void testPersonalBlogCannotBeSharedWithOwner() throws Exception {
|
||||
listenToEvents(true);
|
||||
|
||||
assertFalse(blogSharingManager0.canBeShared(blog1.getId(),
|
||||
contact1From0));
|
||||
assertFalse(blogSharingManager0.canBeShared(blog2.getId(),
|
||||
contact2From0));
|
||||
assertFalse(blogSharingManager1.canBeShared(blog0.getId(),
|
||||
contact0From1));
|
||||
assertFalse(blogSharingManager2.canBeShared(blog0.getId(),
|
||||
contact0From2));
|
||||
assertEquals(SHARING,
|
||||
blogSharingManager0.getSharingStatus(blog1.getId(),
|
||||
contact1From0));
|
||||
assertEquals(SHARING,
|
||||
blogSharingManager0.getSharingStatus(blog2.getId(),
|
||||
contact2From0));
|
||||
assertEquals(SHARING,
|
||||
blogSharingManager1.getSharingStatus(blog0.getId(),
|
||||
contact0From1));
|
||||
assertEquals(SHARING,
|
||||
blogSharingManager2.getSharingStatus(blog0.getId(),
|
||||
contact0From2));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -191,13 +197,13 @@ public class BlogSharingIntegrationTest
|
||||
}
|
||||
// sharer has own invitation message and response
|
||||
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||
blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
.size());
|
||||
// blog can not be shared again
|
||||
assertFalse(blogSharingManager0.canBeShared(blog2.getId(),
|
||||
contact1From0));
|
||||
assertFalse(blogSharingManager1.canBeShared(blog2.getId(),
|
||||
contact0From1));
|
||||
assertEquals(SHARING, blogSharingManager0.getSharingStatus(
|
||||
blog2.getId(), contact1From0));
|
||||
assertEquals(SHARING, blogSharingManager1.getSharingStatus(
|
||||
blog2.getId(), contact0From1));
|
||||
|
||||
// group message count is still correct
|
||||
assertGroupCount(messageTracker0, g, 2, 1);
|
||||
@@ -300,13 +306,13 @@ public class BlogSharingIntegrationTest
|
||||
}
|
||||
// sharer has own invitation message and response
|
||||
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||
blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
.size());
|
||||
// blog can not be shared again
|
||||
assertFalse(blogSharingManager0.canBeShared(rssBlog.getId(),
|
||||
contact1From0));
|
||||
assertFalse(blogSharingManager1.canBeShared(rssBlog.getId(),
|
||||
contact0From1));
|
||||
assertEquals(SHARING, blogSharingManager0.getSharingStatus(
|
||||
rssBlog.getId(), contact1From0));
|
||||
assertEquals(SHARING, blogSharingManager1.getSharingStatus(
|
||||
rssBlog.getId(), contact0From1));
|
||||
|
||||
// group message count is still correct
|
||||
assertGroupCount(messageTracker0, g, 2, 1);
|
||||
@@ -361,11 +367,11 @@ public class BlogSharingIntegrationTest
|
||||
}
|
||||
// sharer has own invitation message and response
|
||||
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||
blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
.size());
|
||||
// blog can be shared again
|
||||
assertTrue(
|
||||
blogSharingManager0.canBeShared(blog2.getId(), contact1From0));
|
||||
assertEquals(SHAREABLE, blogSharingManager0.getSharingStatus(
|
||||
blog2.getId(), contact1From0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -416,8 +422,8 @@ public class BlogSharingIntegrationTest
|
||||
assertEquals(0,
|
||||
blogSharingManager1.getSharedWith(blog2.getId()).size());
|
||||
// blog can be shared again by sharer
|
||||
assertTrue(
|
||||
blogSharingManager0.canBeShared(blog2.getId(), contact1From0));
|
||||
assertEquals(SHAREABLE, blogSharingManager0.getSharingStatus(
|
||||
blog2.getId(), contact1From0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -534,8 +540,8 @@ public class BlogSharingIntegrationTest
|
||||
.contains(contact0From1));
|
||||
|
||||
// 1 can again share blog 1 with 0
|
||||
assertTrue(
|
||||
blogSharingManager1.canBeShared(blog1.getId(), contact0From1));
|
||||
assertEquals(SHAREABLE, blogSharingManager1.getSharingStatus(
|
||||
blog1.getId(), contact0From1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -592,8 +598,8 @@ public class BlogSharingIntegrationTest
|
||||
}
|
||||
|
||||
// 0 can share blog2 again with 1
|
||||
assertTrue(
|
||||
blogSharingManager0.canBeShared(blog2.getId(), contact1From0));
|
||||
assertEquals(SHAREABLE, blogSharingManager0.getSharingStatus(
|
||||
blog2.getId(), contact1From0));
|
||||
}
|
||||
|
||||
@NotNullByDefault
|
||||
|
||||
@@ -47,6 +47,9 @@ import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.MIN_AUTO_DELETE_TIMER_MS;
|
||||
import static org.briarproject.briar.api.forum.ForumSharingManager.CLIENT_ID;
|
||||
import static org.briarproject.briar.api.forum.ForumSharingManager.MAJOR_VERSION;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.INVITED;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHAREABLE;
|
||||
import static org.briarproject.briar.api.sharing.SharingManager.SharingStatus.SHARING;
|
||||
import static org.briarproject.briar.test.BriarTestUtils.assertGroupCount;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -183,9 +186,11 @@ public class ForumSharingIntegrationTest
|
||||
assertEquals(2, getMessages1From0().size());
|
||||
// forum can not be shared again
|
||||
Contact c1 = contactManager0.getContact(contactId1From0);
|
||||
assertFalse(forumSharingManager0.canBeShared(forum.getId(), c1));
|
||||
assertEquals(SHARING,
|
||||
forumSharingManager0.getSharingStatus(forum.getId(), c1));
|
||||
Contact c0 = contactManager1.getContact(contactId0From1);
|
||||
assertFalse(forumSharingManager1.canBeShared(forum.getId(), c0));
|
||||
assertEquals(SHARING,
|
||||
forumSharingManager1.getSharingStatus(forum.getId(), c0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -271,7 +276,8 @@ public class ForumSharingIntegrationTest
|
||||
assertEquals(2, getMessages1From0().size());
|
||||
// forum can be shared again
|
||||
Contact c1 = contactManager0.getContact(contactId1From0);
|
||||
assertTrue(forumSharingManager0.canBeShared(forum.getId(), c1));
|
||||
assertEquals(SHAREABLE,
|
||||
forumSharingManager0.getSharingStatus(forum.getId(), c1));
|
||||
|
||||
// sharer un-subscribes from forum
|
||||
forumManager0.removeForum(forum);
|
||||
@@ -340,18 +346,18 @@ public class ForumSharingIntegrationTest
|
||||
assertFalse(forumSharingManager1.getSharedWith(forum.getId())
|
||||
.contains(contact0));
|
||||
// forum can be shared again by sharer
|
||||
assertTrue(forumSharingManager0
|
||||
.canBeShared(forum.getId(), contact1From0));
|
||||
assertEquals(SHAREABLE, forumSharingManager0
|
||||
.getSharingStatus(forum.getId(), contact1From0));
|
||||
// invitee that left can not yet share again
|
||||
assertFalse(forumSharingManager1
|
||||
.canBeShared(forum.getId(), contact0From1));
|
||||
assertEquals(INVITED, forumSharingManager1
|
||||
.getSharingStatus(forum.getId(), contact0From1));
|
||||
|
||||
// sharer responds with leave message
|
||||
sync0To1(1, true);
|
||||
|
||||
// invitee that left can now share again
|
||||
assertTrue(forumSharingManager1
|
||||
.canBeShared(forum.getId(), contact0From1));
|
||||
assertEquals(SHAREABLE, forumSharingManager1
|
||||
.getSharingStatus(forum.getId(), contact0From1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -405,13 +411,15 @@ public class ForumSharingIntegrationTest
|
||||
assertFalse(forumSharingManager1.getSharedWith(forum.getId())
|
||||
.contains(contact0));
|
||||
// forum can be re-shared by invitee now
|
||||
assertTrue(forumSharingManager1.canBeShared(forum.getId(), c0));
|
||||
assertEquals(SHAREABLE,
|
||||
forumSharingManager1.getSharingStatus(forum.getId(), c0));
|
||||
|
||||
// invitee responds with LEAVE message
|
||||
sync1To0(1, true);
|
||||
|
||||
// sharer can share forum again as well now
|
||||
assertTrue(forumSharingManager0.canBeShared(forum.getId(), c1));
|
||||
assertEquals(SHAREABLE,
|
||||
forumSharingManager0.getSharingStatus(forum.getId(), c1));
|
||||
|
||||
// invitee also un-subscribes forum without effect
|
||||
forumManager1.removeForum(forum);
|
||||
@@ -621,10 +629,10 @@ public class ForumSharingIntegrationTest
|
||||
addContacts1And2();
|
||||
|
||||
// forum can be shared with contacts again
|
||||
assertTrue(forumSharingManager0
|
||||
.canBeShared(forum.getId(), contact1From0));
|
||||
assertTrue(forumSharingManager0
|
||||
.canBeShared(forum.getId(), contact2From0));
|
||||
assertEquals(SHAREABLE, forumSharingManager0
|
||||
.getSharingStatus(forum.getId(), contact1From0));
|
||||
assertEquals(SHAREABLE, forumSharingManager0
|
||||
.getSharingStatus(forum.getId(), contact2From0));
|
||||
|
||||
// send invitation
|
||||
forumSharingManager0
|
||||
|
||||
Reference in New Issue
Block a user