signal-desktop/libtextsecure/test/protocol_wrapper_test.js
Scott Nonnenberg cfe0bd0e79 Move to npm for several dependencies
mustache
jQuery
underscore
backbone
mocha
chai
intl-tel-input
2018-05-23 16:26:48 -07:00

39 lines
1.2 KiB
JavaScript

'use strict';
describe('Protocol Wrapper', function() {
var store = textsecure.storage.protocol;
var identifier = '+5558675309';
var another_identifier = '+5555590210';
var prekeys, identityKey, testKey;
this.timeout(5000);
before(function(done) {
localStorage.clear();
libsignal.KeyHelper.generateIdentityKeyPair()
.then(function(identityKey) {
return textsecure.storage.protocol.saveIdentity(
identifier,
identityKey
);
})
.then(function() {
done();
});
});
describe('processPreKey', function() {
it('rejects if the identity key changes', function() {
var address = new libsignal.SignalProtocolAddress(identifier, 1);
var builder = new libsignal.SessionBuilder(store, address);
return builder
.processPreKey({
identityKey: textsecure.crypto.getRandomBytes(33),
encodedNumber: address.toString(),
})
.then(function() {
throw new Error('Allowed to overwrite identity key');
})
.catch(function(e) {
assert.strictEqual(e.message, 'Identity key changed');
});
});
});
});