Search in sources :

Example 61 with DecryptedGroup

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

the class GroupChangeUtil_resolveConflict_decryptedOnly_Test method field_19__password_change_is_kept.

@Test
public void field_19__password_change_is_kept() {
    ByteString password1 = ByteString.copyFrom(Util.getSecretBytes(16));
    ByteString password2 = ByteString.copyFrom(Util.getSecretBytes(16));
    DecryptedGroup groupState = DecryptedGroup.newBuilder().setInviteLinkPassword(password1).build();
    DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().setNewInviteLinkPassword(password2).build();
    DecryptedGroupChange resolvedChanges = GroupChangeUtil.resolveConflict(groupState, decryptedChange).build();
    assertEquals(decryptedChange, resolvedChanges);
}
Also used : ByteString(com.google.protobuf.ByteString) DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 62 with DecryptedGroup

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

the class GroupChangeUtil_resolveConflict_decryptedOnly_Test method field_17__changes_to_remove_missing_requesting_members_are_excluded.

@Test
public void field_17__changes_to_remove_missing_requesting_members_are_excluded() {
    UUID member1 = UUID.randomUUID();
    UUID member2 = UUID.randomUUID();
    UUID member3 = UUID.randomUUID();
    DecryptedGroup groupState = DecryptedGroup.newBuilder().addRequestingMembers(requestingMember(member2)).build();
    DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().addDeleteRequestingMembers(UuidUtil.toByteString(member1)).addDeleteRequestingMembers(UuidUtil.toByteString(member2)).addDeleteRequestingMembers(UuidUtil.toByteString(member3)).build();
    DecryptedGroupChange resolvedChanges = GroupChangeUtil.resolveConflict(groupState, decryptedChange).build();
    DecryptedGroupChange expected = DecryptedGroupChange.newBuilder().addDeleteRequestingMembers(UuidUtil.toByteString(member2)).build();
    assertEquals(expected, resolvedChanges);
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) UUID(java.util.UUID) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 63 with DecryptedGroup

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

the class GroupChangeUtil_resolveConflict_decryptedOnly_Test method field_9__promote_pending_members.

@Test
public void field_9__promote_pending_members() {
    UUID member1 = UUID.randomUUID();
    UUID member2 = UUID.randomUUID();
    UUID member3 = UUID.randomUUID();
    ProfileKey profileKey2 = randomProfileKey();
    DecryptedGroup groupState = DecryptedGroup.newBuilder().addMembers(member(member1)).addPendingMembers(pendingMember(member2)).build();
    DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().addPromotePendingMembers(member(member1)).addPromotePendingMembers(member(member2, profileKey2)).addPromotePendingMembers(member(member3)).build();
    DecryptedGroupChange resolvedChanges = GroupChangeUtil.resolveConflict(groupState, decryptedChange).build();
    DecryptedGroupChange expected = DecryptedGroupChange.newBuilder().addPromotePendingMembers(member(member2, profileKey2)).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 64 with DecryptedGroup

use of org.signal.storageservice.protos.groups.local.DecryptedGroup 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 65 with DecryptedGroup

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

the class GroupChangeUtil_resolveConflict_decryptedOnly_Test method field_5__unnecessary_role_changes_removed.

@Test
public void field_5__unnecessary_role_changes_removed() {
    UUID member1 = UUID.randomUUID();
    UUID member2 = UUID.randomUUID();
    UUID member3 = UUID.randomUUID();
    UUID memberNotInGroup = UUID.randomUUID();
    DecryptedGroup groupState = DecryptedGroup.newBuilder().addMembers(admin(member1)).addMembers(member(member2)).addMembers(member(member3)).build();
    DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().addModifyMemberRoles(promoteAdmin(member1)).addModifyMemberRoles(promoteAdmin(member2)).addModifyMemberRoles(demoteAdmin(member3)).addModifyMemberRoles(promoteAdmin(memberNotInGroup)).build();
    DecryptedGroupChange resolvedChanges = GroupChangeUtil.resolveConflict(groupState, decryptedChange).build();
    DecryptedGroupChange expected = DecryptedGroupChange.newBuilder().addModifyMemberRoles(promoteAdmin(member2)).build();
    assertEquals(expected, resolvedChanges);
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) UUID(java.util.UUID) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Aggregations

DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)328 Test (org.junit.Test)306 DecryptedGroupChange (org.signal.storageservice.protos.groups.local.DecryptedGroupChange)182 UUID (java.util.UUID)110 GroupChange (org.signal.storageservice.protos.groups.GroupChange)58 ProfileKey (org.signal.zkgroup.profiles.ProfileKey)50 ProtoTestUtils.randomProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey)46 DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)44 ProtoTestUtils.newProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey)24 ProtoTestUtils.withProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey)24 Group (org.signal.storageservice.protos.groups.Group)22 ByteString (com.google.protobuf.ByteString)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 DecryptedPendingMember (org.signal.storageservice.protos.groups.local.DecryptedPendingMember)12 DecryptedRequestingMember (org.signal.storageservice.protos.groups.local.DecryptedRequestingMember)8 NonNull (androidx.annotation.NonNull)6 ArrayList (java.util.ArrayList)6 GroupDatabase (org.thoughtcrime.securesms.database.GroupDatabase)6 Nullable (androidx.annotation.Nullable)4 WorkerThread (androidx.annotation.WorkerThread)4