use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class ProfileKeySetTest method new_member_by_self_is_authoritative.
@Test
public void new_member_by_self_is_authoritative() {
UUID newMember = UUID.randomUUID();
ProfileKey profileKey = ProfileKeyUtil.createNew();
ProfileKeySet profileKeySet = new ProfileKeySet();
profileKeySet.addKeysFromGroupChange(changeBy(newMember).addMember(newMember, profileKey).build());
assertTrue(profileKeySet.getProfileKeys().isEmpty());
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ACI.from(newMember), profileKey)));
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
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)));
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
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)));
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
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)));
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method apply_modify_member_profile_keys.
@Test
public void apply_modify_member_profile_keys() throws NotAbleToApplyGroupV2ChangeException {
ProfileKey profileKey1 = randomProfileKey();
ProfileKey profileKey2a = randomProfileKey();
ProfileKey profileKey2b = randomProfileKey();
DecryptedMember member1 = member(UUID.randomUUID(), profileKey1);
DecryptedMember member2a = member(UUID.randomUUID(), profileKey2a);
DecryptedMember member2b = withProfileKey(member2a, profileKey2b);
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addMembers(member1).addMembers(member2a).build(), DecryptedGroupChange.newBuilder().setRevision(14).addModifiedProfileKeys(member2b).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(14).addMembers(member1).addMembers(member2b).build(), newGroup);
}
Aggregations