-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance crypto/hash.js coverage #17447
Changes from 5 commits
77f61dc
d5ba19d
b38e323
cfa073a
4dc97af
380a158
6a96751
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,3 +154,10 @@ common.expectsError( | |
message: 'The "algorithm" argument must be of type string' | ||
} | ||
); | ||
|
||
{ | ||
const Hash = crypto.Hash; | ||
const instance = crypto.Hash('sha256'); | ||
assert(instance instanceof Hash, 'Hash is expected to return a new instance' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs a space either at the end of this line (after instance) or on the next line. Right now it says "instancewhen". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, Sorry. I'll update it soon. |
||
'when called without `new`'); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,30 @@ if (!common.hasCrypto) | |
const assert = require('assert'); | ||
const crypto = require('crypto'); | ||
|
||
{ | ||
const Hmac = crypto.Hmac; | ||
const instance = crypto.Hmac('sha256', 'Node'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
assert(instance instanceof Hmac, 'Hmac is expected to return a new instance' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
'when called without `new`'); | ||
} | ||
|
||
common.expectsError( | ||
() => new crypto.Hmac(null), | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
type: TypeError, | ||
message: 'The "hmac" argument must be of type string' | ||
}); | ||
|
||
common.expectsError( | ||
() => new crypto.Hmac('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') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createHash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same adobe #17458 (comment)