Skip to content

Commit

Permalink
test: increase pbkdf2 test coverage
Browse files Browse the repository at this point in the history
PR-URL: #17730
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
  • Loading branch information
Leko authored and MylesBorins committed Jan 8, 2018
1 parent ce87e56 commit 03ae4c2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/parallel/test-crypto-pbkdf2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
() => {
Expand Down

0 comments on commit 03ae4c2

Please sign in to comment.