use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class GroupChangeUtil_resolveConflict_Test method field_3_to_9__add_of_pending_member_converted_to_a_promote.
@Test
public void field_3_to_9__add_of_pending_member_converted_to_a_promote() {
UUID member1 = UUID.randomUUID();
ProfileKey profileKey1 = randomProfileKey();
DecryptedGroup groupState = DecryptedGroup.newBuilder().addPendingMembers(pendingMember(member1)).build();
DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().addNewMembers(member(member1)).build();
GroupChange.Actions change = GroupChange.Actions.newBuilder().addAddMembers(GroupChange.Actions.AddMemberAction.newBuilder().setAdded(encryptedMember(member1, profileKey1))).build();
GroupChange.Actions resolvedActions = GroupChangeUtil.resolveConflict(groupState, decryptedChange, change).build();
GroupChange.Actions expected = GroupChange.Actions.newBuilder().addPromotePendingMembers(GroupChange.Actions.PromotePendingMemberAction.newBuilder().setPresentation(presentation(member1, profileKey1))).build();
assertEquals(expected, resolvedActions);
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class GroupsV2Operations_decrypt_change_Test method can_decrypt_promote_pending_member_field9.
@Test
public void can_decrypt_promote_pending_member_field9() {
UUID newMember = UUID.randomUUID();
ProfileKey profileKey = newProfileKey();
GroupCandidate groupCandidate = groupCandidate(newMember, profileKey);
assertDecryption(groupOperations.createAcceptInviteChange(groupCandidate.getProfileKeyCredential().get()), DecryptedGroupChange.newBuilder().addPromotePendingMembers(DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(newMember)).setRole(Member.Role.DEFAULT).setProfileKey(ByteString.copyFrom(profileKey.serialize())).setJoinedAtRevision(-1)));
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class GroupsV2Operations_decrypt_group_Test method decrypt_full_members_field_7.
@Test
public void decrypt_full_members_field_7() throws VerificationFailedException, InvalidGroupStateException {
UUID admin1 = UUID.randomUUID();
UUID member1 = UUID.randomUUID();
ProfileKey adminProfileKey = newProfileKey();
ProfileKey memberProfileKey = newProfileKey();
Group group = Group.newBuilder().addMembers(Member.newBuilder().setRole(Member.Role.ADMINISTRATOR).setUserId(groupOperations.encryptUuid(admin1)).setJoinedAtRevision(4).setProfileKey(encryptProfileKey(admin1, adminProfileKey))).addMembers(Member.newBuilder().setRole(Member.Role.DEFAULT).setUserId(groupOperations.encryptUuid(member1)).setJoinedAtRevision(7).setProfileKey(encryptProfileKey(member1, memberProfileKey))).build();
DecryptedGroup decryptedGroup = groupOperations.decryptGroup(group);
assertEquals(DecryptedGroup.newBuilder().addMembers(DecryptedMember.newBuilder().setJoinedAtRevision(4).setUuid(UuidUtil.toByteString(admin1)).setRole(Member.Role.ADMINISTRATOR).setProfileKey(ByteString.copyFrom(adminProfileKey.serialize()))).addMembers(DecryptedMember.newBuilder().setJoinedAtRevision(7).setRole(Member.Role.DEFAULT).setUuid(UuidUtil.toByteString(member1)).setProfileKey(ByteString.copyFrom(memberProfileKey.serialize()))).build().getMembersList(), decryptedGroup.getMembersList());
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class GroupsV2Operations_decrypt_group_Test method decrypt_requesting_members_field_9.
@Test
public void decrypt_requesting_members_field_9() throws VerificationFailedException, InvalidGroupStateException {
UUID admin1 = UUID.randomUUID();
UUID member1 = UUID.randomUUID();
ProfileKey adminProfileKey = newProfileKey();
ProfileKey memberProfileKey = newProfileKey();
Group group = Group.newBuilder().addRequestingMembers(RequestingMember.newBuilder().setUserId(groupOperations.encryptUuid(admin1)).setProfileKey(encryptProfileKey(admin1, adminProfileKey)).setTimestamp(5000)).addRequestingMembers(RequestingMember.newBuilder().setUserId(groupOperations.encryptUuid(member1)).setProfileKey(encryptProfileKey(member1, memberProfileKey)).setTimestamp(15000)).build();
DecryptedGroup decryptedGroup = groupOperations.decryptGroup(group);
assertEquals(DecryptedGroup.newBuilder().addRequestingMembers(DecryptedRequestingMember.newBuilder().setUuid(UuidUtil.toByteString(admin1)).setProfileKey(ByteString.copyFrom(adminProfileKey.serialize())).setTimestamp(5000)).addRequestingMembers(DecryptedRequestingMember.newBuilder().setUuid(UuidUtil.toByteString(member1)).setProfileKey(ByteString.copyFrom(memberProfileKey.serialize())).setTimestamp(15000)).build().getRequestingMembersList(), decryptedGroup.getRequestingMembersList());
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class GroupsV2Operations_decrypt_change_Test method can_decrypt_member_additions_direct_to_admin_field3.
@Test
public void can_decrypt_member_additions_direct_to_admin_field3() {
UUID self = UUID.randomUUID();
UUID newMember = UUID.randomUUID();
ProfileKey profileKey = newProfileKey();
GroupCandidate groupCandidate = groupCandidate(newMember, profileKey);
assertDecryption(groupOperations.createModifyGroupMembershipChange(Collections.singleton(groupCandidate), self).setRevision(10), DecryptedGroupChange.newBuilder().setRevision(10).addNewMembers(DecryptedMember.newBuilder().setRole(Member.Role.DEFAULT).setProfileKey(ByteString.copyFrom(profileKey.serialize())).setJoinedAtRevision(10).setUuid(UuidUtil.toByteString(newMember))));
}
Aggregations