Search in sources :

Example 11 with DecryptedGroupChange

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

the class GroupChangeReconstructTest method avatar_change.

@Test
public void avatar_change() {
    DecryptedGroup from = DecryptedGroup.newBuilder().setAvatar("A").build();
    DecryptedGroup to = DecryptedGroup.newBuilder().setAvatar("B").build();
    DecryptedGroupChange decryptedGroupChange = GroupChangeReconstruct.reconstructGroupChange(from, to);
    assertEquals(DecryptedGroupChange.newBuilder().setNewAvatar(DecryptedString.newBuilder().setValue("B")).build(), decryptedGroupChange);
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 12 with DecryptedGroupChange

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

the class GroupChangeReconstructTest method timer_change.

@Test
public void timer_change() {
    DecryptedGroup from = DecryptedGroup.newBuilder().setDisappearingMessagesTimer(DecryptedTimer.newBuilder().setDuration(100)).build();
    DecryptedGroup to = DecryptedGroup.newBuilder().setDisappearingMessagesTimer(DecryptedTimer.newBuilder().setDuration(200)).build();
    DecryptedGroupChange decryptedGroupChange = GroupChangeReconstruct.reconstructGroupChange(from, to);
    assertEquals(DecryptedGroupChange.newBuilder().setNewTimer(DecryptedTimer.newBuilder().setDuration(200)).build(), decryptedGroupChange);
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 13 with DecryptedGroupChange

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

the class GroupChangeReconstructTest method new_requesting_members_ignores_existing_by_uuid.

@Test
public void new_requesting_members_ignores_existing_by_uuid() {
    UUID member1 = UUID.randomUUID();
    UUID member2 = UUID.randomUUID();
    ProfileKey profileKey2 = newProfileKey();
    DecryptedGroup from = DecryptedGroup.newBuilder().addRequestingMembers(requestingMember(member1, newProfileKey())).build();
    DecryptedGroup to = DecryptedGroup.newBuilder().addRequestingMembers(requestingMember(member1, newProfileKey())).addRequestingMembers(requestingMember(member2, profileKey2)).build();
    DecryptedGroupChange decryptedGroupChange = GroupChangeReconstruct.reconstructGroupChange(from, to);
    assertEquals(DecryptedGroupChange.newBuilder().addNewRequestingMembers(requestingMember(member2, profileKey2)).build(), decryptedGroupChange);
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) 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) Test(org.junit.Test)

Example 14 with DecryptedGroupChange

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

the class GroupChangeReconstructTest method announcement_group_change.

@Test
public void announcement_group_change() {
    DecryptedGroup from = DecryptedGroup.newBuilder().setIsAnnouncementGroup(EnabledState.DISABLED).build();
    DecryptedGroup to = DecryptedGroup.newBuilder().setIsAnnouncementGroup(EnabledState.ENABLED).build();
    DecryptedGroupChange decryptedGroupChange = GroupChangeReconstruct.reconstructGroupChange(from, to);
    assertEquals(DecryptedGroupChange.newBuilder().setNewIsAnnouncementGroup(EnabledState.ENABLED).build(), decryptedGroupChange);
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 15 with DecryptedGroupChange

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

the class GroupChangeReconstructTest method access_control_change_membership.

@Test
public void access_control_change_membership() {
    DecryptedGroup from = DecryptedGroup.newBuilder().setAccessControl(AccessControl.newBuilder().setMembers(AccessControl.AccessRequired.ADMINISTRATOR)).build();
    DecryptedGroup to = DecryptedGroup.newBuilder().setAccessControl(AccessControl.newBuilder().setMembers(AccessControl.AccessRequired.MEMBER)).build();
    DecryptedGroupChange decryptedGroupChange = GroupChangeReconstruct.reconstructGroupChange(from, to);
    assertEquals(DecryptedGroupChange.newBuilder().setNewMemberAccess(AccessControl.AccessRequired.MEMBER).build(), decryptedGroupChange);
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) 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