use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method apply_modify_admin_profile_keys.
@Test
public void apply_modify_admin_profile_keys() throws NotAbleToApplyGroupV2ChangeException {
UUID adminUuid = UUID.randomUUID();
ProfileKey profileKey1 = randomProfileKey();
ProfileKey profileKey2a = randomProfileKey();
ProfileKey profileKey2b = randomProfileKey();
DecryptedMember member1 = member(UUID.randomUUID(), profileKey1);
DecryptedMember admin2a = admin(adminUuid, profileKey2a);
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addMembers(member1).addMembers(admin2a).build(), DecryptedGroupChange.newBuilder().setRevision(14).addModifiedProfileKeys(DecryptedMember.newBuilder(DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(adminUuid)).build()).setProfileKey(ByteString.copyFrom(profileKey2b.serialize()))).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(14).addMembers(member1).addMembers(admin(adminUuid, profileKey2b)).build(), newGroup);
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method skip_promote_requesting_member_by_direct_add.
@Test
public void skip_promote_requesting_member_by_direct_add() throws NotAbleToApplyGroupV2ChangeException {
ProfileKey profileKey2 = randomProfileKey();
ProfileKey profileKey3 = randomProfileKey();
DecryptedMember member1 = member(UUID.randomUUID());
UUID requesting2Uuid = UUID.randomUUID();
UUID requesting3Uuid = UUID.randomUUID();
UUID requesting4Uuid = UUID.randomUUID();
DecryptedRequestingMember requesting2 = requestingMember(requesting2Uuid);
DecryptedRequestingMember requesting3 = requestingMember(requesting3Uuid);
DecryptedRequestingMember requesting4 = requestingMember(requesting4Uuid);
DecryptedMember member2 = member(requesting2Uuid, profileKey2);
DecryptedMember member3 = member(requesting3Uuid, profileKey3);
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addRequestingMembers(requesting2).addRequestingMembers(requesting3).addRequestingMembers(requesting4).build(), DecryptedGroupChange.newBuilder().setRevision(11).addNewMembers(member2).addNewMembers(member3).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).addMembers(member2).addMembers(member3).addRequestingMembers(requesting4).build(), newGroup);
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
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.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class GroupChangeReconstructTest method to_member.
@Test
public void to_member() {
UUID uuid = UUID.randomUUID();
ProfileKey profileKey = randomProfileKey();
DecryptedGroup from = DecryptedGroup.newBuilder().addMembers(withProfileKey(admin(uuid), profileKey)).build();
DecryptedGroup to = DecryptedGroup.newBuilder().addMembers(withProfileKey(member(uuid), profileKey)).build();
DecryptedGroupChange decryptedGroupChange = GroupChangeReconstruct.reconstructGroupChange(from, to);
assertEquals(DecryptedGroupChange.newBuilder().addModifyMemberRoles(demoteAdmin(uuid)).build(), decryptedGroupChange);
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class GroupChangeReconstructTest method to_admin.
@Test
public void to_admin() {
UUID uuid = UUID.randomUUID();
ProfileKey profileKey = randomProfileKey();
DecryptedGroup from = DecryptedGroup.newBuilder().addMembers(withProfileKey(member(uuid), profileKey)).build();
DecryptedGroup to = DecryptedGroup.newBuilder().addMembers(withProfileKey(admin(uuid), profileKey)).build();
DecryptedGroupChange decryptedGroupChange = GroupChangeReconstruct.reconstructGroupChange(from, to);
assertEquals(DecryptedGroupChange.newBuilder().addModifyMemberRoles(promoteAdmin(uuid)).build(), decryptedGroupChange);
}
Aggregations