1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-02 05:42:20 -05:00
mail/test/integration/email-dao-test.js
2014-06-17 12:56:31 +02:00

422 lines
40 KiB
JavaScript

define(function(require) {
'use strict';
var expect = chai.expect,
ImapClient = require('imap-client'),
BrowserCrow = require('browsercrow'),
BrowserSMTP = require('browsersmtp'),
SmtpClient = require('smtpclient'),
appController = require('js/app-controller'),
mailreader = require('mailreader'),
openpgp = require('openpgp'),
PgpMailer = require('pgpmailer');
describe('Email DAO integration tests', function() {
this.timeout(100000);
chai.Assertion.includeStack = true;
var emailDao, imapClient, imapMessages, imapFolders, imapServer, smtpServer, smtpClient, userStorage,
mockKeyPair;
var testAccount = {
user: 'safewithme.testuser@gmail.com',
pass: 'passphrase',
xoauth2: 'testtoken'
};
beforeEach(function(done) {
imapMessages = [{
raw: 'Message-id: <a>\r\nSubject: hello 1\r\n\r\nWorld 1!',
internaldate: '14-Sep-2013 21:22:28 -0300',
uid: 500
}, {
raw: 'Message-id: <b>\r\nSubject: hello 2\r\n\r\nWorld 2!',
flags: ['\\Seen'],
uid: 600
}, {
raw: 'Message-id: <c>\r\nSubject: hello 3\r\n\r\nWorld 3!'
}, {
raw: 'From: sender name <sender@example.com>\r\n' +
'To: Receiver name <receiver@example.com>\r\n' +
'Subject: hello 4\r\n' +
'Message-Id: <d>\r\n' +
'Date: Fri, 13 Sep 2013 15:01:00 +0300\r\n' +
'\r\n' +
'World 4!'
}, {
raw: 'Message-id: <e>\r\nSubject: hello 5\r\n\r\nWorld 5!'
}, {
raw: 'Message-id: <f>Subject: hello 6\r\n\r\nWorld 6!'
}, {
raw: 'Message-id: <g>\nFrom: safewithme.testuser@gmail.com\nTo: safewithme.testuser@gmail.com\nSubject: enigmail encrypted pgp/mime with attachment\nContent-Type: multipart/encrypted;\n protocol=\"application/pgp-encrypted\";\n boundary=\"abc\"\n\nThis is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)\n--abc\nContent-Type: application/pgp-encrypted\nContent-Description: PGP/MIME version identification\n\nVersion: 1\n\n--abc\nContent-Type: application/octet-stream; name=\"encrypted.asc\"\nContent-Description: OpenPGP encrypted message\nContent-Disposition: inline; filename=\"encrypted.asc\"\n\n-----BEGIN PGP MESSAGE-----\nVersion: GnuPG/MacGPG2 v2.0.22 (Darwin)\nComment: GPGTools - http://gpgtools.org\nComment: Using GnuPG with Thunderbird - http://www.enigmail.net/\n\nhQEMA9f7k/zfv8I8AQf/XY1dJfGWb2iU0GYhZLNXkXoi7k4pnWSbRKQoVcEFoYpz\niltbJo70U6rdRziUO2VnGzsdnyi+NtpaZSXdxAKrE2KxQsPwNUziBWyTCL9WyAa/\nz9L5PldfK7H1o8C9CqC3LU6Ppwafaw2WImbPgnvwvuSD+BeAJlPQ9QyzhKmG8faq\nG67yMLm76kP1zKiEacIZng4ilGQ+K5cy43ryod/7HNQWUkHXt/E4YJXzjyNOXzYh\n5r2fbz0OIYcyFIuAIDqzDG5wtGmRc/6qVkUVdOs+H3RPCFPJjPUsRdH5kW6uiHQ2\nMMr5blSzWt0Q7cIqlZJgoMRte3VGEy0ED/oJZaIo3Mnst2ue5uIc5j6Q31nJCvJt\nY37ldHgrN+RpU6pcSjLgfkntjw5nQaV+KnNoB4BpKhODYMVZIuA8TivgVjpDFDgu\n8X/X0gMXD8l6hqMGP48g7etD+poYDWUp5DnsjuyNo2uFXDRyO5GZLM31jh2pIiQw\neoOmijPWy2/CSuMV6swNMbUryhp1idrujC5ggKeLBYARefDKD1T40PUFV88THCyL\n2NPZY1XKp2NIMH+WrJKYTqaJgSGzRKkqZOZByISAd+Ld7nm/t636sT1HoVHn9AR7\nfbiOqjvHW/AYV0TAK912QzVj/qg4PKSaMSV0CjIW3IoY1uPmYLxfSDxUmHwrnyEn\n74CkF/a3VNBTN6MX2Z6kFuswZx5LCcIgGzuZvOtoEIUl65ypWTyi51yWl/w+ieMU\nRr/Fxj5WNeUn1W34yVfB0AvNJQIwwZpiqMrYC7BPgi/1vvCaLv9mxWXtgudAHw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bwQaE1hhkzqfoy0qLY4vfKhVJ37bvFCKDNt7SyTHQOX2jOsbjVm\nL205UvBzSdSg5WVrXmO1dOeJ9kxWHbnMEg6Bf/tAYpukXcz7XEBpKa0+nlhWiImY\ntgIsOEJvP/OTtF5KFZ7yw5bLJl4sYTCYqpCh4Co7e8yM/zlNSPjvcZ9TfWyp4jxv\n=ZQ8O\n-----END PGP MESSAGE-----\n\n--abc--\n',
internaldate: '14-Sep-2013 20:22:28 -0300',
uid: 800
}, {
raw: "Message-id: <h>\nFrom: safewithme.testuser@gmail.com\nTo: safewithme.testuser@gmail.com\nSubject: enigmail encrypted signed pgp/mime with attachment\nContent-Type: multipart/encrypted;\n protocol=\"application/pgp-encrypted\";\n boundary=\"abc\"\n\nThis is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)\n--abc\nContent-Type: application/pgp-encrypted\nContent-Description: PGP/MIME version identification\n\nVersion: 1\n\n--abc\nContent-Type: application/octet-stream; name=\"encrypted.asc\"\nContent-Description: OpenPGP encrypted message\nContent-Disposition: inline; filename=\"encrypted.asc\"\n\n-----BEGIN PGP MESSAGE-----\nVersion: GnuPG/MacGPG2 v2.0.22 (Darwin)\nComment: GPGTools - http://gpgtools.org\nComment: Using GnuPG with Thunderbird - http://www.enigmail.net/\n\nhQELA9f7k/zfv8I8AQf3WUkThZZkrDcKyCmrnWoUC75EKDD6L9R40OpMNMMdYb5o\nQedZVlokwHeCFdliIVi/WtHfMsyZsT65w7C9rDtLf4l/vtE8Pg2OuTu/BYf4+O4h\nMhRKk6snqE3SQENeatsslRQFpz3/C1SgXbb9ooug8ZOD1I+/4I6xGpBbFnlJ78rX\nW33h/V/8WAXF/LRoHF1ZXLpvk7TccxviKuFI2zCLcqexD4dqbq7AqYdCIKzoAVgj\nPnBg+sGKZDredvCOVWlJS1Sf/SIWuGUWtxcoDMkUjvQ/+r+l6vwOFmtlSD3gUvxV\nj470QQS5PVk0ZBKmnA5XFn8bYqpXpgZI8p2e/eXByexjdHNgNC2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7ArubxDIwVnJkzi2xjeixG1JTfC/rPnqRG96nv8txnRG9Ko4Sc6XfF9RekATz5RJ\nEgDBPiD4Ujbf//BbR7ZRgF3C7U929ubuyb2IhlhDViidz2fN60mLkeO8/M7laPUM\n9hs0nu1rjp1n7rnP/b84x5FcOuE7TxObkQMlpd5iCp4UKmJcpwmYZMBAPjnTrSPo\nyjGWLplWnA==\n=p4q6\n-----END PGP MESSAGE-----\n\n--abc--\n",
internaldate: '14-Sep-2013 22:22:28 -0300',
uid: 801
}];
imapFolders = {
separator: '/',
folders: {
'[Gmail]': {
flags: ['\\Noselect'],
folders: {
'All Mail': {
'special-use': '\\All'
},
Drafts: {
'special-use': '\\Drafts'
},
Important: {
'special-use': '\\Important'
},
'Sent Mail': {
'special-use': '\\Sent'
},
Spam: {
'special-use': '\\Junk'
},
Starred: {
'special-use': '\\Flagged'
},
Trash: {
'special-use': '\\Trash'
}
}
}
}
};
var serverUsers = {};
serverUsers[testAccount.user] = {
password: testAccount.pass,
xoauth2: {
accessToken: testAccount.xoauth2,
sessionTimeout: 3600 * 1000
}
};
imapServer = new BrowserCrow({
debug: false,
plugins: ['sasl-ir', 'xoauth2', 'special-use', 'id', 'idle', 'unselect', 'enable', 'condstore'],
id: {
name: 'browsercrow',
version: '0.1.0'
},
storage: {
'INBOX': {
messages: imapMessages
},
'': imapFolders
},
users: serverUsers
});
smtpServer = new BrowserSMTP({
debug: false,
users: serverUsers
});
mockKeyPair = {
privateKey: {
_id: '0A45D6B44958B0AC',
userId: testAccount.user,
encryptedKey: '-----BEGIN PGP PRIVATE KEY BLOCK-----\r\nVersion: OpenPGP.js v.1.20131116\r\nComment: Whiteout Mail - http://whiteout.io\r\n\r\nxcL+BFKODs4BB/9iOF4THsjQMY+WEpT7ShgKxj4bHzRRaQkqczS4nZvP0U3g\r\nqeqCnbpagyeKXA+bhWFQW4GmXtgAoeD5PXs6AZYrw3tWNxLKu2Oe6Tp9K/XI\r\nxTMQ2wl4qZKDXHvuPsJ7c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2BgP4Kbh9JqhnD/2NKD/csuL6No5guyOH8+zekdBtFE394SV8e9N+\r\nzYgzVex4SDG8y/YO7W7Tp6afNb+sqyzEw5Bknypn0Hc3cr9wy1P8jLMM2woL\r\nGRDZ5IutCAV/D/h881dHJs0tV2hpdGVvdXQgVXNlciA8c2FmZXdpdGhtZS50\r\nZXN0dXNlckBnbWFpbC5jb20+wsBcBBABCAAQBQJSjg7aCRDX+5P837/CPAAA\r\n3ZwH/2AVGYB+8RDarP5a5uZPYSxJKeM8zHMbi7LKQWhr5NpkJajZdra1CCGZ\r\nTXTeQSRBvU4SNGOmDAlhf0qCGeXwMHIzrzovkBedHIc/vypEkItdJeXQAaJx\r\nuhQOnmyi9priuzBBx4e9x1aBn+aAdNGiJB4l13L2T4fow8WLIVpVwXB6BWya\r\nlz50JwLzJP6qHxkhvIZElTrQ+Yoo3stS6w/7wNtK/f3MIYkIGVVUrIDgzN0X\r\nm4z6ypN1dsrM6tPkMZ0JlqjHiz7DXpKrWsfNkoVZ9A98osMH2nIDS58JVEDc\r\nAXoFSLsbdmqFmIc2Ew828TjlX+FLU9tlx89WhSMTapzUjHU=\r\n=wxuK\r\n-----END PGP PRIVATE KEY BLOCK-----'
},
publicKey: {
_id: '0A45D6B44958B0AC',
userId: testAccount.user,
publicKey: '-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nVersion: OpenPGP.js v.1.20131116\r\nComment: Whiteout Mail - http://whiteout.io\r\n\r\nxsBNBFKODs4BB/9iOF4THsjQMY+WEpT7ShgKxj4bHzRRaQkqczS4nZvP0U3g\r\nqeqCnbpagyeKXA+bhWFQW4GmXtgAoeD5PXs6AZYrw3tWNxLKu2Oe6Tp9K/XI\r\nxTMQ2wl4qZKDXHvuPsJ7cmgaWqpPyXtxA4zHHS3WrkI/6VzHAcI/y6x4szSB\r\nKgSuhI3hjh3s7TybUC1U6AfoQGx/S7e3WwlCOrK8GTClirN/2mCPRC5wuIft\r\nnkoMfA6jK8d2OPrJ63shy5cgwHOjQg/xuk46dNS7tkvGmbaa+X0PgqSKB+Hf\r\nYPPNS/ylg911DH9qa8BqYU2QpNh9jUKXSF+HbaOM+plWkCSAL7czV+R3ABEB\r\nAAHNLVdoaXRlb3V0IFVzZXIgPHNhZmV3aXRobWUudGVzdHVzZXJAZ21haWwu\r\nY29tPsLAXAQQAQgAEAUCUo4O2gkQ1/uT/N+/wjwAAN2cB/9gFRmAfvEQ2qz+\r\nWubmT2EsSSnjPMxzG4uyykFoa+TaZCWo2Xa2tQghmU103kEkQb1OEjRjpgwJ\r\nYX9Kghnl8DByM686L5AXnRyHP78qRJCLXSXl0AGicboUDp5sovaa4rswQceH\r\nvcdWgZ/mgHTRoiQeJddy9k+H6MPFiyFaVcFwegVsmpc+dCcC8yT+qh8ZIbyG\r\nRJU60PmKKN7LUusP+8DbSv39zCGJCBlVVKyA4MzdF5uM+sqTdXbKzOrT5DGd\r\nCZaox4s+w16Sq1rHzZKFWfQPfKLDB9pyA0ufCVRA3AF6BUi7G3ZqhZiHNhMP\r\nNvE45V/hS1PbZcfPVoUjE2qc1Ix1\r\n=7Wpe\r\n-----END PGP PUBLIC KEY BLOCK-----'
}
};
// don't multithread, Function.prototype.bind() is broken in phantomjs in web workers
window.Worker = undefined;
navigator.online = true;
imapClient = new ImapClient({
auth: {
user: testAccount.user,
xoauth2: testAccount.xoauth2
},
secure: true,
ca: ['random string']
});
imapClient._client.client._TCPSocket = imapServer.createTCPSocket();
imapClient._listeningClient.client._TCPSocket = imapServer.createTCPSocket();
imapClient.onError = function(err) {
console.log('IMAP error.', err);
console.log('IMAP reconnecting...');
// re-init client modules on error
appController.onConnect(function(err) {
if (err) {
console.error('IMAP reconnect failed!', err);
return;
}
console.log('IMAP reconnect attempt complete.');
});
};
smtpClient = new SmtpClient('localhost', 25, {
auth: {
user: testAccount.user,
xoauth2: testAccount.xoauth2
},
secure: true,
ca: ['random string'],
onError: console.error
});
smtpClient._TCPSocket = smtpServer.createTCPSocket();
sinon.stub(mailreader, 'startWorker', function() {});
sinon.stub(openpgp, 'initWorker', function() {});
sinon.stub(appController, 'onConnect', function(cb) {
appController._emailDao.onConnect({
imapClient: imapClient,
pgpMailer: new PgpMailer({
tls: {
ca: 'random string'
}
}, appController._pgpbuilder)
}, cb);
});
appController.start({
onError: function() {}
}, function(err) {
expect(err).to.not.exist;
userStorage = appController._userStorage;
appController.init({
emailAddress: testAccount.user
}, function(err) {
expect(err).to.not.exist;
emailDao = appController._emailDao;
emailDao.onIncomingMessage = function() {};
emailDao.unlock({
passphrase: testAccount.pass,
keypair: mockKeyPair
}, function(err) {
expect(err).to.not.exist;
appController.onConnect(function(err) {
expect(err).to.not.exist;
done();
});
});
});
});
});
afterEach(function(done) {
openpgp.initWorker.restore();
mailreader.startWorker.restore();
appController.onConnect.restore();
imapClient._client.close();
imapClient._listeningClient.close();
userStorage.clear(done);
});
describe('IMAP Tests', function() {
var currentFolder;
beforeEach(function(done) {
emailDao.openFolder({
folder: {
path: 'INBOX'
}
}, function(err) {
expect(err).to.not.exist;
currentFolder = emailDao._account.folders.filter(function(folder) {
return folder.path === 'INBOX';
}).pop();
expect(currentFolder).to.exist;
done();
});
});
afterEach(function() {
emailDao.onIncomingMessage = function() {};
});
it('should receive new messages on startup', function(done) {
emailDao.onIncomingMessage = function(messages) {
expect(messages.length).to.equal(imapMessages.length);
done();
};
});
it('should receive new messages', function(done) {
emailDao.onIncomingMessage = function(messages) {
expect(messages.length).to.equal(imapMessages.length);
emailDao.onIncomingMessage = function(messages) {
expect(messages.length).to.equal(1);
expect(messages[0].answered).to.be.false;
emailDao.onIncomingMessage = function(messages) {
expect(messages.length).to.equal(1);
expect(messages[0].answered).to.be.true;
done();
};
};
setTimeout(function() {
imapServer.appendMessage('INBOX', ['$My$Flag'], false, 'Message-id: <n1>\r\nSubject: new message\r\n\r\nhello world!');
setTimeout(function() {
imapServer.appendMessage('INBOX', ['$My$Flag', '\\Answered'], false, 'Message-id: <n2>\r\nSubject: new message\r\n\r\nhello world!');
}, 1000);
}, 1000);
};
});
it('should delete a message', function(done) {
emailDao.onIncomingMessage = function() {
emailDao.deleteMessage({
folder: currentFolder,
message: {
uid: 600
}
}, function(err) {
expect(err).to.not.exist;
emailDao.openFolder({
folder: {
path: '[Gmail]/Trash'
}
}, function(err, folder) {
expect(err).to.not.exist;
expect(folder.exists).to.equal(1);
emailDao.onIncomingMessage = function(messages) {
expect(messages.length).to.equal(1);
expect(messages[0].id).to.equal('b');
done();
};
});
});
};
});
it('should get body', function(done) {
emailDao.onIncomingMessage = function(messages) {
emailDao.getBody({
folder: currentFolder,
message: messages[4]
}, function(err, message) {
expect(err).to.not.exist;
expect(message.body).to.equal('World 5!');
done();
});
};
});
[{
nr: 6,
hasAttachments: true
}, {
nr: 7,
hasAttachments: true
}].forEach(function(email) {
it('should get and decrypt body #' + email.nr, function(done) {
emailDao.onIncomingMessage = function(messages) {
emailDao.getBody({
folder: currentFolder,
message: messages[email.nr]
}, function(err, message) {
expect(err).to.not.exist;
emailDao.decryptBody({
message: message,
folder: currentFolder
}, function(err) {
expect(err).to.not.exist;
expect(message.body).to.equal('asdf');
if (email.hasAttachments) {
expect(message.attachments.length).to.equal(1);
}
done();
});
});
};
});
});
it('should set flags', function(done) {
emailDao.onIncomingMessage = function(messages) {
var message = messages[0];
message.unread = false;
message.answered = true;
emailDao.setFlags({
folder: currentFolder,
message: message
}, function(err) {
expect(err).to.not.exist;
done();
});
};
});
});
describe('SMTP Tests', function() {
// phantomjs is just sooo slow
it('should send a plaintext message', function(done) {
sinon.stub(smtpServer, 'onmail', function(mail) {
expect(mail.from).to.equal(testAccount.user);
expect(mail.to).to.deep.equal([testAccount.user]);
expect(/^Content-Type: multipart\/signed/.test(mail.body)).to.be.true;
});
emailDao.sendPlaintext({
smtpclient: smtpClient,
email: {
from: [testAccount.user],
to: [testAccount.user],
subject: 'plaintext test',
body: 'hello world!'
}
}, function(err) {
expect(err).to.not.exist;
expect(smtpServer.onmail.callCount).to.equal(1);
smtpServer.onmail.restore();
done();
});
});
it('should send an encrypted message', function(done) {
sinon.stub(smtpServer, 'onmail', function(mail) {
expect(mail.from).to.equal(testAccount.user);
expect(mail.to).to.deep.equal([testAccount.user]);
expect(/^Content-Type: multipart\/mixed/.test(mail.body)).to.be.true;
expect(mail.body).to.contain('this is a private conversation');
});
emailDao.sendEncrypted({
smtpclient: smtpClient,
email: {
from: [testAccount.user],
to: [testAccount.user],
subject: 'plaintext test',
body: 'hello world!',
publicKeysArmored: [mockKeyPair.publicKey.publicKey]
}
}, function(err) {
expect(err).to.not.exist;
expect(smtpServer.onmail.callCount).to.equal(1);
smtpServer.onmail.restore();
done();
});
});
});
});
});