From 67b692bdb9d38d4f07ba003eb69d45f84bb0d964 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Ruben Bridgewater Reviewed-By: Ujjwal Sharma Reviewed-By: Colin Ihrig Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Rich Trott Reviewed-By: Gireesh Punathil --- 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"` + } + ); + } +}