Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: improve pbkdf2 test error message regexp
Test for full error message with `^` and `$`
  • Loading branch information
joyeecheung committed Dec 2, 2016
commit 71ba2dfc00b77fe907666288aa1b9b6c69ad67a9
12 changes: 6 additions & 6 deletions test/parallel/test-crypto-pbkdf2.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,32 @@ function ondone(err, key) {
// Error path should not leak memory (check with valgrind).
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, 20, null);
}, /No callback/);
}, /^Error: No callback provided to pbkdf2$/);

// Should not work with Infinity key length
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, Infinity, 'sha256', common.fail);
}, /Bad key length/);
}, /^TypeError: Bad key length$/);

// Should not work with negative Infinity key length
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, -Infinity, 'sha256', common.fail);
}, /Bad key length/);
}, /^TypeError: Bad key length$/);

// Should not work with NaN key length
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, NaN, 'sha256', common.fail);
}, /Bad key length/);
}, /^TypeError: Bad key length$/);

// Should not work with negative key length
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, -1, 'sha256', common.fail);
}, /Bad key length/);
}, /^TypeError: Bad key length$/);

// Should not work with key length that does not fit into 32 signed bits
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, 4073741824, 'sha256', common.fail);
}, /Bad key length/);
}, /^TypeError: Bad key length$/);

// Should not get FATAL ERROR with empty password and salt
// https://github.com/nodejs/node/issues/8571
Expand Down