use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by WhisperSystems.
the class DecryptedGroupUtilTest method can_extract_uuid_from_decrypted_member.
@Test
public void can_extract_uuid_from_decrypted_member() {
UUID uuid = UUID.randomUUID();
DecryptedMember decryptedMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(uuid)).build();
UUID parsed = DecryptedGroupUtil.toUuid(decryptedMember);
assertEquals(uuid, parsed);
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class GroupStateMapperTest method updates_with_a_server_mismatch_inserts_additional_update.
@Test
public void updates_with_a_server_mismatch_inserts_additional_update() {
DecryptedGroup currentState = state(6);
ServerGroupLogEntry log7 = serverLogEntry(7);
DecryptedMember newMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(UUID.randomUUID())).build();
DecryptedGroup state7b = DecryptedGroup.newBuilder().setRevision(8).setTitle("Group Revision " + 8).build();
DecryptedGroup state8 = DecryptedGroup.newBuilder().setRevision(8).setTitle("Group Revision " + 8).addMembers(newMember).build();
ServerGroupLogEntry log8 = new ServerGroupLogEntry(state8, change(8));
ServerGroupLogEntry log9 = new ServerGroupLogEntry(DecryptedGroup.newBuilder().setRevision(9).addMembers(newMember).setTitle("Group Revision " + 9).build(), change(9));
AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, asList(log7, log8, log9)), LATEST);
assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(asList(asLocal(log7), new LocalGroupLogEntry(state7b, log8.getChange()), new LocalGroupLogEntry(state8, DecryptedGroupChange.newBuilder().setRevision(8).addNewMembers(newMember).build()), asLocal(log9))));
assertNewState(new GlobalGroupState(log9.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState());
assertEquals(log9.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method remove_pending_member.
@Test
public void remove_pending_member() throws NotAbleToApplyGroupV2ChangeException {
DecryptedMember member1 = member(UUID.randomUUID());
UUID pendingUuid = UUID.randomUUID();
DecryptedPendingMember pending = pendingMember(pendingUuid);
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addPendingMembers(pending).build(), DecryptedGroupChange.newBuilder().setRevision(11).addDeletePendingMembers(DecryptedPendingMemberRemoval.newBuilder().setUuidCipherText(ProtoTestUtils.encrypt(pendingUuid)).build()).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method promote_pending_member.
@Test
public void promote_pending_member() throws NotAbleToApplyGroupV2ChangeException {
ProfileKey profileKey2 = randomProfileKey();
DecryptedMember member1 = member(UUID.randomUUID());
UUID pending2Uuid = UUID.randomUUID();
DecryptedPendingMember pending2 = pendingMember(pending2Uuid);
DecryptedMember member2 = member(pending2Uuid, profileKey2);
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addPendingMembers(pending2).build(), DecryptedGroupChange.newBuilder().setRevision(11).addPromotePendingMembers(member2).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).addMembers(member2).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method cant_apply_modify_member_profile_keys_if_member_not_in_group.
@Test(expected = NotAbleToApplyGroupV2ChangeException.class)
public void cant_apply_modify_member_profile_keys_if_member_not_in_group() 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 = member(UUID.randomUUID(), profileKey2b);
DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addMembers(member1).addMembers(member2a).build(), DecryptedGroupChange.newBuilder().setRevision(14).addModifiedProfileKeys(member2b).build());
}
Aggregations