Search in sources :

Example 86 with ProfileKey

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

the class ProfileKeySetTest method authoritative_takes_priority_when_seen_first.

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

Example 87 with ProfileKey

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

the class ProfileKeySetTest method new_member_by_promote_by_unknown_editor_is_not_authoritative.

@Test
public void new_member_by_promote_by_unknown_editor_is_not_authoritative() {
    UUID newMember = UUID.randomUUID();
    ProfileKey profileKey = ProfileKeyUtil.createNew();
    ProfileKeySet profileKeySet = new ProfileKeySet();
    profileKeySet.addKeysFromGroupChange(changeByUnknown().promote(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 88 with ProfileKey

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

the class ProfileKeySetTest method new_member_by_promote_by_other_editor_is_not_authoritative.

@Test
public void new_member_by_promote_by_other_editor_is_not_authoritative() {
    UUID editor = UUID.randomUUID();
    UUID newMember = UUID.randomUUID();
    ProfileKey profileKey = ProfileKeyUtil.createNew();
    ProfileKeySet profileKeySet = new ProfileKeySet();
    profileKeySet.addKeysFromGroupChange(changeBy(editor).promote(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 89 with ProfileKey

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

the class ProfileKeySetTest method authoritative_takes_priority_when_seen_second.

@Test
public void authoritative_takes_priority_when_seen_second() {
    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(member).profileKeyUpdate(member, profileKey2).build());
    assertTrue(profileKeySet.getProfileKeys().isEmpty());
    assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ACI.from(member), profileKey2)));
}
Also used : UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) Test(org.junit.Test)

Example 90 with ProfileKey

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

the class ProfileKeySetTest method profile_key_update_by_another_is_not_authoritative.

@Test
public void profile_key_update_by_another_is_not_authoritative() {
    UUID editor = UUID.randomUUID();
    UUID member = UUID.randomUUID();
    ProfileKey profileKey = ProfileKeyUtil.createNew();
    ProfileKeySet profileKeySet = new ProfileKeySet();
    profileKeySet.addKeysFromGroupChange(changeBy(editor).profileKeyUpdate(member, profileKey).build());
    assertTrue(profileKeySet.getAuthoritativeProfileKeys().isEmpty());
    assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ACI.from(member), 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