test: add hasCrypto when using binding('crypto')
Currently, when configured --without-ssl tests that use process.binding('crypto') fail with the following error: === release test-accessor-properties === Path: parallel/test-accessor-properties node/test/parallel/test-accessor-properties.js:16 const crypto = process.binding('crypto'); ^ Error: No such module: crypto at Object.<anonymous> (test-accessor-properties.js:16:24) at Module._compile (module.js:660:30) at Object.Module._extensions..js (module.js:671:10) at Module.load (module.js:577:32) at tryModuleLoad (module.js:517:12) at Function.Module._load (module.js:509:3) at Function.Module.runMain (module.js:701:10) at startup (bootstrap_node.js:194:16) at bootstrap_node.js:645:3 This commit adds a hasCrypto check. PR-URL: https://github.com/nodejs/node/pull/17867 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
acbe00792d
commit
6fc9c331c6
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
// This tests that the accessor properties do not raise assertions
|
// This tests that the accessor properties do not raise assertions
|
||||||
// when called with incompatible receivers.
|
// when called with incompatible receivers.
|
||||||
@ -12,9 +12,6 @@ const assert = require('assert');
|
|||||||
const TTY = process.binding('tty_wrap').TTY;
|
const TTY = process.binding('tty_wrap').TTY;
|
||||||
const UDP = process.binding('udp_wrap').UDP;
|
const UDP = process.binding('udp_wrap').UDP;
|
||||||
|
|
||||||
// There are accessor properties in crypto too
|
|
||||||
const crypto = process.binding('crypto');
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Should throw instead of raise assertions
|
// Should throw instead of raise assertions
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
@ -33,15 +30,6 @@ const crypto = process.binding('crypto');
|
|||||||
UDP.prototype.fd;
|
UDP.prototype.fd;
|
||||||
}, TypeError);
|
}, TypeError);
|
||||||
|
|
||||||
assert.throws(() => {
|
|
||||||
crypto.SecureContext.prototype._external;
|
|
||||||
}, TypeError);
|
|
||||||
|
|
||||||
assert.throws(() => {
|
|
||||||
crypto.Connection.prototype._external;
|
|
||||||
}, TypeError);
|
|
||||||
|
|
||||||
|
|
||||||
// Should not throw for Object.getOwnPropertyDescriptor
|
// Should not throw for Object.getOwnPropertyDescriptor
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
typeof Object.getOwnPropertyDescriptor(TTY.prototype, 'bytesRead'),
|
typeof Object.getOwnPropertyDescriptor(TTY.prototype, 'bytesRead'),
|
||||||
@ -63,15 +51,28 @@ const crypto = process.binding('crypto');
|
|||||||
'object'
|
'object'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.strictEqual(
|
if (common.hasCrypto) { // eslint-disable-line crypto-check
|
||||||
typeof Object.getOwnPropertyDescriptor(
|
// There are accessor properties in crypto too
|
||||||
crypto.SecureContext.prototype, '_external'),
|
const crypto = process.binding('crypto');
|
||||||
'object'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.throws(() => {
|
||||||
typeof Object.getOwnPropertyDescriptor(
|
crypto.SecureContext.prototype._external;
|
||||||
crypto.Connection.prototype, '_external'),
|
}, TypeError);
|
||||||
'object'
|
|
||||||
);
|
assert.throws(() => {
|
||||||
|
crypto.Connection.prototype._external;
|
||||||
|
}, TypeError);
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
typeof Object.getOwnPropertyDescriptor(
|
||||||
|
crypto.SecureContext.prototype, '_external'),
|
||||||
|
'object'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
typeof Object.getOwnPropertyDescriptor(
|
||||||
|
crypto.Connection.prototype, '_external'),
|
||||||
|
'object'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
// to pass to the internal binding layer.
|
// to pass to the internal binding layer.
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { mapToHeaders } = require('internal/http2/util');
|
const { mapToHeaders } = require('internal/http2/util');
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// Flags: --expose-internals
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
require('../common');
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
// Test coverage for the updateOptionsBuffer method used internally
|
// Test coverage for the updateOptionsBuffer method used internally
|
||||||
// by the http2 implementation.
|
// by the http2 implementation.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user