GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: fix test when compiled without engine support · nodejs/node@d6114cb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/addons/openssl-test-engine
    • test.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/addons/openssl-test-engine/test.js‎

Copy file name to clipboardExpand all lines: test/addons/openssl-test-engine/test.js
+35-26Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,59 @@ const crypto = require('crypto');
1111
const fs = require('fs');
1212
const path = require('path');
1313

14+
// Engine support in OpenSSL is checked later on.
15+
let hasEngineSupport = true;
1416

15-
assert.throws(() => crypto.setEngine(true), /ERR_INVALID_ARG_TYPE/);
17+
assert.throws(() => crypto.setEngine(true), /ERR_INVALID_ARG_TYPE|ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED/);
1618
assert.throws(() => crypto.setEngine('/path/to/engine', 'notANumber'),
1719
/ERR_INVALID_ARG_TYPE/);
1820

1921
{
2022
const invalidEngineName = 'xxx';
2123
assert.throws(() => crypto.setEngine(invalidEngineName),
22-
/ERR_CRYPTO_ENGINE_UNKNOWN/);
24+
/ERR_CRYPTO_ENGINE_UNKNOWN|ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED/);
2325
assert.throws(() => crypto.setEngine(invalidEngineName,
2426
crypto.constants.ENGINE_METHOD_RSA),
25-
/ERR_CRYPTO_ENGINE_UNKNOWN/);
27+
/ERR_CRYPTO_ENGINE_UNKNOWN|ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED/);
2628
}
2729

28-
crypto.setEngine('dynamic');
29-
crypto.setEngine('dynamic');
30+
try {
31+
crypto.setEngine('dynamic');
32+
crypto.setEngine('dynamic');
3033

31-
crypto.setEngine('dynamic', crypto.constants.ENGINE_METHOD_RSA);
32-
crypto.setEngine('dynamic', crypto.constants.ENGINE_METHOD_RSA);
34+
crypto.setEngine('dynamic', crypto.constants.ENGINE_METHOD_RSA);
35+
crypto.setEngine('dynamic', crypto.constants.ENGINE_METHOD_RSA);
36+
} catch (err) {
37+
assert.strictEqual(err.code, 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED');
38+
hasEngineSupport = false;
39+
}
3340

34-
const engine = path.join(__dirname,
35-
`/build/${common.buildType}/testsetengine.engine`);
41+
if (hasEngineSupport) {
42+
const engine = path.join(__dirname,
43+
`/build/${common.buildType}/testsetengine.engine`);
3644

37-
if (!fs.existsSync(engine))
38-
common.skip('no engine');
45+
if (!fs.existsSync(engine))
46+
common.skip('no engine');
3947

40-
{
41-
const engineId = path.parse(engine).name;
42-
const execDir = path.parse(engine).dir;
48+
{
49+
const engineId = path.parse(engine).name;
50+
const execDir = path.parse(engine).dir;
4351

44-
crypto.setEngine(engine);
45-
// OpenSSL 3.0.1 and 1.1.1m now throw errors if an engine is loaded again
46-
// with a duplicate absolute path.
47-
// TODO(richardlau): figure out why this fails on macOS but not Linux.
48-
// crypto.setEngine(engine);
52+
crypto.setEngine(engine);
53+
// OpenSSL 3.0.1 and 1.1.1m now throw errors if an engine is loaded again
54+
// with a duplicate absolute path.
55+
// TODO(richardlau): figure out why this fails on macOS but not Linux.
56+
// crypto.setEngine(engine);
4957

50-
// crypto.setEngine(engine, crypto.constants.ENGINE_METHOD_RSA);
51-
// crypto.setEngine(engine, crypto.constants.ENGINE_METHOD_RSA);
58+
// crypto.setEngine(engine, crypto.constants.ENGINE_METHOD_RSA);
59+
// crypto.setEngine(engine, crypto.constants.ENGINE_METHOD_RSA);
5260

53-
process.env.OPENSSL_ENGINES = execDir;
61+
process.env.OPENSSL_ENGINES = execDir;
5462

55-
crypto.setEngine(engineId);
56-
crypto.setEngine(engineId);
63+
crypto.setEngine(engineId);
64+
crypto.setEngine(engineId);
5765

58-
crypto.setEngine(engineId, crypto.constants.ENGINE_METHOD_RSA);
59-
crypto.setEngine(engineId, crypto.constants.ENGINE_METHOD_RSA);
66+
crypto.setEngine(engineId, crypto.constants.ENGINE_METHOD_RSA);
67+
crypto.setEngine(engineId, crypto.constants.ENGINE_METHOD_RSA);
68+
}
6069
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.