UUID-keyed lookups in SignalProtocolStore
This commit is contained in:
parent
6323aedd9b
commit
c7e7d55af4
46 changed files with 2094 additions and 1447 deletions
|
@ -248,11 +248,6 @@
|
|||
></script>
|
||||
|
||||
<script type="text/javascript" src="../js/libphonenumber-util.js"></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="../js/keychange_listener.js"
|
||||
data-cover
|
||||
></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="../js/expiring_messages.js"
|
||||
|
@ -313,7 +308,6 @@
|
|||
<script type="text/javascript" src="views/list_view_test.js"></script>
|
||||
|
||||
<script type="text/javascript" src="libphonenumber_util_test.js"></script>
|
||||
<script type="text/javascript" src="keychange_listener_test.js"></script>
|
||||
<script type="text/javascript" src="reliable_trigger_test.js"></script>
|
||||
<script type="text/javascript" src="database_test.js"></script>
|
||||
<script type="text/javascript" src="i18n_test.js"></script>
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
// Copyright 2017-2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
/* global ConversationController, SignalProtocolStore, Whisper */
|
||||
|
||||
describe('KeyChangeListener', () => {
|
||||
const STORAGE_KEYS_TO_RESTORE = ['number_id', 'uuid_id'];
|
||||
const oldStorageValues = new Map();
|
||||
|
||||
const phoneNumberWithKeyChange = '+13016886524'; // nsa
|
||||
const addressString = `${phoneNumberWithKeyChange}.1`;
|
||||
const oldKey = window.Signal.Crypto.getRandomBytes(33);
|
||||
const newKey = window.Signal.Crypto.getRandomBytes(33);
|
||||
let store;
|
||||
|
||||
before(async () => {
|
||||
window.ConversationController.reset();
|
||||
await window.ConversationController.load();
|
||||
|
||||
STORAGE_KEYS_TO_RESTORE.forEach(key => {
|
||||
oldStorageValues.set(key, window.textsecure.storage.get(key));
|
||||
});
|
||||
window.textsecure.storage.put('number_id', '+14155555556.2');
|
||||
window.textsecure.storage.put('uuid_id', `${window.getGuid()}.2`);
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await window.Signal.Data.removeAll();
|
||||
await window.storage.fetch();
|
||||
|
||||
oldStorageValues.forEach((oldValue, key) => {
|
||||
if (oldValue) {
|
||||
window.textsecure.storage.put(key, oldValue);
|
||||
} else {
|
||||
window.textsecure.storage.remove(key);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
let convo;
|
||||
|
||||
beforeEach(async () => {
|
||||
window.ConversationController.reset();
|
||||
await window.ConversationController.load();
|
||||
await window.ConversationController.loadPromise();
|
||||
|
||||
convo = window.ConversationController.dangerouslyCreateAndAdd({
|
||||
id: phoneNumberWithKeyChange,
|
||||
type: 'private',
|
||||
});
|
||||
await window.Signal.Data.saveConversation(convo.attributes);
|
||||
|
||||
store = new SignalProtocolStore();
|
||||
await store.hydrateCaches();
|
||||
Whisper.KeyChangeListener.init(store);
|
||||
return store.saveIdentity(addressString, oldKey);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await window.Signal.Data.removeAllMessagesInConversation(convo.id, {
|
||||
logId: phoneNumberWithKeyChange,
|
||||
MessageCollection: Whisper.MessageCollection,
|
||||
});
|
||||
await window.Signal.Data.removeConversation(convo.id, {
|
||||
Conversation: Whisper.Conversation,
|
||||
});
|
||||
|
||||
await store.removeIdentityKey(phoneNumberWithKeyChange);
|
||||
});
|
||||
|
||||
describe('When we have a conversation with this contact', () => {
|
||||
it('generates a key change notice in the private conversation with this contact', done => {
|
||||
const original = convo.addKeyChange;
|
||||
convo.addKeyChange = keyChangedId => {
|
||||
assert.equal(phoneNumberWithKeyChange, keyChangedId);
|
||||
convo.addKeyChange = original;
|
||||
done();
|
||||
};
|
||||
store.saveIdentity(addressString, newKey);
|
||||
});
|
||||
});
|
||||
|
||||
describe('When we have a group with this contact', () => {
|
||||
let groupConvo;
|
||||
|
||||
beforeEach(async () => {
|
||||
groupConvo = ConversationController.dangerouslyCreateAndAdd({
|
||||
id: 'groupId',
|
||||
type: 'group',
|
||||
members: [convo.id],
|
||||
});
|
||||
await window.Signal.Data.saveConversation(groupConvo.attributes);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await window.Signal.Data.removeAllMessagesInConversation(groupConvo.id, {
|
||||
logId: phoneNumberWithKeyChange,
|
||||
MessageCollection: Whisper.MessageCollection,
|
||||
});
|
||||
await window.Signal.Data.removeConversation(groupConvo.id, {
|
||||
Conversation: Whisper.Conversation,
|
||||
});
|
||||
});
|
||||
|
||||
it('generates a key change notice in the group conversation with this contact', done => {
|
||||
const original = groupConvo.addKeyChange;
|
||||
groupConvo.addKeyChange = keyChangedId => {
|
||||
assert.equal(phoneNumberWithKeyChange, keyChangedId);
|
||||
groupConvo.addKeyChange = original;
|
||||
done();
|
||||
};
|
||||
|
||||
store.saveIdentity(addressString, newKey);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue