Tests for isTrustedIdentity

// FREEBIE
This commit is contained in:
lilia 2016-05-04 00:09:44 -07:00
parent b385b6e48e
commit f173104c82
2 changed files with 47 additions and 0 deletions

View file

@ -37,6 +37,30 @@ describe("SignalProtocolStore", function() {
});
}).then(done,done);
});
it('returns whether a key is trusted', function(done) {
var newIdentity = textsecure.crypto.getRandomBytes(33);
store.putIdentityKey(identifier, testKey.pubKey).then(function() {
store.isTrustedIdentity(identifier, newIdentity).then(function(trusted) {
if (trusted) {
done(new Error('Allowed to overwrite identity key'));
} else {
done();
}
}).catch(done);
});
});
it('returns whether a key is untrusted', function(done) {
var newIdentity = textsecure.crypto.getRandomBytes(33);
store.putIdentityKey(identifier, testKey.pubKey).then(function() {
store.isTrustedIdentity(identifier, testKey.pubKey).then(function(trusted) {
if (trusted) {
done();
} else {
done(new Error('Allowed to overwrite identity key'));
}
}).catch(done);
});
});
it('stores prekeys', function(done) {
store.storePreKey(1, testKey).then(function() {
return store.loadPreKey(1).then(function(key) {

View file

@ -49,6 +49,29 @@ describe("SignalProtocolStore", function() {
});
});
});
it('returns true if a key is trusted', function(done) {
store.putIdentityKey(identifier, testKey.pubKey).then(function() {
store.isTrustedIdentity(identifier, testKey.pubKey).then(function(trusted) {
if (trusted) {
done();
} else {
done(new Error('Allowed to overwrite identity key'));
}
}).catch(done);
});
});
it('returns false if a key is untrusted', function(done) {
var newIdentity = textsecure.crypto.getRandomBytes(33);
store.putIdentityKey(identifier, testKey.pubKey).then(function() {
store.isTrustedIdentity(identifier, newIdentity).then(function(trusted) {
if (trusted) {
done(new Error('Allowed to overwrite identity key'));
} else {
done();
}
}).catch(done);
});
});
it('stores prekeys', function(done) {
store.storePreKey(1, testKey).then(function() {
return store.loadPreKey(1).then(function(key) {