Fix integration tests for verification email matching

This commit is contained in:
Tankred Hase
2017-08-19 17:52:15 +08:00
committed by Martin Hauck
parent 0852822055
commit 92df122435
2 changed files with 22 additions and 12 deletions

View File

@@ -7,6 +7,7 @@ const Email = require('../../src/email/email');
const Mongo = require('../../src/dao/mongo');
const PGP = require('../../src/service/pgp');
const PublicKey = require('../../src/service/public-key');
const templates = require('../../src/email/templates');
describe('Public Key Integration Tests', function() {
this.timeout(20000);
@@ -37,19 +38,24 @@ describe('Public Key Integration Tests', function() {
sandbox = sinon.sandbox.create();
await mongo.clear(DB_TYPE);
mailsSent = [];
sendEmailStub = sinon.stub().returns(Promise.resolve({response: '250'}));
sendEmailStub.withArgs(sinon.match(recipient => {
mailsSent[mailsSent.length] = {to: recipient.to.address};
return true;
}), sinon.match(params => {
mailsSent[mailsSent.length - 1].params = params;
const paramMatcher = sinon.match(params => {
mailsSent[mailsSent.length] = {params};
expect(params.nonce).to.exist;
expect(params.keyId).to.exist;
return true;
});
sandbox.spy(templates, 'verifyKey').withArgs(paramMatcher);
sandbox.spy(templates, 'verifyRemove').withArgs(paramMatcher);
sendEmailStub = sinon.stub().returns(Promise.resolve({response: '250'}));
sendEmailStub.withArgs(sinon.match(sendOptions => {
mailsSent[mailsSent.length - 1].to = sendOptions.to.address;
return true;
}));
sandbox.stub(nodemailer, 'createTransport').returns({
templateSender: () => sendEmailStub
sendMail: sendEmailStub
});
email = new Email(nodemailer);
email.init({