Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: add typeerror test for EC crypto keygen
  • Loading branch information
teorossi82 committed Nov 16, 2018
commit 19670bb4c971c01dd158de4133dc7df77ea6d296
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 ` +
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to validate the message.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@refack I have to remove the validation of the message or it can be good as is?

'"namedCurve"'
});
}

// It should recognize both NIST and standard curve names.
generateKeyPair('ec', {
namedCurve: 'P-192',
Expand Down