Add pniSignatureVerified support
This commit is contained in:
parent
7dc11c1928
commit
95caf59c3c
11 changed files with 258 additions and 126 deletions
|
@ -9,6 +9,7 @@ import Long from 'long';
|
|||
|
||||
import * as durations from '../../util/durations';
|
||||
import { uuidToBytes } from '../../util/uuidToBytes';
|
||||
import { generateConfigMatrix } from '../../util/generateConfigMatrix';
|
||||
import { toUntaggedPni } from '../../types/ServiceId';
|
||||
import { MY_STORY_ID } from '../../types/Stories';
|
||||
import { Bootstrap } from '../bootstrap';
|
||||
|
@ -98,131 +99,134 @@ describe('pnp/merge', function (this: Mocha.Suite) {
|
|||
await bootstrap.teardown();
|
||||
});
|
||||
|
||||
for (const finalContact of [ServiceIdKind.ACI, ServiceIdKind.PNI]) {
|
||||
for (const withNotification of [false, true]) {
|
||||
const testName =
|
||||
'happens via storage service, ' +
|
||||
`${withNotification ? 'with' : 'without'} notification ` +
|
||||
`(${finalContact})`;
|
||||
const matrix = generateConfigMatrix({
|
||||
finalContact: [ServiceIdKind.ACI, ServiceIdKind.PNI],
|
||||
withPNIMessage: [false, true],
|
||||
pniSignatureVerified: [false, true],
|
||||
});
|
||||
for (const { finalContact, withPNIMessage, pniSignatureVerified } of matrix) {
|
||||
const testName =
|
||||
'happens via storage service, ' +
|
||||
`${withPNIMessage ? 'with' : 'without'} pni message ` +
|
||||
`${pniSignatureVerified ? 'with' : 'without'} pniSignatureVerified ` +
|
||||
`(${finalContact})`;
|
||||
|
||||
// eslint-disable-next-line no-loop-func
|
||||
it(testName, async () => {
|
||||
const { phone } = bootstrap;
|
||||
// eslint-disable-next-line no-loop-func
|
||||
it(testName, async () => {
|
||||
const { phone } = bootstrap;
|
||||
|
||||
const window = await app.getWindow();
|
||||
const leftPane = window.locator('#LeftPane');
|
||||
const window = await app.getWindow();
|
||||
const leftPane = window.locator('#LeftPane');
|
||||
|
||||
debug('opening conversation with the aci contact');
|
||||
debug('opening conversation with the aci contact');
|
||||
await leftPane
|
||||
.locator(`[data-testid="${pniContact.device.aci}"]`)
|
||||
.click();
|
||||
|
||||
await window.locator('.module-conversation-hero').waitFor();
|
||||
|
||||
debug('Send message to ACI');
|
||||
{
|
||||
const compositionInput = await app.waitForEnabledComposer();
|
||||
|
||||
await compositionInput.type('Hello ACI');
|
||||
await compositionInput.press('Enter');
|
||||
}
|
||||
|
||||
debug('opening conversation with the pni contact');
|
||||
await leftPane
|
||||
.locator('.module-conversation-list__item--contact-or-conversation')
|
||||
.first()
|
||||
.click();
|
||||
|
||||
await window.locator('.module-conversation-hero').waitFor();
|
||||
|
||||
debug('Verify starting state');
|
||||
{
|
||||
// No messages
|
||||
const messages = window.locator('.module-message__text');
|
||||
assert.strictEqual(await messages.count(), 0, 'message count');
|
||||
|
||||
// No notifications
|
||||
const notifications = window.locator('.SystemMessage');
|
||||
assert.strictEqual(
|
||||
await notifications.count(),
|
||||
0,
|
||||
'notification count'
|
||||
);
|
||||
}
|
||||
|
||||
if (withPNIMessage) {
|
||||
debug('Send message to PNI');
|
||||
const compositionInput = await app.waitForEnabledComposer();
|
||||
|
||||
await compositionInput.type('Hello PNI');
|
||||
await compositionInput.press('Enter');
|
||||
}
|
||||
|
||||
if (finalContact === ServiceIdKind.ACI) {
|
||||
debug('switching back to ACI conversation');
|
||||
await leftPane
|
||||
.locator(`[data-testid="${pniContact.device.aci}"]`)
|
||||
.click();
|
||||
|
||||
await window.locator('.module-conversation-hero').waitFor();
|
||||
}
|
||||
|
||||
debug('Send message to ACI');
|
||||
{
|
||||
const compositionInput = await app.waitForEnabledComposer();
|
||||
|
||||
await compositionInput.type('Hello ACI');
|
||||
await compositionInput.press('Enter');
|
||||
}
|
||||
|
||||
debug('opening conversation with the pni contact');
|
||||
await leftPane
|
||||
.locator('.module-conversation-list__item--contact-or-conversation')
|
||||
.first()
|
||||
.click();
|
||||
|
||||
await window.locator('.module-conversation-hero').waitFor();
|
||||
|
||||
debug('Verify starting state');
|
||||
{
|
||||
// No messages
|
||||
const messages = window.locator('.module-message__text');
|
||||
assert.strictEqual(await messages.count(), 0, 'message count');
|
||||
|
||||
// No notifications
|
||||
const notifications = window.locator('.SystemMessage');
|
||||
assert.strictEqual(
|
||||
await notifications.count(),
|
||||
0,
|
||||
'notification count'
|
||||
);
|
||||
}
|
||||
|
||||
if (withNotification) {
|
||||
debug('Send message to PNI');
|
||||
const compositionInput = await app.waitForEnabledComposer();
|
||||
|
||||
await compositionInput.type('Hello PNI');
|
||||
await compositionInput.press('Enter');
|
||||
}
|
||||
|
||||
if (finalContact === ServiceIdKind.ACI) {
|
||||
debug('switching back to ACI conversation');
|
||||
await leftPane
|
||||
.locator(`[data-testid="${pniContact.device.aci}"]`)
|
||||
.click();
|
||||
|
||||
await window.locator('.module-conversation-hero').waitFor();
|
||||
}
|
||||
|
||||
debug(
|
||||
'removing both contacts from storage service, adding one combined contact'
|
||||
debug(
|
||||
'removing both contacts from storage service, adding one combined contact'
|
||||
);
|
||||
{
|
||||
const state = await phone.expectStorageState('consistency check');
|
||||
await phone.setStorageState(
|
||||
state.mergeContact(pniContact, {
|
||||
identityState: Proto.ContactRecord.IdentityState.DEFAULT,
|
||||
whitelisted: true,
|
||||
identityKey: pniContact.publicKey.serialize(),
|
||||
profileKey: pniContact.profileKey.serialize(),
|
||||
pniSignatureVerified,
|
||||
})
|
||||
);
|
||||
{
|
||||
const state = await phone.expectStorageState('consistency check');
|
||||
await phone.setStorageState(
|
||||
state.mergeContact(pniContact, {
|
||||
identityState: Proto.ContactRecord.IdentityState.DEFAULT,
|
||||
whitelisted: true,
|
||||
identityKey: pniContact.publicKey.serialize(),
|
||||
profileKey: pniContact.profileKey.serialize(),
|
||||
})
|
||||
);
|
||||
await phone.sendFetchStorage({
|
||||
timestamp: bootstrap.getTimestamp(),
|
||||
});
|
||||
await app.waitForManifestVersion(state.version);
|
||||
}
|
||||
await phone.sendFetchStorage({
|
||||
timestamp: bootstrap.getTimestamp(),
|
||||
});
|
||||
await app.waitForManifestVersion(state.version);
|
||||
}
|
||||
|
||||
debug('Verify final state');
|
||||
{
|
||||
// Should have both PNI and ACI messages
|
||||
debug('Verify final state');
|
||||
{
|
||||
// Should have both PNI and ACI messages
|
||||
await window.locator('.module-message__text >> "Hello ACI"').waitFor();
|
||||
if (withPNIMessage) {
|
||||
await window
|
||||
.locator('.module-message__text >> "Hello ACI"')
|
||||
.locator('.module-message__text >> "Hello PNI"')
|
||||
.waitFor();
|
||||
if (withNotification) {
|
||||
await window
|
||||
.locator('.module-message__text >> "Hello PNI"')
|
||||
.waitFor();
|
||||
}
|
||||
|
||||
const messages = window.locator('.module-message__text');
|
||||
assert.strictEqual(
|
||||
await messages.count(),
|
||||
withNotification ? 2 : 1,
|
||||
'message count'
|
||||
);
|
||||
|
||||
// One notification - the merge
|
||||
const notifications = window.locator('.SystemMessage');
|
||||
assert.strictEqual(
|
||||
await notifications.count(),
|
||||
withNotification ? 1 : 0,
|
||||
'notification count'
|
||||
);
|
||||
|
||||
if (withNotification) {
|
||||
const first = await notifications.first();
|
||||
assert.match(
|
||||
await first.innerText(),
|
||||
/Your message history with ACI Contact and their number .* has been merged./
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const messages = window.locator('.module-message__text');
|
||||
assert.strictEqual(
|
||||
await messages.count(),
|
||||
withPNIMessage ? 2 : 1,
|
||||
'message count'
|
||||
);
|
||||
|
||||
// One notification - the merge
|
||||
const notifications = window.locator('.SystemMessage');
|
||||
assert.strictEqual(
|
||||
await notifications.count(),
|
||||
withPNIMessage && !pniSignatureVerified ? 1 : 0,
|
||||
'notification count'
|
||||
);
|
||||
|
||||
if (withPNIMessage && !pniSignatureVerified) {
|
||||
const first = await notifications.first();
|
||||
assert.match(
|
||||
await first.innerText(),
|
||||
/Your message history with ACI Contact and their number .* has been merged./
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
it('accepts storage service contact splitting', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue