Search in sources :

Example 31 with DecryptedGroup

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

the class GroupChangeUtil_resolveConflict_Test method field_12__timer_change_is_preserved.

@Test
public void field_12__timer_change_is_preserved() {
    DecryptedGroup groupState = DecryptedGroup.newBuilder().setDisappearingMessagesTimer(DecryptedTimer.newBuilder().setDuration(123)).build();
    DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().setNewTimer(DecryptedTimer.newBuilder().setDuration(456)).build();
    GroupChange.Actions change = GroupChange.Actions.newBuilder().setModifyDisappearingMessagesTimer(GroupChange.Actions.ModifyDisappearingMessagesTimerAction.newBuilder().setTimer(ByteString.EMPTY)).build();
    GroupChange.Actions resolvedActions = GroupChangeUtil.resolveConflict(groupState, decryptedChange, change).build();
    assertEquals(change, resolvedActions);
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) GroupChange(org.signal.storageservice.protos.groups.GroupChange) DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 32 with DecryptedGroup

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

the class GroupChangeUtil_resolveConflict_Test method field_7__add_pending_members.

@Test
public void field_7__add_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(member3)).build();
    DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().addNewPendingMembers(pendingMember(member1)).addNewPendingMembers(pendingMember(member2)).addNewPendingMembers(pendingMember(member3)).build();
    GroupChange.Actions change = GroupChange.Actions.newBuilder().addAddPendingMembers(GroupChange.Actions.AddPendingMemberAction.newBuilder().setAdded(PendingMember.newBuilder().setMember(encryptedMember(member1, randomProfileKey())))).addAddPendingMembers(GroupChange.Actions.AddPendingMemberAction.newBuilder().setAdded(PendingMember.newBuilder().setMember(encryptedMember(member2, profileKey2)))).addAddPendingMembers(GroupChange.Actions.AddPendingMemberAction.newBuilder().setAdded(PendingMember.newBuilder().setMember(encryptedMember(member3, randomProfileKey())))).build();
    GroupChange.Actions resolvedActions = GroupChangeUtil.resolveConflict(groupState, decryptedChange, change).build();
    GroupChange.Actions expected = GroupChange.Actions.newBuilder().addAddPendingMembers(GroupChange.Actions.AddPendingMemberAction.newBuilder().setAdded(PendingMember.newBuilder().setMember(encryptedMember(member2, profileKey2)))).build();
    assertEquals(expected, resolvedActions);
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) GroupChange(org.signal.storageservice.protos.groups.GroupChange) DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) ProtoTestUtils.randomProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 33 with DecryptedGroup

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

the class DecryptedGroupUtil_apply_Test method attribute_access.

@Test
public void attribute_access() throws NotAbleToApplyGroupV2ChangeException {
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).setAccessControl(AccessControl.newBuilder().setAttributes(AccessControl.AccessRequired.ADMINISTRATOR).setMembers(AccessControl.AccessRequired.MEMBER).build()).build(), DecryptedGroupChange.newBuilder().setRevision(11).setNewAttributeAccess(AccessControl.AccessRequired.MEMBER).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(11).setAccessControl(AccessControl.newBuilder().setAttributes(AccessControl.AccessRequired.MEMBER).setMembers(AccessControl.AccessRequired.MEMBER).build()).build(), newGroup);
}
Also used : DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 34 with DecryptedGroup

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

the class DecryptedGroupUtil_apply_Test method title.

@Test
public void title() throws NotAbleToApplyGroupV2ChangeException {
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).setTitle("Old title").build(), DecryptedGroupChange.newBuilder().setRevision(11).setNewTitle(DecryptedString.newBuilder().setValue("New title").build()).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(11).setTitle("New title").build(), newGroup);
}
Also used : DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 35 with DecryptedGroup

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

the class DecryptedGroupUtil_apply_Test method invite_link_password.

@Test
public void invite_link_password() throws NotAbleToApplyGroupV2ChangeException {
    ByteString password1 = ByteString.copyFrom(Util.getSecretBytes(16));
    ByteString password2 = ByteString.copyFrom(Util.getSecretBytes(16));
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).setInviteLinkPassword(password1).build(), DecryptedGroupChange.newBuilder().setRevision(11).setNewInviteLinkPassword(password2).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(11).setInviteLinkPassword(password2).build(), newGroup);
}
Also used : ByteString(com.google.protobuf.ByteString) 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