Search in sources :

Example 1 with NotAbleToApplyGroupV2ChangeException

use of org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException 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 NotAbleToApplyGroupV2ChangeException

use of org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException 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 3 with NotAbleToApplyGroupV2ChangeException

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

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);
}
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) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 4 with NotAbleToApplyGroupV2ChangeException

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

the class DecryptedGroupUtil_apply_Test method cant_apply_modify_member_profile_keys_if_member_not_in_group.

@Test(expected = NotAbleToApplyGroupV2ChangeException.class)
public void cant_apply_modify_member_profile_keys_if_member_not_in_group() throws NotAbleToApplyGroupV2ChangeException {
    ProfileKey profileKey1 = randomProfileKey();
    ProfileKey profileKey2a = randomProfileKey();
    ProfileKey profileKey2b = randomProfileKey();
    DecryptedMember member1 = member(UUID.randomUUID(), profileKey1);
    DecryptedMember member2a = member(UUID.randomUUID(), profileKey2a);
    DecryptedMember member2b = member(UUID.randomUUID(), profileKey2b);
    DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addMembers(member1).addMembers(member2a).build(), DecryptedGroupChange.newBuilder().setRevision(14).addModifiedProfileKeys(member2b).build());
}
Also used : 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 5 with NotAbleToApplyGroupV2ChangeException

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

the class DecryptedGroupUtil_apply_Test method apply_modify_member_profile_keys.

@Test
public void apply_modify_member_profile_keys() throws NotAbleToApplyGroupV2ChangeException {
    ProfileKey profileKey1 = randomProfileKey();
    ProfileKey profileKey2a = randomProfileKey();
    ProfileKey profileKey2b = randomProfileKey();
    DecryptedMember member1 = member(UUID.randomUUID(), profileKey1);
    DecryptedMember member2a = member(UUID.randomUUID(), profileKey2a);
    DecryptedMember member2b = withProfileKey(member2a, profileKey2b);
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addMembers(member1).addMembers(member2a).build(), DecryptedGroupChange.newBuilder().setRevision(14).addModifiedProfileKeys(member2b).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(14).addMembers(member1).addMembers(member2b).build(), newGroup);
}
Also used : 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