1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-24 01:42:20 -05:00

Properly mock publickey requests

This commit is contained in:
Tankred Hase 2015-08-05 14:10:29 +02:00
parent aa24881efc
commit 8636ba201b

View File

@ -249,6 +249,7 @@ describe('Email DAO integration tests', function() {
function onCleaned() { function onCleaned() {
userStorage = accountService._accountStore; userStorage = accountService._accountStore;
auth = accountService._auth; auth = accountService._auth;
emailDao = accountService._emailDao;
auth.setCredentials({ auth.setCredentials({
emailAddress: testAccount.user, emailAddress: testAccount.user,
@ -257,19 +258,17 @@ describe('Email DAO integration tests', function() {
imap: {} // a preconfigured smtpclient with mocked tcp sockets imap: {} // a preconfigured smtpclient with mocked tcp sockets
}); });
// stub rest request to key server
sinon.stub(emailDao._keychain._publicKeyDao, 'get').returns(resolves(mockKeyPair.publicKey));
sinon.stub(emailDao._keychain._publicKeyDao, 'getByUserId').returns(resolves(mockKeyPair.publicKey));
auth.init().then(function() { auth.init().then(function() {
accountService.init({ accountService.init({
emailAddress: testAccount.user emailAddress: testAccount.user
}).then(function() { }).then(function() {
emailDao = accountService._emailDao;
// retrieve the pgpbuilder from the emaildao and initialize the pgpmailer with the existing pgpbuilder // retrieve the pgpbuilder from the emaildao and initialize the pgpmailer with the existing pgpbuilder
pgpMailer = new PgpMailer({}, emailDao._pgpbuilder); pgpMailer = new PgpMailer({}, emailDao._pgpbuilder);
// stub rest request to key server
sinon.stub(emailDao._keychain._publicKeyDao, 'get').returns(resolves(mockKeyPair.publicKey));
sinon.stub(emailDao._keychain._publicKeyDao, 'getByUserId').returns(resolves(mockKeyPair.publicKey));
emailDao.unlock({ emailDao.unlock({
passphrase: testAccount.pass, passphrase: testAccount.pass,
keypair: mockKeyPair keypair: mockKeyPair