test: rsa-pss generateKeyPairSync invalid option hash

PR-URL: https://github.com/nodejs/node/pull/27883
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
Evgenii Shchepotev 2019-05-26 13:17:54 +03:00 committed by Rich Trott
parent 1dbf2765bc
commit 1279d513b8

View File

@ -999,6 +999,20 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}); });
} }
// Invalid hash value.
for (const hashValue of [123, true, {}, []]) {
common.expectsError(() => {
generateKeyPairSync('rsa-pss', {
modulusLength: 4096,
hash: hashValue
});
}, {
type: TypeError,
code: 'ERR_INVALID_OPT_VALUE',
message: `The value "${hashValue}" is invalid for option "hash"`
});
}
// Invalid private key type. // Invalid private key type.
for (const type of ['foo', 'spki']) { for (const type of ['foo', 'spki']) {
common.expectsError(() => { common.expectsError(() => {