Skip to content

Commit 71ba2df

Browse files
committed
test: improve pbkdf2 test error message regexp
Test for full error message with `^` and `$`
1 parent d75e47b commit 71ba2df

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

test/parallel/test-crypto-pbkdf2.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,32 @@ function ondone(err, key) {
5858
// Error path should not leak memory (check with valgrind).
5959
assert.throws(function() {
6060
crypto.pbkdf2('password', 'salt', 1, 20, null);
61-
}, /No callback/);
61+
}, /^Error: No callback provided to pbkdf2$/);
6262

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

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

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

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

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

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

0 commit comments

Comments
 (0)