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: #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 rvagg committed Nov 28, 2018
1 parent 237e479 commit e9abf42
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 e9abf42

Please sign in to comment.