Skip to content

Commit

Permalink
test: add typeerror test for EC crypto keygen
Browse files Browse the repository at this point in the history
PR-URL: nodejs#24400
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
teorossi82 authored and Trott committed Nov 20, 2018
1 parent e25e8b6 commit 67b67ad
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/parallel/test-crypto-keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 67b67ad

Please sign in to comment.