From 03ae4c2badfd1a2cfc5b437c75b0062d4bdfe12b Mon Sep 17 00:00:00 2001 From: Leko Date: Mon, 18 Dec 2017 16:07:39 +0900 Subject: [PATCH] test: increase pbkdf2 test coverage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/17730 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Tobias Nießen Reviewed-By: Jon Moss --- test/parallel/test-crypto-pbkdf2.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/parallel/test-crypto-pbkdf2.js b/test/parallel/test-crypto-pbkdf2.js index 3cefa84e712a49..af8acd42c7c7fd 100644 --- a/test/parallel/test-crypto-pbkdf2.js +++ b/test/parallel/test-crypto-pbkdf2.js @@ -65,6 +65,26 @@ common.expectsError( } ); +common.expectsError( + () => crypto.pbkdf2Sync('password', 'salt', -1, 20, null), + { + code: 'ERR_OUT_OF_RANGE', + type: RangeError, + message: 'The "iterations" argument is out of range' + } +); + +['str', null, undefined, [], {}].forEach((notNumber) => { + common.expectsError( + () => { + crypto.pbkdf2Sync('password', 'salt', 1, notNumber, 'sha256'); + }, { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "keylen" argument must be of type number' + }); +}); + [Infinity, -Infinity, NaN, -1, 4073741824, INT_MAX + 1].forEach((i) => { common.expectsError( () => {