Search in sources :

Example 41 with ProfileKey

use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by WhisperSystems.

the class ProfileKeySetTest method new_requesting_member_if_not_editor_is_not_authoritative.

@Test
public void new_requesting_member_if_not_editor_is_not_authoritative() {
    UUID editor = UUID.randomUUID();
    UUID requesting = UUID.randomUUID();
    ProfileKey profileKey = ProfileKeyUtil.createNew();
    ProfileKeySet profileKeySet = new ProfileKeySet();
    profileKeySet.addKeysFromGroupChange(changeBy(editor).requestJoin(requesting, profileKey).build());
    assertTrue(profileKeySet.getAuthoritativeProfileKeys().isEmpty());
    assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ACI.from(requesting), profileKey)));
}
Also used : UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) Test(org.junit.Test)

Example 42 with ProfileKey

use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by WhisperSystems.

the class ProfileKeySetTest method new_requesting_member_if_editor_is_authoritative.

@Test
public void new_requesting_member_if_editor_is_authoritative() {
    UUID editor = UUID.randomUUID();
    ProfileKey profileKey = ProfileKeyUtil.createNew();
    ProfileKeySet profileKeySet = new ProfileKeySet();
    profileKeySet.addKeysFromGroupChange(changeBy(editor).requestJoin(profileKey).build());
    assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ACI.from(editor), profileKey)));
    assertTrue(profileKeySet.getProfileKeys().isEmpty());
}
Also used : UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) Test(org.junit.Test)

Example 43 with ProfileKey

use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by WhisperSystems.

the class ProfileKeySetTest method multiple_updates_overwrite.

@Test
public void multiple_updates_overwrite() {
    UUID editor = UUID.randomUUID();
    UUID member = UUID.randomUUID();
    ProfileKey profileKey1 = ProfileKeyUtil.createNew();
    ProfileKey profileKey2 = ProfileKeyUtil.createNew();
    ProfileKeySet profileKeySet = new ProfileKeySet();
    profileKeySet.addKeysFromGroupChange(changeBy(editor).profileKeyUpdate(member, profileKey1).build());
    profileKeySet.addKeysFromGroupChange(changeBy(editor).profileKeyUpdate(member, profileKey2).build());
    assertTrue(profileKeySet.getAuthoritativeProfileKeys().isEmpty());
    assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ACI.from(member), profileKey2)));
}
Also used : UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) Test(org.junit.Test)

Example 44 with ProfileKey

use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by WhisperSystems.

the class ProfileKeySetTest method new_member_is_not_authoritative.

@Test
public void new_member_is_not_authoritative() {
    UUID editor = UUID.randomUUID();
    UUID newMember = UUID.randomUUID();
    ProfileKey profileKey = ProfileKeyUtil.createNew();
    ProfileKeySet profileKeySet = new ProfileKeySet();
    profileKeySet.addKeysFromGroupChange(changeBy(editor).addMember(newMember, profileKey).build());
    assertTrue(profileKeySet.getAuthoritativeProfileKeys().isEmpty());
    assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ACI.from(newMember), profileKey)));
}
Also used : UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) Test(org.junit.Test)

Example 45 with ProfileKey

use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by WhisperSystems.

the class ProfileKeySetTest method new_member_by_self_promote_is_authoritative.

@Test
public void new_member_by_self_promote_is_authoritative() {
    UUID newMember = UUID.randomUUID();
    ProfileKey profileKey = ProfileKeyUtil.createNew();
    ProfileKeySet profileKeySet = new ProfileKeySet();
    profileKeySet.addKeysFromGroupChange(changeBy(newMember).promote(newMember, profileKey).build());
    assertTrue(profileKeySet.getProfileKeys().isEmpty());
    assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ACI.from(newMember), profileKey)));
}
Also used : UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) Test(org.junit.Test)

Aggregations

ProfileKey (org.signal.zkgroup.profiles.ProfileKey)150 Test (org.junit.Test)102 UUID (java.util.UUID)90 DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)50 ProtoTestUtils.randomProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey)50 DecryptedGroupChange (org.signal.storageservice.protos.groups.local.DecryptedGroupChange)34 ProtoTestUtils.newProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey)28 ProtoTestUtils.withProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey)28 IOException (java.io.IOException)24 GroupChange (org.signal.storageservice.protos.groups.GroupChange)14 DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)14 InvalidCiphertextException (org.whispersystems.signalservice.api.crypto.InvalidCiphertextException)12 InvalidInputException (org.signal.zkgroup.InvalidInputException)8 ProfileKeyCredential (org.signal.zkgroup.profiles.ProfileKeyCredential)8 Recipient (org.thoughtcrime.securesms.recipients.Recipient)8 InvalidKeyException (org.whispersystems.libsignal.InvalidKeyException)8 NonNull (androidx.annotation.NonNull)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 RecipientDatabase (org.thoughtcrime.securesms.database.RecipientDatabase)6 IdentityKey (org.whispersystems.libsignal.IdentityKey)6