Send support for Sender Key

This commit is contained in:
Scott Nonnenberg 2021-05-25 15:40:04 -07:00 committed by GitHub
parent d8417e562b
commit e6f1ec2b6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 2290 additions and 911 deletions

View file

@ -175,6 +175,14 @@ describe('SignalProtocolStore', () => {
assert.isTrue(
constantTimeEqual(expected.serialize(), actual.serialize())
);
await store.removeSenderKey(encodedAddress, distributionId);
const postDeleteGet = await store.getSenderKey(
encodedAddress,
distributionId
);
assert.isUndefined(postDeleteGet);
});
it('roundtrips through database', async () => {
@ -197,6 +205,17 @@ describe('SignalProtocolStore', () => {
assert.isTrue(
constantTimeEqual(expected.serialize(), actual.serialize())
);
await store.removeSenderKey(encodedAddress, distributionId);
// Re-fetch from the database to ensure we get the latest database value
await store.hydrateCaches();
const postDeleteGet = await store.getSenderKey(
encodedAddress,
distributionId
);
assert.isUndefined(postDeleteGet);
});
});
@ -1280,6 +1299,54 @@ describe('SignalProtocolStore', () => {
});
});
describe('getOpenDevices', () => {
it('returns all open devices for a number', async () => {
const openRecord = getSessionRecord(true);
const openDevices = [1, 2, 3, 10].map(deviceId => {
return [number, deviceId].join('.');
});
await Promise.all(
openDevices.map(async encodedNumber => {
await store.storeSession(encodedNumber, openRecord);
})
);
const closedRecord = getSessionRecord(false);
await store.storeSession([number, 11].join('.'), closedRecord);
const result = await store.getOpenDevices([number, 'blah', 'blah2']);
assert.deepEqual(result, {
devices: [
{
id: 1,
identifier: number,
},
{
id: 2,
identifier: number,
},
{
id: 3,
identifier: number,
},
{
id: 10,
identifier: number,
},
],
emptyIdentifiers: ['blah', 'blah2'],
});
});
it('returns empty array for a number with no device ids', async () => {
const result = await store.getOpenDevices(['foo']);
assert.deepEqual(result, {
devices: [],
emptyIdentifiers: ['foo'],
});
});
});
describe('zones', () => {
const zone = new Zone('zone', {
pendingSessions: true,