protocol_wrapper_test.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * vim: ts=4:sw=4:expandtab
  3. */
  4. 'use strict';
  5. describe('Protocol Wrapper', function() {
  6. var store = textsecure.storage.protocol;
  7. var identifier = '+5558675309';
  8. var another_identifier = '+5555590210';
  9. var prekeys, identityKey, testKey;
  10. this.timeout(5000);
  11. before(function(done) {
  12. localStorage.clear();
  13. libsignal.KeyHelper.generateIdentityKeyPair().then(function(identityKey) {
  14. return textsecure.storage.protocol.saveIdentity(identifier, identityKey);
  15. }).then(done);
  16. });
  17. describe('processPreKey', function() {
  18. it('rejects if the identity key changes', function(done) {
  19. var address = new libsignal.SignalProtocolAddress(identifier, 1);
  20. var builder = new libsignal.SessionBuilder(store, address);
  21. return builder.processPreKey({
  22. identityKey: textsecure.crypto.getRandomBytes(33),
  23. encodedNumber: address.toString()
  24. }).then(function() {
  25. done(new Error('Allowed to overwrite identity key'));
  26. }).catch(function(e) {
  27. assert.strictEqual(e.message, 'Identity key changed');
  28. done();
  29. });
  30. });
  31. });
  32. });