Migrate schema to service ids

This commit is contained in:
Fedor Indutny 2023-08-16 22:54:39 +02:00 committed by Jamie Kyle
parent 71958f8a01
commit 8b0da36caa
258 changed files with 4795 additions and 2613 deletions

View file

@ -2,8 +2,9 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { Pni } from '@signalapp/libsignal-client';
import {
UUIDKind,
ServiceIdKind,
Proto,
ReceiptType,
StorageState,
@ -50,10 +51,10 @@ describe('pnp/PNI Signature', function needsName() {
{
whitelisted: true,
serviceE164: pniContact.device.number,
identityKey: pniContact.getPublicKey(UUIDKind.PNI).serialize(),
identityKey: pniContact.getPublicKey(ServiceIdKind.PNI).serialize(),
givenName: 'PNI Contact',
},
UUIDKind.PNI
ServiceIdKind.PNI
);
state = state.addContact(pniContact, {
@ -64,7 +65,7 @@ describe('pnp/PNI Signature', function needsName() {
});
// Just to make PNI Contact visible in the left pane
state = state.pin(pniContact, UUIDKind.PNI);
state = state.pin(pniContact, ServiceIdKind.PNI);
// Add my story
state = state.addRecord({
@ -75,7 +76,7 @@ describe('pnp/PNI Signature', function needsName() {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: true,
name: MY_STORY_ID,
recipientUuids: [],
recipientServiceIds: [],
},
},
});
@ -94,8 +95,8 @@ describe('pnp/PNI Signature', function needsName() {
it('should be sent by Desktop until encrypted delivery receipt', async () => {
const { server, desktop } = bootstrap;
const ourPniKey = await desktop.getIdentityKey(UUIDKind.PNI);
const ourAciKey = await desktop.getIdentityKey(UUIDKind.ACI);
const ourPniKey = await desktop.getIdentityKey(ServiceIdKind.PNI);
const ourAciKey = await desktop.getIdentityKey(ServiceIdKind.ACI);
const window = await app.getWindow();
@ -107,8 +108,8 @@ describe('pnp/PNI Signature', function needsName() {
profileName: 'Mysterious Stranger',
});
const ourKey = await desktop.popSingleUseKey(UUIDKind.PNI);
await stranger.addSingleUseKey(desktop, ourKey, UUIDKind.PNI);
const ourKey = await desktop.popSingleUseKey(ServiceIdKind.PNI);
await stranger.addSingleUseKey(desktop, ourKey, ServiceIdKind.PNI);
const checkPniSignature = (
message: Proto.IPniSignatureMessage | null | undefined,
@ -120,9 +121,17 @@ describe('pnp/PNI Signature', function needsName() {
);
}
if (!message.pni) {
throw new Error(
`Missing expected pni on pni signature message from ${source}`
);
}
assert.deepEqual(
message.pni,
uuidToBytes(desktop.pni),
Pni.parseFromServiceIdBinary(
Buffer.from(message.pni)
).getServiceIdString(),
desktop.pni,
`Incorrect pni in pni signature message from ${source}`
);
@ -135,14 +144,14 @@ describe('pnp/PNI Signature', function needsName() {
debug('sending a message to our PNI');
await stranger.sendText(desktop, 'A message to PNI', {
uuidKind: UUIDKind.PNI,
serviceIdKind: ServiceIdKind.PNI,
withProfileKey: true,
timestamp: bootstrap.getTimestamp(),
});
debug('opening conversation with the stranger');
await leftPane
.locator(`[data-testid="${stranger.toContact().uuid}"]`)
.locator(`[data-testid="${stranger.toContact().aci}"]`)
.click();
debug('Accept conversation from a stranger');
@ -272,13 +281,13 @@ describe('pnp/PNI Signature', function needsName() {
debug('Waiting for a PNI message');
{
const { source, body, uuidKind } = await pniContact.waitForMessage();
const { source, body, serviceIdKind } = await pniContact.waitForMessage();
assert.strictEqual(source, desktop, 'PNI message has valid source');
assert.strictEqual(body, 'Hello PNI', 'PNI message has valid body');
assert.strictEqual(
uuidKind,
UUIDKind.PNI,
serviceIdKind,
ServiceIdKind.PNI,
'PNI message has valid destination'
);
}
@ -305,7 +314,7 @@ describe('pnp/PNI Signature', function needsName() {
debug('Wait for merge to happen');
await leftPane
.locator(`[data-testid="${pniContact.toContact().uuid}"]`)
.locator(`[data-testid="${pniContact.toContact().aci}"]`)
.waitFor();
{
@ -319,13 +328,13 @@ describe('pnp/PNI Signature', function needsName() {
debug('Waiting for a ACI message');
{
const { source, body, uuidKind } = await pniContact.waitForMessage();
const { source, body, serviceIdKind } = await pniContact.waitForMessage();
assert.strictEqual(source, desktop, 'ACI message has valid source');
assert.strictEqual(body, 'Hello ACI', 'ACI message has valid body');
assert.strictEqual(
uuidKind,
UUIDKind.ACI,
serviceIdKind,
ServiceIdKind.ACI,
'ACI message has valid destination'
);
}
@ -337,15 +346,16 @@ describe('pnp/PNI Signature', function needsName() {
after: state,
});
assert.isUndefined(
newState.getContact(pniContact, UUIDKind.PNI),
'PNI Contact must be removed from storage service'
const pni = newState.getContact(pniContact, ServiceIdKind.PNI);
const aci = newState.getContact(pniContact, ServiceIdKind.ACI);
assert.strictEqual(
aci,
pni,
'ACI Contact must be the same as PNI Contact storage service'
);
const aci = newState.getContact(pniContact, UUIDKind.ACI);
assert(aci, 'ACI Contact must be in storage service');
assert.strictEqual(aci?.serviceUuid, pniContact.device.uuid);
assert.strictEqual(aci?.aci, pniContact.device.aci);
assert.strictEqual(aci?.pni, pniContact.device.pni);
// Two outgoing, one incoming