test: ec2 generateKeyPairSync invalid parameter encoding · nodejs/node@de463f1 (original) (raw)

Original file line number Diff line number Diff line change
@@ -449,6 +449,29 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
449 449 }));
450 450 }
451 451
452 +// Test invalid parameter encoding.
453 +{
454 +common.expectsError(() => generateKeyPairSync('ec', {
455 +namedCurve: 'P-256',
456 +paramEncoding: 'otherEncoding',
457 +publicKeyEncoding: {
458 +type: 'spki',
459 +format: 'pem'
460 +},
461 +privateKeyEncoding: {
462 +type: 'pkcs8',
463 +format: 'pem',
464 +cipher: 'aes-128-cbc',
465 +passphrase: 'top secret'
466 +}
467 +}), {
468 +type: TypeError,
469 +code: 'ERR_INVALID_OPT_VALUE',
470 +message: 'The value "otherEncoding" is invalid for ' +
471 +'option "paramEncoding"'
472 +});
473 +}
474 +
452 475 {
453 476 // Test the util.promisified API with async RSA key generation.
454 477 promisify(generateKeyPair)('rsa', {