use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by WhisperSystems.
the class GroupChangeUtil_resolveConflict_Test method field_12__timer_change_is_preserved.
@Test
public void field_12__timer_change_is_preserved() {
DecryptedGroup groupState = DecryptedGroup.newBuilder().setDisappearingMessagesTimer(DecryptedTimer.newBuilder().setDuration(123)).build();
DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().setNewTimer(DecryptedTimer.newBuilder().setDuration(456)).build();
GroupChange.Actions change = GroupChange.Actions.newBuilder().setModifyDisappearingMessagesTimer(GroupChange.Actions.ModifyDisappearingMessagesTimerAction.newBuilder().setTimer(ByteString.EMPTY)).build();
GroupChange.Actions resolvedActions = GroupChangeUtil.resolveConflict(groupState, decryptedChange, change).build();
assertEquals(change, resolvedActions);
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by WhisperSystems.
the class GroupChangeUtil_resolveConflict_Test method field_7__add_pending_members.
@Test
public void field_7__add_pending_members() {
UUID member1 = UUID.randomUUID();
UUID member2 = UUID.randomUUID();
UUID member3 = UUID.randomUUID();
ProfileKey profileKey2 = randomProfileKey();
DecryptedGroup groupState = DecryptedGroup.newBuilder().addMembers(member(member1)).addPendingMembers(pendingMember(member3)).build();
DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().addNewPendingMembers(pendingMember(member1)).addNewPendingMembers(pendingMember(member2)).addNewPendingMembers(pendingMember(member3)).build();
GroupChange.Actions change = GroupChange.Actions.newBuilder().addAddPendingMembers(GroupChange.Actions.AddPendingMemberAction.newBuilder().setAdded(PendingMember.newBuilder().setMember(encryptedMember(member1, randomProfileKey())))).addAddPendingMembers(GroupChange.Actions.AddPendingMemberAction.newBuilder().setAdded(PendingMember.newBuilder().setMember(encryptedMember(member2, profileKey2)))).addAddPendingMembers(GroupChange.Actions.AddPendingMemberAction.newBuilder().setAdded(PendingMember.newBuilder().setMember(encryptedMember(member3, randomProfileKey())))).build();
GroupChange.Actions resolvedActions = GroupChangeUtil.resolveConflict(groupState, decryptedChange, change).build();
GroupChange.Actions expected = GroupChange.Actions.newBuilder().addAddPendingMembers(GroupChange.Actions.AddPendingMemberAction.newBuilder().setAdded(PendingMember.newBuilder().setMember(encryptedMember(member2, profileKey2)))).build();
assertEquals(expected, resolvedActions);
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtil_apply_Test method attribute_access.
@Test
public void attribute_access() throws NotAbleToApplyGroupV2ChangeException {
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).setAccessControl(AccessControl.newBuilder().setAttributes(AccessControl.AccessRequired.ADMINISTRATOR).setMembers(AccessControl.AccessRequired.MEMBER).build()).build(), DecryptedGroupChange.newBuilder().setRevision(11).setNewAttributeAccess(AccessControl.AccessRequired.MEMBER).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).setAccessControl(AccessControl.newBuilder().setAttributes(AccessControl.AccessRequired.MEMBER).setMembers(AccessControl.AccessRequired.MEMBER).build()).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtil_apply_Test method title.
@Test
public void title() throws NotAbleToApplyGroupV2ChangeException {
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).setTitle("Old title").build(), DecryptedGroupChange.newBuilder().setRevision(11).setNewTitle(DecryptedString.newBuilder().setValue("New title").build()).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).setTitle("New title").build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtil_apply_Test method invite_link_password.
@Test
public void invite_link_password() throws NotAbleToApplyGroupV2ChangeException {
ByteString password1 = ByteString.copyFrom(Util.getSecretBytes(16));
ByteString password2 = ByteString.copyFrom(Util.getSecretBytes(16));
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).setInviteLinkPassword(password1).build(), DecryptedGroupChange.newBuilder().setRevision(11).setNewInviteLinkPassword(password2).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).setInviteLinkPassword(password2).build(), newGroup);
}
Aggregations