Search in sources :

Example 66 with DecryptedMember

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

the class DecryptedGroupUtilTest method can_extract_uuid_from_decrypted_member.

@Test
public void can_extract_uuid_from_decrypted_member() {
    UUID uuid = UUID.randomUUID();
    DecryptedMember decryptedMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(uuid)).build();
    UUID parsed = DecryptedGroupUtil.toUuid(decryptedMember);
    assertEquals(uuid, parsed);
}
Also used : UUID(java.util.UUID) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 67 with DecryptedMember

use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.

the class GroupStateMapperTest method updates_with_a_server_mismatch_inserts_additional_update.

@Test
public void updates_with_a_server_mismatch_inserts_additional_update() {
    DecryptedGroup currentState = state(6);
    ServerGroupLogEntry log7 = serverLogEntry(7);
    DecryptedMember newMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(UUID.randomUUID())).build();
    DecryptedGroup state7b = DecryptedGroup.newBuilder().setRevision(8).setTitle("Group Revision " + 8).build();
    DecryptedGroup state8 = DecryptedGroup.newBuilder().setRevision(8).setTitle("Group Revision " + 8).addMembers(newMember).build();
    ServerGroupLogEntry log8 = new ServerGroupLogEntry(state8, change(8));
    ServerGroupLogEntry log9 = new ServerGroupLogEntry(DecryptedGroup.newBuilder().setRevision(9).addMembers(newMember).setTitle("Group Revision " + 9).build(), change(9));
    AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, asList(log7, log8, log9)), LATEST);
    assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(asList(asLocal(log7), new LocalGroupLogEntry(state7b, log8.getChange()), new LocalGroupLogEntry(state8, DecryptedGroupChange.newBuilder().setRevision(8).addNewMembers(newMember).build()), asLocal(log9))));
    assertNewState(new GlobalGroupState(log9.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState());
    assertEquals(log9.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
Also used : DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 68 with DecryptedMember

use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.

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)

Example 69 with DecryptedMember

use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.

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)

Example 70 with DecryptedMember

use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.

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)

Aggregations

DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)80 Test (org.junit.Test)54 DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)48 UUID (java.util.UUID)32 DecryptedPendingMember (org.signal.storageservice.protos.groups.local.DecryptedPendingMember)20 ProfileKey (org.signal.zkgroup.profiles.ProfileKey)14 ProtoTestUtils.newProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey)14 ProtoTestUtils.randomProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey)14 ProtoTestUtils.withProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey)14 ByteString (com.google.protobuf.ByteString)12 DecryptedRequestingMember (org.signal.storageservice.protos.groups.local.DecryptedRequestingMember)12 DecryptedGroupChange (org.signal.storageservice.protos.groups.local.DecryptedGroupChange)10 NonNull (androidx.annotation.NonNull)6 WorkerThread (androidx.annotation.WorkerThread)6 DecryptedModifyMemberRole (org.signal.storageservice.protos.groups.local.DecryptedModifyMemberRole)6 Context (android.content.Context)4 DrawableRes (androidx.annotation.DrawableRes)4 Nullable (androidx.annotation.Nullable)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4