Skip to content

Commit

Permalink
test: improve pbkdf2 test error message regexp
Browse files Browse the repository at this point in the history
Test for full error message with `^` and `$`
  • Loading branch information
joyeecheung committed Dec 2, 2016
1 parent d75e47b commit 71ba2df
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit 71ba2df

Please sign in to comment.