Skip native Crypto tests if native lib is not available
This commit is contained in:
parent
dcd28fadc6
commit
66844826c6
|
@ -125,6 +125,7 @@ function testAESEAX() {
|
|||
});
|
||||
}
|
||||
|
||||
/* eslint-disable no-invalid-this */
|
||||
module.exports = () => describe('Symmetric AES-EAX', function() {
|
||||
let sinonSandbox;
|
||||
let getWebCryptoStub;
|
||||
|
@ -142,6 +143,11 @@ module.exports = () => describe('Symmetric AES-EAX', function() {
|
|||
};
|
||||
|
||||
describe('Symmetric AES-EAX (native)', function() {
|
||||
before(function () {
|
||||
const detectNative = () => !!(util.getWebCrypto() || util.getNodeCrypto());
|
||||
if (!detectNative()) { this.skip(); }
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
sinonSandbox = sandbox.create();
|
||||
enableNative();
|
||||
|
|
|
@ -25,6 +25,8 @@ module.exports = () => describe('basic RSA cryptography', function () {
|
|||
sinonSandbox.restore();
|
||||
});
|
||||
|
||||
const detectNative = () => !!(util.getWebCrypto() || util.getNodeCrypto());
|
||||
|
||||
const disableNative = () => {
|
||||
enableNative();
|
||||
// stubbed functions return undefined
|
||||
|
@ -105,6 +107,8 @@ module.exports = () => describe('basic RSA cryptography', function () {
|
|||
});
|
||||
|
||||
it('compare native crypto and bnSign', async function() {
|
||||
if (!detectNative()) { this.skip(); }
|
||||
|
||||
const bits = 1024;
|
||||
const { publicParams, privateParams } = await crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits);
|
||||
const { n, e, d, p, q, u } = { ...publicParams, ...privateParams };
|
||||
|
@ -120,6 +124,8 @@ module.exports = () => describe('basic RSA cryptography', function () {
|
|||
});
|
||||
|
||||
it('compare native crypto and bnVerify', async function() {
|
||||
if (!detectNative()) { this.skip(); }
|
||||
|
||||
const bits = 1024;
|
||||
const { publicParams, privateParams } = await crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits);
|
||||
const { n, e, d, p, q, u } = { ...publicParams, ...privateParams };
|
||||
|
|
Loading…
Reference in New Issue
Block a user