Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a407a48

Browse filesBrowse files
LekoMylesBorins
authored andcommitted
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: #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>
1 parent 35d492c commit a407a48
Copy full SHA for a407a48

File tree

Expand file treeCollapse file tree

2 files changed

+31
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+31
-0
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-crypto-hash.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-hash.js
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,10 @@ common.expectsError(
154154
message: 'The "algorithm" argument must be of type string'
155155
}
156156
);
157+
158+
{
159+
const Hash = crypto.Hash;
160+
const instance = crypto.Hash('sha256');
161+
assert(instance instanceof Hash, 'Hash is expected to return a new instance' +
162+
' when called without `new`');
163+
}
Collapse file

‎test/parallel/test-crypto-hmac.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-hmac.js
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,30 @@ if (!common.hasCrypto)
66
const assert = require('assert');
77
const crypto = require('crypto');
88

9+
{
10+
const Hmac = crypto.Hmac;
11+
const instance = crypto.Hmac('sha256', 'Node');
12+
assert(instance instanceof Hmac, 'Hmac is expected to return a new instance' +
13+
' when called without `new`');
14+
}
15+
16+
common.expectsError(
17+
() => crypto.createHmac(null),
18+
{
19+
code: 'ERR_INVALID_ARG_TYPE',
20+
type: TypeError,
21+
message: 'The "hmac" argument must be of type string'
22+
});
23+
24+
common.expectsError(
25+
() => crypto.createHmac('sha1', null),
26+
{
27+
code: 'ERR_INVALID_ARG_TYPE',
28+
type: TypeError,
29+
message: 'The "key" argument must be one of type string, TypedArray, or ' +
30+
'DataView'
31+
});
32+
933
{
1034
// Test HMAC
1135
const actual = crypto.createHmac('sha1', 'Node')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.