More descriptive tests

// FREEBIE
This commit is contained in:
lilia 2016-05-04 00:30:42 -07:00
parent f173104c82
commit 348ee0b3e7

View file

@ -20,17 +20,22 @@ describe("SignalProtocolStore", function() {
pubKey: textsecure.crypto.getRandomBytes(33), pubKey: textsecure.crypto.getRandomBytes(33),
privKey: textsecure.crypto.getRandomBytes(32), privKey: textsecure.crypto.getRandomBytes(32),
}; };
describe('getLocalRegistrationId', function() {
it('retrieves my registration id', function(done) { it('retrieves my registration id', function(done) {
store.getLocalRegistrationId().then(function(reg) { store.getLocalRegistrationId().then(function(reg) {
assert.strictEqual(reg, 1337); assert.strictEqual(reg, 1337);
}).then(done, done); }).then(done, done);
}); });
});
describe('getIdentityKeyPair', function() {
it('retrieves my identity key', function(done) { it('retrieves my identity key', function(done) {
store.getIdentityKeyPair().then(function(key) { store.getIdentityKeyPair().then(function(key) {
assertEqualArrayBuffers(key.pubKey, identityKey.pubKey); assertEqualArrayBuffers(key.pubKey, identityKey.pubKey);
assertEqualArrayBuffers(key.privKey, identityKey.privKey); assertEqualArrayBuffers(key.privKey, identityKey.privKey);
}).then(done,done); }).then(done,done);
}); });
});
describe('putIdentityKey', function() {
it('stores identity keys', function(done) { it('stores identity keys', function(done) {
store.putIdentityKey(identifier, testKey.pubKey).then(function() { store.putIdentityKey(identifier, testKey.pubKey).then(function() {
return store.loadIdentityKey(identifier).then(function(key) { return store.loadIdentityKey(identifier).then(function(key) {
@ -49,6 +54,8 @@ describe("SignalProtocolStore", function() {
}); });
}); });
}); });
});
describe('isTrustedIdentity', function() {
it('returns true if a key is trusted', function(done) { it('returns true if a key is trusted', function(done) {
store.putIdentityKey(identifier, testKey.pubKey).then(function() { store.putIdentityKey(identifier, testKey.pubKey).then(function() {
store.isTrustedIdentity(identifier, testKey.pubKey).then(function(trusted) { store.isTrustedIdentity(identifier, testKey.pubKey).then(function(trusted) {
@ -72,6 +79,8 @@ describe("SignalProtocolStore", function() {
}).catch(done); }).catch(done);
}); });
}); });
});
describe('storePreKey', function() {
it('stores prekeys', function(done) { it('stores prekeys', function(done) {
store.storePreKey(1, testKey).then(function() { store.storePreKey(1, testKey).then(function() {
return store.loadPreKey(1).then(function(key) { return store.loadPreKey(1).then(function(key) {
@ -80,6 +89,8 @@ describe("SignalProtocolStore", function() {
}); });
}).then(done,done); }).then(done,done);
}); });
});
describe('removePreKey', function() {
it('deletes prekeys', function(done) { it('deletes prekeys', function(done) {
before(function(done) { before(function(done) {
store.storePreKey(2, testKey).then(done); store.storePreKey(2, testKey).then(done);
@ -90,6 +101,8 @@ describe("SignalProtocolStore", function() {
}); });
}).then(done,done); }).then(done,done);
}); });
});
describe('storeSignedPreKey', function() {
it('stores signed prekeys', function(done) { it('stores signed prekeys', function(done) {
store.storeSignedPreKey(3, testKey).then(function() { store.storeSignedPreKey(3, testKey).then(function() {
return store.loadSignedPreKey(3).then(function(key) { return store.loadSignedPreKey(3).then(function(key) {
@ -98,6 +111,8 @@ describe("SignalProtocolStore", function() {
}); });
}).then(done,done); }).then(done,done);
}); });
});
describe('removeSignedPreKey', function() {
it('deletes signed prekeys', function(done) { it('deletes signed prekeys', function(done) {
before(function(done) { before(function(done) {
store.storeSignedPreKey(4, testKey).then(done); store.storeSignedPreKey(4, testKey).then(done);
@ -108,6 +123,8 @@ describe("SignalProtocolStore", function() {
}); });
}).then(done,done); }).then(done,done);
}); });
});
describe('storeSession', function() {
it('stores sessions', function(done) { it('stores sessions', function(done) {
var testRecord = "an opaque string"; var testRecord = "an opaque string";
store.storeSession(identifier + '.1', testRecord).then(function() { store.storeSession(identifier + '.1', testRecord).then(function() {
@ -116,6 +133,8 @@ describe("SignalProtocolStore", function() {
}); });
}).then(done,done); }).then(done,done);
}); });
});
describe('removeAllSessions', function() {
it('removes all sessions for a number', function(done) { it('removes all sessions for a number', function(done) {
var testRecord = "an opaque string"; var testRecord = "an opaque string";
var devices = [1, 2, 3].map(function(deviceId) { var devices = [1, 2, 3].map(function(deviceId) {
@ -137,6 +156,8 @@ describe("SignalProtocolStore", function() {
}); });
}).then(done,done); }).then(done,done);
}); });
});
describe('clearSessionStore', function() {
it ('clears the session store', function(done) { it ('clears the session store', function(done) {
var testRecord = "an opaque string"; var testRecord = "an opaque string";
store.storeSession(identifier + '.1', testRecord).then(function() { store.storeSession(identifier + '.1', testRecord).then(function() {
@ -148,6 +169,8 @@ describe("SignalProtocolStore", function() {
}).then(done,done); }).then(done,done);
}); });
});
describe('getDeviceIds', function() {
it('returns deviceIds for a number', function(done) { it('returns deviceIds for a number', function(done) {
var testRecord = "an opaque string"; var testRecord = "an opaque string";
var devices = [1, 2, 3].map(function(deviceId) { var devices = [1, 2, 3].map(function(deviceId) {
@ -170,4 +193,5 @@ describe("SignalProtocolStore", function() {
assert.sameMembers(deviceIds,[]); assert.sameMembers(deviceIds,[]);
}).then(done,done); }).then(done,done);
}); });
});
}); });