You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
| /*
 | |
|  * vim: ts=4:sw=4:expandtab
 | |
|  */
 | |
| 
 | |
| 'use strict';
 | |
| 
 | |
| describe('Device storage', function() {
 | |
|     before(function() { localStorage.clear(); });
 | |
|     var store = textsecure.storage.axolotl;
 | |
|     var identifier = '+5558675309';
 | |
|     var another_identifier = '+5555590210';
 | |
|     var identityKey = {
 | |
|         pubKey: textsecure.crypto.getRandomBytes(33),
 | |
|         privKey: textsecure.crypto.getRandomBytes(32),
 | |
|     };
 | |
|     var testKey = {
 | |
|         pubKey: textsecure.crypto.getRandomBytes(33),
 | |
|         privKey: textsecure.crypto.getRandomBytes(32),
 | |
|     };
 | |
|     describe('saveKeysToDeviceObject', function() {
 | |
|         it('rejects if the identity key changes', function(done) {
 | |
|             return textsecure.storage.devices.saveKeysToDeviceObject({
 | |
|                 identityKey: identityKey.pubKey,
 | |
|                 encodedNumber: identifier + '.1'
 | |
|             }).then(function() {
 | |
|                 textsecure.storage.devices.saveKeysToDeviceObject({
 | |
|                     identityKey: testKey.pubKey,
 | |
|                     encodedNumber: identifier + '.1'
 | |
|                 }).then(function() {
 | |
|                     done(new Error('Allowed to overwrite identity key'));
 | |
|                 }).catch(function(e) {
 | |
|                     assert.strictEqual(e.message, 'Identity key changed');
 | |
|                     done();
 | |
|                 });
 | |
|             });
 | |
|         });
 | |
|     });
 | |
| });
 |