Search in sources :

Example 6 with DecryptedMember

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

the class GroupStateMapperTest method notices_changes_in_avatar_and_title_but_not_members_in_placeholder.

@Test
public void notices_changes_in_avatar_and_title_but_not_members_in_placeholder() {
    UUID newMemberUuid = UUID.randomUUID();
    DecryptedMember newMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(newMemberUuid)).build();
    DecryptedMember existingMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(UUID.randomUUID())).build();
    DecryptedGroup currentState = DecryptedGroup.newBuilder().setRevision(GroupStateMapper.PLACEHOLDER_REVISION).setTitle("Incorrect group title").setAvatar("Incorrect group avatar").addMembers(newMember).build();
    ServerGroupLogEntry log8 = new ServerGroupLogEntry(DecryptedGroup.newBuilder().setRevision(8).addMembers(newMember).addMembers(existingMember).setTitle("Group Revision " + 8).setAvatar("Group Avatar " + 8).build(), DecryptedGroupChange.newBuilder().setRevision(8).setEditor(UuidUtil.toByteString(newMemberUuid)).addNewMembers(newMember).build());
    DecryptedGroupChange expectedChange = DecryptedGroupChange.newBuilder().setRevision(8).setNewTitle(DecryptedString.newBuilder().setValue("Group Revision " + 8)).setNewAvatar(DecryptedString.newBuilder().setValue("Group Avatar " + 8)).build();
    AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, singletonList(log8)), LATEST);
    assertNotNull(log8.getGroup());
    assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(singletonList(new LocalGroupLogEntry(log8.getGroup(), expectedChange))));
    assertNewState(new GlobalGroupState(log8.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState());
    assertEquals(log8.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) 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 7 with DecryptedMember

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

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)

Example 8 with DecryptedMember

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

the class DecryptedGroupUtil_apply_Test method apply_new_member.

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

Example 9 with DecryptedMember

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

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 10 with DecryptedMember

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

the class DecryptedGroupUtil_apply_Test method apply_new_pending_member_already_in_group.

@Test(expected = NotAbleToApplyGroupV2ChangeException.class)
public void apply_new_pending_member_already_in_group() throws NotAbleToApplyGroupV2ChangeException {
    DecryptedMember member1 = member(UUID.randomUUID());
    UUID uuid2 = UUID.randomUUID();
    DecryptedMember member2 = member(uuid2);
    DecryptedPendingMember pending2 = pendingMember(uuid2);
    DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addMembers(member2).build(), DecryptedGroupChange.newBuilder().setRevision(11).addNewPendingMembers(pending2).build());
}
Also used : DecryptedPendingMember(org.signal.storageservice.protos.groups.local.DecryptedPendingMember) UUID(java.util.UUID) 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