diff options
author | Matteo <teorossi82@yahoo.it> | 2018-11-16 20:30:05 +0100 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-11-19 18:41:35 -0800 |
commit | 67b67ad05025a8beeb99d60a99354bbb50d8d14a (patch) | |
tree | 82daf12b839bd3ac57da2ceb69472bff3cd07734 /test | |
parent | e25e8b6886d390441b9c7c1c6349ac6dcdd3ba25 (diff) | |
download | android-node-v8-67b67ad05025a8beeb99d60a99354bbb50d8d14a.tar.gz android-node-v8-67b67ad05025a8beeb99d60a99354bbb50d8d14a.tar.bz2 android-node-v8-67b67ad05025a8beeb99d60a99354bbb50d8d14a.zip |
test: add typeerror test for EC crypto keygen
PR-URL: https://github.com/nodejs/node/pull/24400
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-crypto-keygen.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js index 072f69565a..241e4aa73a 100644 --- a/test/parallel/test-crypto-keygen.js +++ b/test/parallel/test-crypto-keygen.js @@ -625,6 +625,22 @@ function convertDERToPEM(label, der) { message: 'Invalid ECDH curve name' }); + // Test error type when curve is not a string + for (const namedCurve of [true, {}, [], 123]) { + common.expectsError(() => { + generateKeyPairSync('ec', { + namedCurve, + publicKeyEncoding: { type: 'spki', format: 'pem' }, + privateKeyEncoding: { type: 'sec1', format: 'pem' } + }); + }, { + type: TypeError, + code: 'ERR_INVALID_OPT_VALUE', + message: `The value "${namedCurve}" is invalid for option ` + + '"namedCurve"' + }); + } + // It should recognize both NIST and standard curve names. generateKeyPair('ec', { namedCurve: 'P-192', |