From de463f1490d25868f961c678d2962d45d1ff4977 Mon Sep 17 00:00:00 2001 From: Ruwan Geeganage Date: Sat, 13 Apr 2019 12:13:08 +0200 Subject: [PATCH] test: ec2 generateKeyPairSync invalid parameter encoding PR-URL: https://github.com/nodejs/node/pull/27212 Reviewed-By: Ben Noordhuis Reviewed-By: Richard Lau Reviewed-By: Ruben Bridgewater --- test/parallel/test-crypto-keygen.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js index 07a0a18c301196..c65f25e172e75c 100644 --- a/test/parallel/test-crypto-keygen.js +++ b/test/parallel/test-crypto-keygen.js @@ -449,6 +449,29 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); })); } +// Test invalid parameter encoding. +{ + common.expectsError(() => generateKeyPairSync('ec', { + namedCurve: 'P-256', + paramEncoding: 'otherEncoding', + publicKeyEncoding: { + type: 'spki', + format: 'pem' + }, + privateKeyEncoding: { + type: 'pkcs8', + format: 'pem', + cipher: 'aes-128-cbc', + passphrase: 'top secret' + } + }), { + type: TypeError, + code: 'ERR_INVALID_OPT_VALUE', + message: 'The value "otherEncoding" is invalid for ' + + 'option "paramEncoding"' + }); +} + { // Test the util.promisified API with async RSA key generation. promisify(generateKeyPair)('rsa', {