Search in sources :

Example 1 with DecryptedRequestingMember

use of org.signal.storageservice.protos.groups.local.DecryptedRequestingMember in project Signal-Android by WhisperSystems.

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);
}
Also used : DecryptedRequestingMember(org.signal.storageservice.protos.groups.local.DecryptedRequestingMember) UUID(java.util.UUID) ProtoTestUtils.withProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) ProtoTestUtils.randomProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey) ProtoTestUtils.newProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 2 with DecryptedRequestingMember

use of org.signal.storageservice.protos.groups.local.DecryptedRequestingMember 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);
}
Also used : DecryptedRequestingMember(org.signal.storageservice.protos.groups.local.DecryptedRequestingMember) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 3 with DecryptedRequestingMember

use of org.signal.storageservice.protos.groups.local.DecryptedRequestingMember 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);
}
Also used : DecryptedRequestingMember(org.signal.storageservice.protos.groups.local.DecryptedRequestingMember) UUID(java.util.UUID) ProtoTestUtils.withProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) ProtoTestUtils.randomProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey) ProtoTestUtils.newProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 4 with DecryptedRequestingMember

use of org.signal.storageservice.protos.groups.local.DecryptedRequestingMember in project Signal-Android by WhisperSystems.

the class DecryptedGroupChangeActionsBuilderChangeSetModifier method moveAddRequestingMembersToPromote.

@Override
public void moveAddRequestingMembersToPromote(int i) {
    DecryptedRequestingMember addMemberAction = result.getNewRequestingMembersList().get(i);
    result.removeNewRequestingMembers(i);
    DecryptedMember build = DecryptedMember.newBuilder().setUuid(addMemberAction.getUuid()).setProfileKey(addMemberAction.getProfileKey()).setRole(Member.Role.DEFAULT).build();
    result.addPromotePendingMembers(0, build);
}
Also used : DecryptedRequestingMember(org.signal.storageservice.protos.groups.local.DecryptedRequestingMember) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember)

Example 5 with DecryptedRequestingMember

use of org.signal.storageservice.protos.groups.local.DecryptedRequestingMember in project Signal-Android by WhisperSystems.

the class DecryptedGroupUtil method applyPromoteRequestingMemberActions.

private static void applyPromoteRequestingMemberActions(DecryptedGroup.Builder builder, List<DecryptedApproveMember> promoteRequestingMembers) throws NotAbleToApplyGroupV2ChangeException {
    for (DecryptedApproveMember approvedMember : promoteRequestingMembers) {
        int index = indexOfUuidInRequestingList(builder.getRequestingMembersList(), approvedMember.getUuid());
        if (index == -1) {
            Log.w(TAG, "Deleted member on change not found in group");
            continue;
        }
        DecryptedRequestingMember requestingMember = builder.getRequestingMembers(index);
        Member.Role role = approvedMember.getRole();
        ensureKnownRole(role);
        builder.removeRequestingMembers(index).addMembers(DecryptedMember.newBuilder().setUuid(approvedMember.getUuid()).setProfileKey(requestingMember.getProfileKey()).setRole(role));
    }
}
Also used : DecryptedApproveMember(org.signal.storageservice.protos.groups.local.DecryptedApproveMember) DecryptedRequestingMember(org.signal.storageservice.protos.groups.local.DecryptedRequestingMember) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) DecryptedPendingMember(org.signal.storageservice.protos.groups.local.DecryptedPendingMember) Member(org.signal.storageservice.protos.groups.Member) DecryptedApproveMember(org.signal.storageservice.protos.groups.local.DecryptedApproveMember) DecryptedRequestingMember(org.signal.storageservice.protos.groups.local.DecryptedRequestingMember)

Aggregations

DecryptedRequestingMember (org.signal.storageservice.protos.groups.local.DecryptedRequestingMember)9 Test (org.junit.Test)5 DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)5 DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)4 UUID (java.util.UUID)3 DecryptedPendingMember (org.signal.storageservice.protos.groups.local.DecryptedPendingMember)3 ByteString (com.google.protobuf.ByteString)2 ProfileKey (org.signal.zkgroup.profiles.ProfileKey)2 ProtoTestUtils.newProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey)2 ProtoTestUtils.randomProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey)2 ProtoTestUtils.withProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey)2 HashMap (java.util.HashMap)1 Member (org.signal.storageservice.protos.groups.Member)1 DecryptedApproveMember (org.signal.storageservice.protos.groups.local.DecryptedApproveMember)1 DecryptedGroupChange (org.signal.storageservice.protos.groups.local.DecryptedGroupChange)1