Search in sources :

Example 6 with NotAbleToApplyGroupV2ChangeException

use of org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException 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);
}
Also used : DecryptedPendingMember(org.signal.storageservice.protos.groups.local.DecryptedPendingMember) 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 7 with NotAbleToApplyGroupV2ChangeException

use of org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException 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());
}
Also used : 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) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 8 with NotAbleToApplyGroupV2ChangeException

use of org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException in project Signal-Android by WhisperSystems.

the class DecryptedGroupUtil_apply_Test method promote_pending_member.

@Test
public void promote_pending_member() throws NotAbleToApplyGroupV2ChangeException {
    ProfileKey profileKey2 = randomProfileKey();
    DecryptedMember member1 = member(UUID.randomUUID());
    UUID pending2Uuid = UUID.randomUUID();
    DecryptedPendingMember pending2 = pendingMember(pending2Uuid);
    DecryptedMember member2 = member(pending2Uuid, profileKey2);
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addPendingMembers(pending2).build(), DecryptedGroupChange.newBuilder().setRevision(11).addPromotePendingMembers(member2).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).addMembers(member2).build(), newGroup);
}
Also used : DecryptedPendingMember(org.signal.storageservice.protos.groups.local.DecryptedPendingMember) 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)

Aggregations

Test (org.junit.Test)8 ProfileKey (org.signal.zkgroup.profiles.ProfileKey)8 ProtoTestUtils.newProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey)8 ProtoTestUtils.randomProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey)8 ProtoTestUtils.withProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey)8 DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)7 UUID (java.util.UUID)6 DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)6 DecryptedPendingMember (org.signal.storageservice.protos.groups.local.DecryptedPendingMember)2 DecryptedRequestingMember (org.signal.storageservice.protos.groups.local.DecryptedRequestingMember)2