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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
  • Loading branch information
Leko authored and MylesBorins committed Jan 9, 2018
1 parent 74a5bba commit 6d15185
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 6d15185

Please sign in to comment.