test: add test case for checking typeof mgf1Hash

add test case to cover uncovered test mgf1Hash param of generateKeyPair,
check typeof

PR-URL: https://github.com/nodejs/node/pull/27892
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
Levin Eugene authored and Michaël Zasso committed 2019-05-31 08:46:52 +02:00
1 parent 2a509d40f4
commit 67b692bdb9
1 file changed
+36
+36
View File
@@ -987,3 +987,39 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
});
}
}
{
// Test RSA-PSS.
common.expectsError(
() => {
generateKeyPair('rsa-pss', {
modulusLength: 512,
saltLength: 16,
hash: 'sha256',
mgf1Hash: undefined
});
},
{
type: TypeError,
code: 'ERR_INVALID_CALLBACK',
message: 'Callback must be a function. Received undefined'
}
);
for (const mgf1Hash of [null, 0, false, {}, []]) {
common.expectsError(
() => {
generateKeyPair('rsa-pss', {
modulusLength: 512,
saltLength: 16,
hash: 'sha256',
mgf1Hash
});
},
{
type: TypeError,
code: 'ERR_INVALID_OPT_VALUE',
message: `The value "${mgf1Hash}" is invalid for option "mgf1Hash"`
}
);
}
}