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 b9b762f

Browse filesBrowse files
Trottevanlucas
authored andcommitted
test: add test for invalid cert string
`tls.parseCertString()` should return an empty object if passed an invalid cert string. This behavior is not currently tested. Add minimal test. PR-URL: #8179 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com>
1 parent a6f8379 commit b9b762f
Copy full SHA for b9b762f

File tree

Expand file treeCollapse file tree

1 file changed

+29
-19
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+29
-19
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-tls-parse-cert-string.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-parse-cert-string.js
+29-19Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,33 @@ require('../common');
44
const assert = require('assert');
55
const tls = require('tls');
66

7-
const singles = 'C=US\nST=CA\nL=SF\nO=Node.js Foundation\nOU=Node.js\n' +
8-
'CN=ca1\nemailAddress=ry@clouds.org';
9-
const singlesOut = tls.parseCertString(singles);
10-
assert.deepStrictEqual(singlesOut, {
11-
C: 'US',
12-
ST: 'CA',
13-
L: 'SF',
14-
O: 'Node.js Foundation',
15-
OU: 'Node.js',
16-
CN: 'ca1',
17-
emailAddress: 'ry@clouds.org'
18-
});
7+
{
8+
const singles = 'C=US\nST=CA\nL=SF\nO=Node.js Foundation\nOU=Node.js\n' +
9+
'CN=ca1\nemailAddress=ry@clouds.org';
10+
const singlesOut = tls.parseCertString(singles);
11+
assert.deepStrictEqual(singlesOut, {
12+
C: 'US',
13+
ST: 'CA',
14+
L: 'SF',
15+
O: 'Node.js Foundation',
16+
OU: 'Node.js',
17+
CN: 'ca1',
18+
emailAddress: 'ry@clouds.org'
19+
});
20+
}
1921

20-
const doubles = 'OU=Domain Control Validated\nOU=PositiveSSL Wildcard\n' +
21-
'CN=*.nodejs.org';
22-
const doublesOut = tls.parseCertString(doubles);
23-
assert.deepStrictEqual(doublesOut, {
24-
OU: [ 'Domain Control Validated', 'PositiveSSL Wildcard' ],
25-
CN: '*.nodejs.org'
26-
});
22+
{
23+
const doubles = 'OU=Domain Control Validated\nOU=PositiveSSL Wildcard\n' +
24+
'CN=*.nodejs.org';
25+
const doublesOut = tls.parseCertString(doubles);
26+
assert.deepStrictEqual(doublesOut, {
27+
OU: [ 'Domain Control Validated', 'PositiveSSL Wildcard' ],
28+
CN: '*.nodejs.org'
29+
});
30+
}
31+
32+
{
33+
const invalid = 'fhqwhgads';
34+
const invalidOut = tls.parseCertString(invalid);
35+
assert.deepStrictEqual(invalidOut, {});
36+
}

0 commit comments

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