1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-25 18:32:20 -05:00

bugfix in cas of channel change

This commit is contained in:
Tankred Hase 2013-11-21 17:09:47 +01:00
parent c19aa10fb0
commit 9d3bc51fcf
2 changed files with 26 additions and 0 deletions

View File

@ -293,6 +293,14 @@ define(function(require) {
return;
}
if (!senderPubkey) {
// this should only happen if a mail from another channel is in the inbox
callback({
errMsg: 'No public key for the sender'
});
return;
}
// decrypt and verfiy signatures
self._crypto.decrypt(email.body, senderPubkey.publicKey, function(err, decrypted) {
if (err) {

View File

@ -598,6 +598,24 @@ define(function(require) {
});
describe('IMAP: list messages from local storage', function() {
it('should fail for empty public key', function(done) {
dummyMail.body = app.string.cryptPrefix + btoa('asdf') + app.string.cryptSuffix;
devicestorageStub.listItems.yields(null, [dummyMail]);
keychainStub.getReceiverPublicKey.yields();
emailDao.listMessages({
folder: 'INBOX',
offset: 0,
num: 1
}, function(err, emails) {
expect(err).to.exist;
expect(emails).to.not.exist;
expect(devicestorageStub.listItems.calledOnce).to.be.true;
expect(keychainStub.getReceiverPublicKey.calledOnce).to.be.true;
done();
});
});
it('should work', function(done) {
dummyMail.body = app.string.cryptPrefix + btoa('asdf') + app.string.cryptSuffix;
devicestorageStub.listItems.yields(null, [dummyMail]);