Better merging for changed keys in storage service
This commit is contained in:
@@ -672,7 +672,7 @@ describe('SignalProtocolStore', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('processContactSyncVerificationState', () => {
|
||||
describe('processVerifiedMessage', () => {
|
||||
const newIdentity = getPublicKey();
|
||||
let keychangeTriggered: number;
|
||||
|
||||
@@ -693,8 +693,8 @@ describe('SignalProtocolStore', () => {
|
||||
await store.hydrateCaches();
|
||||
});
|
||||
|
||||
it('does nothing', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
it('sets the identity key', async () => {
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.DEFAULT,
|
||||
newIdentity
|
||||
@@ -703,15 +703,10 @@ describe('SignalProtocolStore', () => {
|
||||
const identity = await window.Signal.Data.getIdentityKeyById(
|
||||
theirUuid.toString()
|
||||
);
|
||||
|
||||
if (identity) {
|
||||
// fetchRecord resolved so there is a record.
|
||||
// Bad.
|
||||
throw new Error(
|
||||
'processContactSyncVerificationState should not save new records'
|
||||
);
|
||||
}
|
||||
|
||||
assert.isTrue(
|
||||
identity?.publicKey &&
|
||||
constantTimeEqual(identity.publicKey, newIdentity)
|
||||
);
|
||||
assert.strictEqual(keychangeTriggered, 0);
|
||||
});
|
||||
});
|
||||
@@ -729,8 +724,8 @@ describe('SignalProtocolStore', () => {
|
||||
await store.hydrateCaches();
|
||||
});
|
||||
|
||||
it('does not save the new identity (because this is a less secure state)', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
it('updates the identity', async () => {
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.DEFAULT,
|
||||
newIdentity
|
||||
@@ -743,14 +738,9 @@ describe('SignalProtocolStore', () => {
|
||||
throw new Error('Missing identity!');
|
||||
}
|
||||
|
||||
assert.strictEqual(
|
||||
identity.verified,
|
||||
store.VerifiedStatus.VERIFIED
|
||||
);
|
||||
assert.isTrue(
|
||||
constantTimeEqual(identity.publicKey, testKey.pubKey)
|
||||
);
|
||||
assert.strictEqual(keychangeTriggered, 0);
|
||||
assert.strictEqual(identity.verified, store.VerifiedStatus.DEFAULT);
|
||||
assert.isTrue(constantTimeEqual(identity.publicKey, newIdentity));
|
||||
assert.strictEqual(keychangeTriggered, 1);
|
||||
});
|
||||
});
|
||||
describe('when the existing key is the same but VERIFIED', () => {
|
||||
@@ -767,7 +757,7 @@ describe('SignalProtocolStore', () => {
|
||||
});
|
||||
|
||||
it('updates the verified status', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.DEFAULT,
|
||||
testKey.pubKey
|
||||
@@ -801,7 +791,7 @@ describe('SignalProtocolStore', () => {
|
||||
});
|
||||
|
||||
it('does not hang', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.DEFAULT,
|
||||
testKey.pubKey
|
||||
@@ -819,8 +809,8 @@ describe('SignalProtocolStore', () => {
|
||||
await store.hydrateCaches();
|
||||
});
|
||||
|
||||
it('saves the new identity and marks it verified', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
it('saves the new identity and marks it UNVERIFIED', async () => {
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.UNVERIFIED,
|
||||
newIdentity
|
||||
@@ -856,7 +846,7 @@ describe('SignalProtocolStore', () => {
|
||||
});
|
||||
|
||||
it('saves the new identity and marks it UNVERIFIED', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.UNVERIFIED,
|
||||
newIdentity
|
||||
@@ -891,7 +881,7 @@ describe('SignalProtocolStore', () => {
|
||||
});
|
||||
|
||||
it('updates the verified status', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.UNVERIFIED,
|
||||
testKey.pubKey
|
||||
@@ -927,7 +917,7 @@ describe('SignalProtocolStore', () => {
|
||||
});
|
||||
|
||||
it('does not hang', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.UNVERIFIED,
|
||||
testKey.pubKey
|
||||
@@ -946,7 +936,7 @@ describe('SignalProtocolStore', () => {
|
||||
});
|
||||
|
||||
it('saves the new identity and marks it verified', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.VERIFIED,
|
||||
newIdentity
|
||||
@@ -978,7 +968,7 @@ describe('SignalProtocolStore', () => {
|
||||
});
|
||||
|
||||
it('saves the new identity and marks it VERIFIED', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.VERIFIED,
|
||||
newIdentity
|
||||
@@ -1013,7 +1003,7 @@ describe('SignalProtocolStore', () => {
|
||||
});
|
||||
|
||||
it('saves the identity and marks it verified', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.VERIFIED,
|
||||
testKey.pubKey
|
||||
@@ -1049,7 +1039,7 @@ describe('SignalProtocolStore', () => {
|
||||
});
|
||||
|
||||
it('does not hang', async () => {
|
||||
await store.processContactSyncVerificationState(
|
||||
await store.processVerifiedMessage(
|
||||
theirUuid,
|
||||
store.VerifiedStatus.VERIFIED,
|
||||
testKey.pubKey
|
||||
|
Reference in New Issue
Block a user