• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6
7const assert = require('assert');
8const crypto = require('crypto');
9const invalidEngineName = 'xxx';
10
11assert.throws(
12  () => crypto.setEngine(true),
13  {
14    code: 'ERR_INVALID_ARG_TYPE',
15    name: 'TypeError',
16    message: 'The "id" argument must be of type string. Received type boolean' +
17             ' (true)'
18  });
19
20assert.throws(
21  () => crypto.setEngine('/path/to/engine', 'notANumber'),
22  {
23    code: 'ERR_INVALID_ARG_TYPE',
24    name: 'TypeError',
25    message: 'The "flags" argument must be of type number. Received type' +
26             " string ('notANumber')"
27  });
28
29assert.throws(
30  () => crypto.setEngine(invalidEngineName),
31  {
32    code: 'ERR_CRYPTO_ENGINE_UNKNOWN',
33    name: 'Error',
34    message: `Engine "${invalidEngineName}" was not found`
35  });
36
37assert.throws(
38  () => crypto.setEngine(invalidEngineName, crypto.constants.ENGINE_METHOD_RSA),
39  {
40    code: 'ERR_CRYPTO_ENGINE_UNKNOWN',
41    name: 'Error',
42    message: `Engine "${invalidEngineName}" was not found`
43  });
44