Skip to content

Commit 6684482

Browse files
committed
Skip native Crypto tests if native lib is not available
1 parent dcd28fa commit 6684482

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

test/crypto/eax.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ function testAESEAX() {
125125
});
126126
}
127127

128+
/* eslint-disable no-invalid-this */
128129
module.exports = () => describe('Symmetric AES-EAX', function() {
129130
let sinonSandbox;
130131
let getWebCryptoStub;
@@ -142,6 +143,11 @@ module.exports = () => describe('Symmetric AES-EAX', function() {
142143
};
143144

144145
describe('Symmetric AES-EAX (native)', function() {
146+
before(function () {
147+
const detectNative = () => !!(util.getWebCrypto() || util.getNodeCrypto());
148+
if (!detectNative()) { this.skip(); }
149+
});
150+
145151
beforeEach(function () {
146152
sinonSandbox = sandbox.create();
147153
enableNative();

test/crypto/rsa.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ module.exports = () => describe('basic RSA cryptography', function () {
2525
sinonSandbox.restore();
2626
});
2727

28+
const detectNative = () => !!(util.getWebCrypto() || util.getNodeCrypto());
29+
2830
const disableNative = () => {
2931
enableNative();
3032
// stubbed functions return undefined
@@ -105,6 +107,8 @@ module.exports = () => describe('basic RSA cryptography', function () {
105107
});
106108

107109
it('compare native crypto and bnSign', async function() {
110+
if (!detectNative()) { this.skip(); }
111+
108112
const bits = 1024;
109113
const { publicParams, privateParams } = await crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits);
110114
const { n, e, d, p, q, u } = { ...publicParams, ...privateParams };
@@ -120,6 +124,8 @@ module.exports = () => describe('basic RSA cryptography', function () {
120124
});
121125

122126
it('compare native crypto and bnVerify', async function() {
127+
if (!detectNative()) { this.skip(); }
128+
123129
const bits = 1024;
124130
const { publicParams, privateParams } = await crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits);
125131
const { n, e, d, p, q, u } = { ...publicParams, ...privateParams };

0 commit comments

Comments
 (0)