use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtil_apply_Test method apply_remove_requesting_member.
@Test
public void apply_remove_requesting_member() throws NotAbleToApplyGroupV2ChangeException {
DecryptedRequestingMember member1 = requestingMember(UUID.randomUUID());
DecryptedRequestingMember member2 = requestingMember(UUID.randomUUID());
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addRequestingMembers(member1).addRequestingMembers(member2).build(), DecryptedGroupChange.newBuilder().setRevision(14).addDeleteRequestingMembers(member1.getUuid()).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(14).addRequestingMembers(member2).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtil_apply_Test method promote_requesting_member.
@Test
public void promote_requesting_member() throws NotAbleToApplyGroupV2ChangeException {
UUID uuid1 = UUID.randomUUID();
UUID uuid2 = UUID.randomUUID();
UUID uuid3 = UUID.randomUUID();
ProfileKey profileKey1 = newProfileKey();
ProfileKey profileKey2 = newProfileKey();
ProfileKey profileKey3 = newProfileKey();
DecryptedRequestingMember member1 = requestingMember(uuid1, profileKey1);
DecryptedRequestingMember member2 = requestingMember(uuid2, profileKey2);
DecryptedRequestingMember member3 = requestingMember(uuid3, profileKey3);
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addRequestingMembers(member1).addRequestingMembers(member2).addRequestingMembers(member3).build(), DecryptedGroupChange.newBuilder().setRevision(14).addPromoteRequestingMembers(DecryptedApproveMember.newBuilder().setRole(Member.Role.DEFAULT).setUuid(member1.getUuid())).addPromoteRequestingMembers(DecryptedApproveMember.newBuilder().setRole(Member.Role.ADMINISTRATOR).setUuid(member2.getUuid())).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(14).addMembers(member(uuid1, profileKey1)).addMembers(admin(uuid2, profileKey2)).addRequestingMembers(member3).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtil_apply_Test method apply_new_pending_member_already_pending.
@Test
public void apply_new_pending_member_already_pending() throws NotAbleToApplyGroupV2ChangeException {
DecryptedMember member1 = member(UUID.randomUUID());
DecryptedPendingMember pending = pendingMember(UUID.randomUUID());
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addPendingMembers(pending).build(), DecryptedGroupChange.newBuilder().setRevision(11).addNewPendingMembers(pending).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).addPendingMembers(pending).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by WhisperSystems.
the class GroupChangeUtil_resolveConflict_Test method field_9__promote_pending_members.
@Test
public void field_9__promote_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(member2)).build();
DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().addPromotePendingMembers(member(member1)).addPromotePendingMembers(member(member2)).addPromotePendingMembers(member(member3)).build();
GroupChange.Actions change = GroupChange.Actions.newBuilder().addPromotePendingMembers(GroupChange.Actions.PromotePendingMemberAction.newBuilder().setPresentation(presentation(member1, randomProfileKey()))).addPromotePendingMembers(GroupChange.Actions.PromotePendingMemberAction.newBuilder().setPresentation(presentation(member2, profileKey2))).addPromotePendingMembers(GroupChange.Actions.PromotePendingMemberAction.newBuilder().setPresentation(presentation(member3, randomProfileKey()))).build();
GroupChange.Actions resolvedActions = GroupChangeUtil.resolveConflict(groupState, decryptedChange, change).build();
GroupChange.Actions expected = GroupChange.Actions.newBuilder().addPromotePendingMembers(GroupChange.Actions.PromotePendingMemberAction.newBuilder().setPresentation(presentation(member2, profileKey2))).build();
assertEquals(expected, resolvedActions);
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by WhisperSystems.
the class GroupChangeUtil_resolveConflict_Test method field_20__no_description_change_is_removed.
@Test
public void field_20__no_description_change_is_removed() {
DecryptedGroup groupState = DecryptedGroup.newBuilder().setDescription("Existing title").build();
DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().setNewDescription(DecryptedString.newBuilder().setValue("Existing title").build()).build();
GroupChange.Actions change = GroupChange.Actions.newBuilder().setModifyDescription(GroupChange.Actions.ModifyDescriptionAction.newBuilder().setDescription(ByteString.copyFrom("Existing title encrypted".getBytes()))).build();
GroupChange.Actions resolvedActions = GroupChangeUtil.resolveConflict(groupState, decryptedChange, change).build();
assertTrue(GroupChangeUtil.changeIsEmpty(resolvedActions));
}
Aggregations