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 fb553b5

Browse filesBrowse files
LekoMylesBorins
authored andcommitted
test: improve crypto test coverage
- Call Sign without new - Call Verify without new - Call Verify#verify with options.padding !== options.padding >> 0 - Call Verify#verify with options.saltLength !== options.saltLength >> 0 PR-URL: #17426 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 928aecc commit fb553b5
Copy full SHA for fb553b5

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎test/parallel/test-crypto-sign-verify.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-sign-verify.js
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,42 @@ const certPem = fixtures.readSync('test_cert.pem', 'ascii');
1515
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
1616
const modSize = 1024;
1717

18+
{
19+
const Sign = crypto.Sign;
20+
const instance = Sign('SHA256');
21+
assert(instance instanceof Sign, 'Sign is expected to return a new ' +
22+
'instance when called without `new`');
23+
}
24+
25+
{
26+
const Verify = crypto.Verify;
27+
const instance = Verify('SHA256');
28+
assert(instance instanceof Verify, 'Verify is expected to return a new ' +
29+
'instance when called without `new`');
30+
}
31+
32+
common.expectsError(
33+
() => crypto.createVerify('SHA256').verify({
34+
key: certPem,
35+
padding: undefined,
36+
}, ''),
37+
{
38+
code: 'ERR_INVALID_OPT_VALUE',
39+
type: Error,
40+
message: 'The value "undefined" is invalid for option "padding"'
41+
});
42+
43+
common.expectsError(
44+
() => crypto.createVerify('SHA256').verify({
45+
key: certPem,
46+
saltLength: undefined,
47+
}, ''),
48+
{
49+
code: 'ERR_INVALID_OPT_VALUE',
50+
type: Error,
51+
message: 'The value "undefined" is invalid for option "saltLength"'
52+
});
53+
1854
// Test signing and verifying
1955
{
2056
const s1 = crypto.createSign('SHA1')

0 commit comments

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