test: ec2 generateKeyPairSync invalid parameter encoding

PR-URL: https://github.com/nodejs/node/pull/27212
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Ruwan Geeganage 2019-04-13 12:13:08 +02:00 committed by Daniel Bevenius
parent 1e7823dd4e
commit de463f1490

View File

@ -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', {