use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class GroupStateMapperTest method notices_changes_in_avatar_and_title_but_not_members_in_placeholder.
@Test
public void notices_changes_in_avatar_and_title_but_not_members_in_placeholder() {
UUID newMemberUuid = UUID.randomUUID();
DecryptedMember newMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(newMemberUuid)).build();
DecryptedMember existingMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(UUID.randomUUID())).build();
DecryptedGroup currentState = DecryptedGroup.newBuilder().setRevision(GroupStateMapper.PLACEHOLDER_REVISION).setTitle("Incorrect group title").setAvatar("Incorrect group avatar").addMembers(newMember).build();
ServerGroupLogEntry log8 = new ServerGroupLogEntry(DecryptedGroup.newBuilder().setRevision(8).addMembers(newMember).addMembers(existingMember).setTitle("Group Revision " + 8).setAvatar("Group Avatar " + 8).build(), DecryptedGroupChange.newBuilder().setRevision(8).setEditor(UuidUtil.toByteString(newMemberUuid)).addNewMembers(newMember).build());
DecryptedGroupChange expectedChange = DecryptedGroupChange.newBuilder().setRevision(8).setNewTitle(DecryptedString.newBuilder().setValue("Group Revision " + 8)).setNewAvatar(DecryptedString.newBuilder().setValue("Group Avatar " + 8)).build();
AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, singletonList(log8)), LATEST);
assertNotNull(log8.getGroup());
assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(singletonList(new LocalGroupLogEntry(log8.getGroup(), expectedChange))));
assertNewState(new GlobalGroupState(log8.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState());
assertEquals(log8.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 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);
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method apply_new_member.
@Test
public void apply_new_member() throws NotAbleToApplyGroupV2ChangeException {
DecryptedMember member1 = member(UUID.randomUUID());
DecryptedMember member2 = member(UUID.randomUUID());
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).build(), DecryptedGroupChange.newBuilder().setRevision(11).addNewMembers(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 apply_modify_admin_profile_keys.
@Test
public void apply_modify_admin_profile_keys() throws NotAbleToApplyGroupV2ChangeException {
UUID adminUuid = UUID.randomUUID();
ProfileKey profileKey1 = randomProfileKey();
ProfileKey profileKey2a = randomProfileKey();
ProfileKey profileKey2b = randomProfileKey();
DecryptedMember member1 = member(UUID.randomUUID(), profileKey1);
DecryptedMember admin2a = admin(adminUuid, profileKey2a);
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addMembers(member1).addMembers(admin2a).build(), DecryptedGroupChange.newBuilder().setRevision(14).addModifiedProfileKeys(DecryptedMember.newBuilder(DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(adminUuid)).build()).setProfileKey(ByteString.copyFrom(profileKey2b.serialize()))).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(14).addMembers(member1).addMembers(admin(adminUuid, profileKey2b)).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method apply_new_pending_member_already_in_group.
@Test(expected = NotAbleToApplyGroupV2ChangeException.class)
public void apply_new_pending_member_already_in_group() throws NotAbleToApplyGroupV2ChangeException {
DecryptedMember member1 = member(UUID.randomUUID());
UUID uuid2 = UUID.randomUUID();
DecryptedMember member2 = member(uuid2);
DecryptedPendingMember pending2 = pendingMember(uuid2);
DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addMembers(member2).build(), DecryptedGroupChange.newBuilder().setRevision(11).addNewPendingMembers(pending2).build());
}
Aggregations