From 9bf7bbf45e9cc1f6006b680f51239e30d24a5fd7 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Fri, 27 Jul 2018 18:30:30 +0200 Subject: [PATCH] Don't generate a new key for each encryption mode in tests --- test/general/openpgp.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/general/openpgp.js b/test/general/openpgp.js index 7b39c59d..3560ad02 100644 --- a/test/general/openpgp.js +++ b/test/general/openpgp.js @@ -354,6 +354,18 @@ function withCompression(tests) { describe('OpenPGP.js public api tests', function() { + let rsaGenStub; + let rsaGenValue = openpgp.crypto.publicKey.rsa.generate(openpgp.util.getWebCryptoAll() ? 2048 : 512, "10001"); + + beforeEach(function() { + rsaGenStub = stub(openpgp.crypto.publicKey.rsa, 'generate'); + rsaGenStub.returns(rsaGenValue); + }); + + afterEach(function() { + rsaGenStub.restore(); + }); + describe('initWorker, getWorker, destroyWorker - unit tests', function() { afterEach(function() { openpgp.destroyWorker(); // cleanup worker in case of failure @@ -373,18 +385,6 @@ describe('OpenPGP.js public api tests', function() { }); describe('generateKey - validate user ids', function() { - let rsaGenStub; - let rsaGenValue = openpgp.crypto.publicKey.rsa.generate(openpgp.util.getWebCryptoAll() ? 2048 : 512, "10001"); - - beforeEach(function() { - rsaGenStub = stub(openpgp.crypto.publicKey.rsa, 'generate'); - rsaGenStub.returns(rsaGenValue); - }); - - afterEach(function() { - rsaGenStub.restore(); - }); - it('should fail for invalid user name', async function() { const opt = { userIds: [{ name: {}, email: 'text@example.com' }]