Browse Source

test: refactor test-crypto-timing-safe-equal

Add RegExp arguments to throws assertions.

PR-URL: https://github.com/nodejs/node/pull/9843
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
v7.x
Michaël Zasso 8 years ago
committed by Anna Henningsen
parent
commit
0ccb2c3992
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 9
      test/sequential/test-crypto-timing-safe-equal.js

9
test/sequential/test-crypto-timing-safe-equal.js

@ -23,12 +23,15 @@ assert.strictEqual(
assert.throws(function() {
crypto.timingSafeEqual(Buffer.from([1, 2, 3]), Buffer.from([1, 2]));
}, 'should throw when given buffers with different lengths');
}, /^TypeError: Input buffers must have the same length$/,
'should throw when given buffers with different lengths');
assert.throws(function() {
crypto.timingSafeEqual('not a buffer', Buffer.from([1, 2]));
}, 'should throw if the first argument is not a buffer');
}, /^TypeError: First argument must be a buffer$/,
'should throw if the first argument is not a buffer');
assert.throws(function() {
crypto.timingSafeEqual(Buffer.from([1, 2]), 'not a buffer');
}, 'should throw if the second argument is not a buffer');
}, /^TypeError: Second argument must be a buffer$/,
'should throw if the second argument is not a buffer');

Loading…
Cancel
Save