Rebase onto dev/pgp-inline, fix unit tests

This commit is contained in:
Martin Hauck
2019-02-08 17:04:28 +01:00
parent a2b941b0ae
commit 1651571d36
14 changed files with 58 additions and 77 deletions

View File

@@ -11,7 +11,7 @@ const log = require('winston');
describe('Koa App (HTTP Server) Integration Tests', function() {
this.timeout(20000);
let sandbox;
const sandbox = sinon.createSandbox();
let app;
let mongo;
let sendEmailStub;
@@ -24,8 +24,6 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
const fingerprint = '4277257930867231CE393FB8DBC0B3D92B1B86E9';
before(async () => {
sandbox = sinon.sandbox.create();
sandbox.stub(log);
publicKeyArmored = fs.readFileSync(`${__dirname}/../key1.asc`, 'utf8');

View File

@@ -8,11 +8,10 @@ describe('Mongo Integration Tests', function() {
this.timeout(20000);
const DB_TYPE = 'apple';
let sandbox;
const sandbox = sinon.createSandbox();
let mongo;
before(async () => {
sandbox = sinon.sandbox.create();
sandbox.stub(log);
mongo = new Mongo();

View File

@@ -12,7 +12,7 @@ const templates = require('../../src/email/templates');
describe('Public Key Integration Tests', function() {
this.timeout(20000);
let sandbox;
const sandbox = sinon.createSandbox();
let publicKey;
let email;
let mongo;
@@ -35,8 +35,6 @@ describe('Public Key Integration Tests', function() {
});
beforeEach(async () => {
sandbox = sinon.sandbox.create();
await mongo.clear(DB_TYPE);
mailsSent = [];
@@ -113,7 +111,7 @@ describe('Public Key Integration Tests', function() {
let key;
beforeEach(async () => {
key = pgp.parseKey(publicKeyArmored);
key = await pgp.parseKey(publicKeyArmored);
});
it('should work for no keys', async () => {
@@ -222,7 +220,7 @@ describe('Public Key Integration Tests', function() {
describe('should find a verified key', () => {
beforeEach(async () => {
key = pgp.parseKey(publicKeyArmored);
key = await pgp.parseKey(publicKeyArmored);
await publicKey.put({publicKeyArmored, origin});
await publicKey.verify(mailsSent[0].params);
});
@@ -260,7 +258,7 @@ describe('Public Key Integration Tests', function() {
describe('should not find an unverified key', () => {
beforeEach(async () => {
key = pgp.parseKey(publicKeyArmored);
key = await pgp.parseKey(publicKeyArmored);
key.userIds[0].verified = false;
await mongo.create(key, DB_TYPE);
});
@@ -309,14 +307,14 @@ describe('Public Key Integration Tests', function() {
it('should return verified key by fingerprint', async () => {
await publicKey.verify(emailParams);
const fingerprint = pgp.parseKey(publicKeyArmored).fingerprint;
const fingerprint = (await pgp.parseKey(publicKeyArmored)).fingerprint;
const key = await publicKey.get({fingerprint});
expect(key.publicKeyArmored).to.exist;
});
it('should return verified key by fingerprint (uppercase)', async () => {
await publicKey.verify(emailParams);
const fingerprint = pgp.parseKey(publicKeyArmored).fingerprint.toUpperCase();
const fingerprint = (await pgp.parseKey(publicKeyArmored)).fingerprint.toUpperCase();
const key = await publicKey.get({fingerprint});
expect(key.publicKeyArmored).to.exist;
});