diff options
author | Leko <leko.noor@gmail.com> | 2017-12-04 16:32:06 +0900 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2017-12-06 19:35:24 -0500 |
commit | 3d645338a005c4318c72a050b2066d4bca313d53 (patch) | |
tree | 6537694661f2d8415dc3fd2096ae090f43e6be26 /test/parallel/test-crypto-hmac.js | |
parent | c892f6f97db35a1833bfa22d91a0768a57cdec2b (diff) | |
download | android-node-v8-3d645338a005c4318c72a050b2066d4bca313d53.tar.gz android-node-v8-3d645338a005c4318c72a050b2066d4bca313d53.tar.bz2 android-node-v8-3d645338a005c4318c72a050b2066d4bca313d53.zip |
test: expand coverage for crypto
crypto.Hash
- Call constructor without new keyword
crypto.Hmac
- Call constructor without new keyword
- Call constructor with typeof hmac != string
- Call constructor with typeof hmac = string, typeof key != string
PR-URL: https://github.com/nodejs/node/pull/17447
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/parallel/test-crypto-hmac.js')
-rw-r--r-- | test/parallel/test-crypto-hmac.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-crypto-hmac.js b/test/parallel/test-crypto-hmac.js index 8b9473704d..6c2102fe23 100644 --- a/test/parallel/test-crypto-hmac.js +++ b/test/parallel/test-crypto-hmac.js @@ -7,6 +7,30 @@ const assert = require('assert'); const crypto = require('crypto'); { + const Hmac = crypto.Hmac; + const instance = crypto.Hmac('sha256', 'Node'); + assert(instance instanceof Hmac, 'Hmac is expected to return a new instance' + + ' when called without `new`'); +} + +common.expectsError( + () => crypto.createHmac(null), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "hmac" argument must be of type string' + }); + +common.expectsError( + () => crypto.createHmac('sha1', null), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "key" argument must be one of type string, TypedArray, or ' + + 'DataView' + }); + +{ // Test HMAC const actual = crypto.createHmac('sha1', 'Node') .update('some data') |