use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtil_apply_Test method apply_modify_member_profile_keys.
@Test
public void apply_modify_member_profile_keys() throws NotAbleToApplyGroupV2ChangeException {
ProfileKey profileKey1 = randomProfileKey();
ProfileKey profileKey2a = randomProfileKey();
ProfileKey profileKey2b = randomProfileKey();
DecryptedMember member1 = member(UUID.randomUUID(), profileKey1);
DecryptedMember member2a = member(UUID.randomUUID(), profileKey2a);
DecryptedMember member2b = withProfileKey(member2a, profileKey2b);
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addMembers(member1).addMembers(member2a).build(), DecryptedGroupChange.newBuilder().setRevision(14).addModifiedProfileKeys(member2b).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(14).addMembers(member1).addMembers(member2b).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtil_apply_Test method skip_promote_pending_member_by_direct_add.
@Test
public void skip_promote_pending_member_by_direct_add() throws NotAbleToApplyGroupV2ChangeException {
ProfileKey profileKey2 = randomProfileKey();
ProfileKey profileKey3 = randomProfileKey();
DecryptedMember member1 = member(UUID.randomUUID());
UUID pending2Uuid = UUID.randomUUID();
UUID pending3Uuid = UUID.randomUUID();
UUID pending4Uuid = UUID.randomUUID();
DecryptedPendingMember pending2 = pendingMember(pending2Uuid);
DecryptedPendingMember pending3 = pendingMember(pending3Uuid);
DecryptedPendingMember pending4 = pendingMember(pending4Uuid);
DecryptedMember member2 = member(pending2Uuid, profileKey2);
DecryptedMember member3 = member(pending3Uuid, profileKey3);
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addPendingMembers(pending2).addPendingMembers(pending3).addPendingMembers(pending4).build(), DecryptedGroupChange.newBuilder().setRevision(11).addNewMembers(member2).addNewMembers(member3).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).addMembers(member2).addMembers(member3).addPendingMembers(pending4).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtil_apply_Test method apply_remove_member.
@Test
public void apply_remove_member() throws NotAbleToApplyGroupV2ChangeException {
DecryptedMember member1 = member(UUID.randomUUID());
DecryptedMember member2 = member(UUID.randomUUID());
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addMembers(member1).addMembers(member2).build(), DecryptedGroupChange.newBuilder().setRevision(14).addDeleteMembers(member1.getUuid()).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(14).addMembers(member2).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtil_apply_Test method cannot_promote_pending_member_if_not_in_group.
@Test(expected = NotAbleToApplyGroupV2ChangeException.class)
public void cannot_promote_pending_member_if_not_in_group() throws NotAbleToApplyGroupV2ChangeException {
ProfileKey profileKey2 = randomProfileKey();
DecryptedMember member1 = member(UUID.randomUUID());
UUID pending2Uuid = UUID.randomUUID();
DecryptedMember member2 = withProfileKey(admin(pending2Uuid), profileKey2);
DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).build(), DecryptedGroupChange.newBuilder().setRevision(11).addPromotePendingMembers(member2).build());
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtil_apply_Test method apply_modify_member_role.
@Test
public void apply_modify_member_role() throws NotAbleToApplyGroupV2ChangeException {
DecryptedMember member1 = member(UUID.randomUUID());
DecryptedMember member2 = admin(UUID.randomUUID());
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addMembers(member1).addMembers(member2).build(), DecryptedGroupChange.newBuilder().setRevision(14).addModifyMemberRoles(DecryptedModifyMemberRole.newBuilder().setUuid(member1.getUuid()).setRole(Member.Role.ADMINISTRATOR)).addModifyMemberRoles(DecryptedModifyMemberRole.newBuilder().setUuid(member2.getUuid()).setRole(Member.Role.DEFAULT)).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(14).addMembers(asAdmin(member1)).addMembers(asMember(member2)).build(), newGroup);
}
Aggregations