summaryrefslogtreecommitdiff
path: root/test/parallel/test-crypto-hmac.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-09-06 08:10:34 -0700
committerJames M Snell <jasnell@gmail.com>2017-09-18 08:10:59 -0700
commitc75f87cc4c8d3699e081d37bb5bf47a70d830fdb (patch)
tree9d79319f568ff43e36e05a8d2634130adfacfb74 /test/parallel/test-crypto-hmac.js
parent8fa5fcc0ba74c23490c34da1a6c6e9a454280740 (diff)
downloadandroid-node-v8-c75f87cc4c8d3699e081d37bb5bf47a70d830fdb.tar.gz
android-node-v8-c75f87cc4c8d3699e081d37bb5bf47a70d830fdb.tar.bz2
android-node-v8-c75f87cc4c8d3699e081d37bb5bf47a70d830fdb.zip
crypto: refactor the crypto module
* Split single monolithic file into multiple * Make Certificate methods static * Allow randomFill(Sync) to use any ArrayBufferView * Use internal/errors throughout * Improve arg validation in Hash/Hmac * Doc updates PR-URL: https://github.com/nodejs/node/pull/15231 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Diffstat (limited to 'test/parallel/test-crypto-hmac.js')
-rw-r--r--test/parallel/test-crypto-hmac.js23
1 files changed, 9 insertions, 14 deletions
diff --git a/test/parallel/test-crypto-hmac.js b/test/parallel/test-crypto-hmac.js
index 6ddffbf56f..a2921dae47 100644
--- a/test/parallel/test-crypto-hmac.js
+++ b/test/parallel/test-crypto-hmac.js
@@ -6,19 +6,11 @@ if (!common.hasCrypto)
const assert = require('assert');
const crypto = require('crypto');
-// Test for binding layer robustness
-{
- const binding = process.binding('crypto');
- const h = new binding.Hmac();
- // Fail to init the Hmac with an algorithm.
- assert.throws(() => h.update('hello'), /^TypeError: HmacUpdate fail$/);
-}
-
// Test HMAC
const h1 = crypto.createHmac('sha1', 'Node')
- .update('some data')
- .update('to hmac')
- .digest('hex');
+ .update('some data')
+ .update('to hmac')
+ .digest('hex');
assert.strictEqual(h1, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892', 'test HMAC');
// Test HMAC (Wikipedia Test Cases)
@@ -376,9 +368,12 @@ for (let i = 0, l = rfc2202_sha1.length; i < l; i++) {
);
}
-assert.throws(function() {
- crypto.createHmac('sha256', 'w00t').digest('ucs2');
-}, /^Error: hmac\.digest\(\) does not support UTF-16$/);
+common.expectsError(
+ () => crypto.createHmac('sha256', 'w00t').digest('ucs2'),
+ {
+ code: 'ERR_CRYPTO_HASH_DIGEST_NO_UTF16',
+ type: Error
+ });
// Check initialized -> uninitialized state transition after calling digest().
{