From 093fceca58649e890206ee184ed02699eb9c0e9f Mon Sep 17 00:00:00 2001 From: Levin Eugene Date: Sun, 26 May 2019 14:26:02 +0300 Subject: [PATCH] test: add test case for checking typeof mgf1Hash add test case to cover uncovered test mgf1Hash param of generateKeyPair, check typeof --- test/parallel/test-crypto-keygen.js | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js index c65f25e172e75c..d2614e0c76e498 100644 --- a/test/parallel/test-crypto-keygen.js +++ b/test/parallel/test-crypto-keygen.js @@ -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"` + } + ); + } +}