Search in sources :

Example 51 with DecryptedGroupChange

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

the class GroupChangeUtil_resolveConflict_decryptedOnly_Test method field_16__changes_to_add_requesting_members_when_pending_are_promoted.

@Test
public void field_16__changes_to_add_requesting_members_when_pending_are_promoted() {
    UUID member1 = UUID.randomUUID();
    UUID member2 = UUID.randomUUID();
    UUID member3 = UUID.randomUUID();
    ProfileKey profileKey1 = randomProfileKey();
    ProfileKey profileKey2 = randomProfileKey();
    ProfileKey profileKey3 = randomProfileKey();
    DecryptedGroup groupState = DecryptedGroup.newBuilder().addPendingMembers(pendingMember(member1)).addPendingMembers(pendingMember(member3)).build();
    DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().addNewRequestingMembers(requestingMember(member1, profileKey1)).addNewRequestingMembers(requestingMember(member2, profileKey2)).addNewRequestingMembers(requestingMember(member3, profileKey3)).build();
    DecryptedGroupChange resolvedChanges = GroupChangeUtil.resolveConflict(groupState, decryptedChange).build();
    DecryptedGroupChange expected = DecryptedGroupChange.newBuilder().addPromotePendingMembers(member(member1, profileKey1)).addNewRequestingMembers(requestingMember(member2, profileKey2)).addPromotePendingMembers(member(member3, profileKey3)).build();
    assertEquals(expected, resolvedChanges);
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) UUID(java.util.UUID) ProtoTestUtils.randomProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 52 with DecryptedGroupChange

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

the class DecryptedGroupUtilTest method can_extract_uuids_for_all_deleted_pending_excluding_bad_entries.

@Test
public void can_extract_uuids_for_all_deleted_pending_excluding_bad_entries() {
    UUID uuid1 = UUID.randomUUID();
    UUID uuid2 = UUID.randomUUID();
    DecryptedPendingMemberRemoval decryptedMember1 = DecryptedPendingMemberRemoval.newBuilder().setUuid(UuidUtil.toByteString(uuid1)).build();
    DecryptedPendingMemberRemoval decryptedMember2 = DecryptedPendingMemberRemoval.newBuilder().setUuid(UuidUtil.toByteString(uuid2)).build();
    DecryptedPendingMemberRemoval decryptedMember3 = DecryptedPendingMemberRemoval.newBuilder().setUuid(ByteString.copyFrom(Util.getSecretBytes(17))).build();
    DecryptedGroupChange groupChange = DecryptedGroupChange.newBuilder().addDeletePendingMembers(decryptedMember1).addDeletePendingMembers(decryptedMember2).addDeletePendingMembers(decryptedMember3).build();
    List<UUID> removedUuids = DecryptedGroupUtil.removedPendingMembersUuidList(groupChange);
    assertThat(removedUuids, is(asList(uuid1, uuid2)));
}
Also used : DecryptedPendingMemberRemoval(org.signal.storageservice.protos.groups.local.DecryptedPendingMemberRemoval) DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) UUID(java.util.UUID) Test(org.junit.Test)

Example 53 with DecryptedGroupChange

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

the class DecryptedGroupUtilTest method can_extract_uuids_for_all_deleted_members_excluding_bad_entries.

@Test
public void can_extract_uuids_for_all_deleted_members_excluding_bad_entries() {
    UUID uuid1 = UUID.randomUUID();
    UUID uuid2 = UUID.randomUUID();
    DecryptedGroupChange groupChange = DecryptedGroupChange.newBuilder().addDeleteMembers(UuidUtil.toByteString(uuid1)).addDeleteMembers(UuidUtil.toByteString(uuid2)).addDeleteMembers(ByteString.copyFrom(Util.getSecretBytes(17))).build();
    List<UUID> removedUuids = DecryptedGroupUtil.removedMembersUuidList(groupChange);
    assertThat(removedUuids, is(asList(uuid1, uuid2)));
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) UUID(java.util.UUID) Test(org.junit.Test)

Example 54 with DecryptedGroupChange

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

the class DecryptedGroupUtilTest method can_extract_editor_uuid_from_decrypted_group_change.

@Test
public void can_extract_editor_uuid_from_decrypted_group_change() {
    UUID uuid = UUID.randomUUID();
    ByteString editor = UuidUtil.toByteString(uuid);
    DecryptedGroupChange groupChange = DecryptedGroupChange.newBuilder().setEditor(editor).build();
    UUID parsed = DecryptedGroupUtil.editorUuid(groupChange).get();
    assertEquals(uuid, parsed);
}
Also used : ByteString(com.google.protobuf.ByteString) DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) UUID(java.util.UUID) Test(org.junit.Test)

Example 55 with DecryptedGroupChange

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

the class DecryptedGroupUtil_empty_Test method not_empty_with_a_delete_requesting_member_field_17.

@Test
public void not_empty_with_a_delete_requesting_member_field_17() {
    DecryptedGroupChange change = DecryptedGroupChange.newBuilder().addDeleteRequestingMembers(ByteString.copyFrom(new byte[16])).build();
    assertFalse(DecryptedGroupUtil.changeIsEmpty(change));
    assertFalse(DecryptedGroupUtil.changeIsEmptyExceptForProfileKeyChanges(change));
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) Test(org.junit.Test)

Aggregations

DecryptedGroupChange (org.signal.storageservice.protos.groups.local.DecryptedGroupChange)486 Test (org.junit.Test)460 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)234 DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)190 UUID (java.util.UUID)110 GroupChange (org.signal.storageservice.protos.groups.GroupChange)62 ProfileKey (org.signal.zkgroup.profiles.ProfileKey)34 ProtoTestUtils.randomProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey)34 ByteString (com.google.protobuf.ByteString)18 DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)14 NonNull (androidx.annotation.NonNull)12 DecryptedPendingMember (org.signal.storageservice.protos.groups.local.DecryptedPendingMember)12 DecryptedGroupV2Context (org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context)12 ProtoTestUtils.newProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey)12 ProtoTestUtils.withProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey)12 DecryptedPendingMemberRemoval (org.signal.storageservice.protos.groups.local.DecryptedPendingMemberRemoval)10 DecryptedRequestingMember (org.signal.storageservice.protos.groups.local.DecryptedRequestingMember)10 Context (android.content.Context)8 DrawableRes (androidx.annotation.DrawableRes)8 Nullable (androidx.annotation.Nullable)8