2015-09-07 21:53:43 +00:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
2015-07-22 19:48:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
describe('Device storage', function() {
|
2016-04-22 20:39:05 +00:00
|
|
|
var store = textsecure.storage.protocol;
|
2015-07-22 19:48:08 +00:00
|
|
|
var identifier = '+5558675309';
|
|
|
|
var another_identifier = '+5555590210';
|
2016-04-27 22:21:44 +00:00
|
|
|
var prekeys, identityKey, testKey;
|
|
|
|
this.timeout(5000);
|
|
|
|
before(function(done) {
|
|
|
|
localStorage.clear();
|
|
|
|
libsignal.util.generateIdentityKeyPair().then(function(identityKey) {
|
|
|
|
return textsecure.storage.protocol.putIdentityKey(identifier, identityKey);
|
|
|
|
}).then(done);
|
|
|
|
});
|
2015-07-22 19:48:08 +00:00
|
|
|
describe('saveKeysToDeviceObject', function() {
|
|
|
|
it('rejects if the identity key changes', function(done) {
|
|
|
|
return textsecure.storage.devices.saveKeysToDeviceObject({
|
2016-04-27 22:21:44 +00:00
|
|
|
identityKey: textsecure.crypto.getRandomBytes(33),
|
2015-07-22 19:48:08 +00:00
|
|
|
encodedNumber: identifier + '.1'
|
|
|
|
}).then(function() {
|
2016-04-27 22:21:44 +00:00
|
|
|
done(new Error('Allowed to overwrite identity key'));
|
|
|
|
}).catch(function(e) {
|
|
|
|
assert.strictEqual(e.message, 'Identity key changed');
|
|
|
|
done();
|
2015-07-22 19:48:08 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|