Export/import simple update messages
This commit is contained in:
parent
19083cadf7
commit
9df3c63ca6
14 changed files with 1604 additions and 386 deletions
410
ts/test-electron/backup/non_bubble_test.ts
Normal file
410
ts/test-electron/backup/non_bubble_test.ts
Normal file
|
@ -0,0 +1,410 @@
|
|||
// Copyright 2024 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { v4 as generateGuid } from 'uuid';
|
||||
import Long from 'long';
|
||||
|
||||
import type { ConversationModel } from '../../models/conversations';
|
||||
|
||||
import { getRandomBytes } from '../../Crypto';
|
||||
import * as Bytes from '../../Bytes';
|
||||
import { SignalService as Proto, Backups } from '../../protobuf';
|
||||
import Data from '../../sql/Client';
|
||||
import { generateAci } from '../../types/ServiceId';
|
||||
import { PaymentEventKind } from '../../types/Payment';
|
||||
import { ContactFormType } from '../../types/EmbeddedContact';
|
||||
import { DurationInSeconds } from '../../util/durations';
|
||||
import { loadCallsHistory } from '../../services/callHistoryLoader';
|
||||
import { setupBasics, symmetricRoundtripHarness } from './helpers';
|
||||
|
||||
const CONTACT_A = generateAci();
|
||||
const GROUP_ID = Bytes.toBase64(getRandomBytes(32));
|
||||
|
||||
describe('backup/non-bubble messages', () => {
|
||||
let contactA: ConversationModel;
|
||||
let group: ConversationModel;
|
||||
|
||||
beforeEach(async () => {
|
||||
await Data._removeAllMessages();
|
||||
await Data._removeAllConversations();
|
||||
window.storage.reset();
|
||||
|
||||
await setupBasics();
|
||||
|
||||
contactA = await window.ConversationController.getOrCreateAndWait(
|
||||
CONTACT_A,
|
||||
'private',
|
||||
{ systemGivenName: 'CONTACT_A' }
|
||||
);
|
||||
|
||||
group = await window.ConversationController.getOrCreateAndWait(
|
||||
GROUP_ID,
|
||||
'group',
|
||||
{
|
||||
groupVersion: 2,
|
||||
masterKey: Bytes.toBase64(getRandomBytes(32)),
|
||||
name: 'Rock Enthusiasts',
|
||||
}
|
||||
);
|
||||
|
||||
await loadCallsHistory();
|
||||
});
|
||||
|
||||
it('roundtrips END_SESSION simple update', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'incoming',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
sourceServiceId: CONTACT_A,
|
||||
sourceDevice: 1,
|
||||
flags: Proto.DataMessage.Flags.END_SESSION,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips CHAT_SESSION_REFRESH simple update', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'chat-session-refreshed',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips IDENTITY_CHANGE update in direct convos', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'keychange',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips IDENTITY_CHANGE update in groups', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: group.id,
|
||||
id: generateGuid(),
|
||||
type: 'keychange',
|
||||
key_changed: contactA.id,
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips IDENTITY_DEFAULT simple update', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'verified-change',
|
||||
verifiedChanged: contactA.id,
|
||||
verified: false,
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips IDENTITY_VERIFIED simple update', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'verified-change',
|
||||
verifiedChanged: contactA.id,
|
||||
verified: true,
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips CHANGE_NUMBER simple update', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'change-number-notification',
|
||||
sourceServiceId: CONTACT_A,
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips JOINED_SIGNAL simple update', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'joined-signal-notification',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips BAD_DECRYPT simple update', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'delivery-issue',
|
||||
sourceServiceId: CONTACT_A,
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips PAYMENTS_ACTIVATED simple update', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'incoming',
|
||||
sourceServiceId: CONTACT_A,
|
||||
payment: {
|
||||
kind: PaymentEventKind.Activation,
|
||||
},
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips PAYMENT_ACTIVATION_REQUEST simple update', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'incoming',
|
||||
sourceServiceId: CONTACT_A,
|
||||
payment: {
|
||||
kind: PaymentEventKind.ActivationRequest,
|
||||
},
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
// TODO: DESKTOP-7122
|
||||
it.skip('roundtrips bare payments notification', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'incoming',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
sourceServiceId: CONTACT_A,
|
||||
sourceDevice: 1,
|
||||
payment: {
|
||||
kind: PaymentEventKind.Notification,
|
||||
note: 'note with text',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
// TODO: DESKTOP-7122
|
||||
it.skip('roundtrips full payments notification', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'incoming',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
sourceServiceId: CONTACT_A,
|
||||
sourceDevice: 1,
|
||||
payment: {
|
||||
kind: PaymentEventKind.Notification,
|
||||
note: 'note with text',
|
||||
amountMob: '1.01',
|
||||
feeMob: '0.01',
|
||||
transactionDetailsBase64: Bytes.toBase64(
|
||||
Backups.PaymentNotification.TransactionDetails.encode({
|
||||
transaction: {
|
||||
timestamp: Long.fromNumber(Date.now()),
|
||||
},
|
||||
}).finish()
|
||||
),
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips embedded contact', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'incoming',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
sourceServiceId: CONTACT_A,
|
||||
sourceDevice: 1,
|
||||
contact: [
|
||||
{
|
||||
name: {
|
||||
givenName: 'Alice',
|
||||
familyName: 'Smith',
|
||||
},
|
||||
number: [
|
||||
{
|
||||
type: ContactFormType.MOBILE,
|
||||
value: '+121255501234',
|
||||
},
|
||||
],
|
||||
organization: 'Signal',
|
||||
},
|
||||
],
|
||||
reactions: [
|
||||
{
|
||||
emoji: '👍',
|
||||
fromId: contactA.id,
|
||||
targetTimestamp: 1,
|
||||
timestamp: 1,
|
||||
receivedAtDate: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips sticker', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'incoming',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
sourceServiceId: CONTACT_A,
|
||||
sourceDevice: 1,
|
||||
// TODO (DESKTOP-6845): properly handle data FilePointer
|
||||
sticker: {
|
||||
emoji: '👍',
|
||||
packId: Bytes.toHex(getRandomBytes(16)),
|
||||
stickerId: 1,
|
||||
packKey: Bytes.toBase64(getRandomBytes(32)),
|
||||
},
|
||||
reactions: [
|
||||
{
|
||||
emoji: '👍',
|
||||
fromId: contactA.id,
|
||||
targetTimestamp: 1,
|
||||
timestamp: 1,
|
||||
receivedAtDate: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips remote deleted message', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'incoming',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
sourceServiceId: CONTACT_A,
|
||||
sourceDevice: 1,
|
||||
isErased: true,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips timer notification in direct convos', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'timer-notification',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
flags: Proto.DataMessage.Flags.EXPIRATION_TIMER_UPDATE,
|
||||
sourceServiceId: CONTACT_A,
|
||||
sourceDevice: 1,
|
||||
expirationTimerUpdate: {
|
||||
expireTimer: DurationInSeconds.fromMillis(5000),
|
||||
sourceServiceId: CONTACT_A,
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips profile change notification', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'profile-change',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
sourceServiceId: CONTACT_A,
|
||||
sourceDevice: 1,
|
||||
changedId: contactA.id,
|
||||
profileChange: {
|
||||
type: 'name',
|
||||
oldName: 'Old Name',
|
||||
newName: 'New Name',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('roundtrips thread merge', async () => {
|
||||
await symmetricRoundtripHarness([
|
||||
{
|
||||
conversationId: contactA.id,
|
||||
id: generateGuid(),
|
||||
type: 'conversation-merge',
|
||||
received_at: 1,
|
||||
sent_at: 1,
|
||||
timestamp: 1,
|
||||
sourceServiceId: CONTACT_A,
|
||||
sourceDevice: 1,
|
||||
conversationMerge: {
|
||||
renderInfo: {
|
||||
type: 'private',
|
||||
e164: '+12125551234',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue