Search in sources :

Example 1 with DecryptedGroup

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

the class DecryptedGroupUtil_apply_Test method cannot_remove_pending_member_if_not_in_group.

@Test
public void cannot_remove_pending_member_if_not_in_group() throws NotAbleToApplyGroupV2ChangeException {
    DecryptedMember member1 = member(UUID.randomUUID());
    UUID pendingUuid = UUID.randomUUID();
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).build(), DecryptedGroupChange.newBuilder().setRevision(11).addDeletePendingMembers(DecryptedPendingMemberRemoval.newBuilder().setUuidCipherText(ProtoTestUtils.encrypt(pendingUuid)).build()).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).build(), newGroup);
}
Also used : UUID(java.util.UUID) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 2 with DecryptedGroup

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

the class DecryptedGroupUtil_apply_Test method change_both_access_levels.

@Test
public void change_both_access_levels() throws NotAbleToApplyGroupV2ChangeException {
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).setAccessControl(AccessControl.newBuilder().setAttributes(AccessControl.AccessRequired.ADMINISTRATOR).setMembers(AccessControl.AccessRequired.MEMBER).build()).build(), DecryptedGroupChange.newBuilder().setRevision(11).setNewAttributeAccess(AccessControl.AccessRequired.MEMBER).setNewMemberAccess(AccessControl.AccessRequired.ADMINISTRATOR).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(11).setAccessControl(AccessControl.newBuilder().setAttributes(AccessControl.AccessRequired.MEMBER).setMembers(AccessControl.AccessRequired.ADMINISTRATOR).build()).build(), newGroup);
}
Also used : DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 3 with DecryptedGroup

use of org.signal.storageservice.protos.groups.local.DecryptedGroup 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 4 with DecryptedGroup

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

the class DecryptedGroupUtil_apply_Test method apply_new_member_already_in_the_group_by_uuid.

@Test
public void apply_new_member_already_in_the_group_by_uuid() throws NotAbleToApplyGroupV2ChangeException {
    DecryptedMember member1 = member(UUID.randomUUID());
    UUID member2Uuid = UUID.randomUUID();
    DecryptedMember member2a = member(member2Uuid, newProfileKey());
    DecryptedMember member2b = member(member2Uuid, newProfileKey());
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addMembers(member2a).build(), DecryptedGroupChange.newBuilder().setRevision(11).addNewMembers(member2b).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).addMembers(member2b).build(), newGroup);
}
Also used : UUID(java.util.UUID) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 5 with DecryptedGroup

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

the class DecryptedGroupUtil_apply_Test method remove_pending_member.

@Test
public void remove_pending_member() throws NotAbleToApplyGroupV2ChangeException {
    DecryptedMember member1 = member(UUID.randomUUID());
    UUID pendingUuid = UUID.randomUUID();
    DecryptedPendingMember pending = pendingMember(pendingUuid);
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addPendingMembers(pending).build(), DecryptedGroupChange.newBuilder().setRevision(11).addDeletePendingMembers(DecryptedPendingMemberRemoval.newBuilder().setUuidCipherText(ProtoTestUtils.encrypt(pendingUuid)).build()).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).build(), newGroup);
}
Also used : DecryptedPendingMember(org.signal.storageservice.protos.groups.local.DecryptedPendingMember) UUID(java.util.UUID) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Aggregations

DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)328 Test (org.junit.Test)306 DecryptedGroupChange (org.signal.storageservice.protos.groups.local.DecryptedGroupChange)182 UUID (java.util.UUID)110 GroupChange (org.signal.storageservice.protos.groups.GroupChange)58 ProfileKey (org.signal.zkgroup.profiles.ProfileKey)50 ProtoTestUtils.randomProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey)46 DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)44 ProtoTestUtils.newProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey)24 ProtoTestUtils.withProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey)24 Group (org.signal.storageservice.protos.groups.Group)22 ByteString (com.google.protobuf.ByteString)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 DecryptedPendingMember (org.signal.storageservice.protos.groups.local.DecryptedPendingMember)12 DecryptedRequestingMember (org.signal.storageservice.protos.groups.local.DecryptedRequestingMember)8 NonNull (androidx.annotation.NonNull)6 ArrayList (java.util.ArrayList)6 GroupDatabase (org.thoughtcrime.securesms.database.GroupDatabase)6 Nullable (androidx.annotation.Nullable)4 WorkerThread (androidx.annotation.WorkerThread)4