mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
181324e192
commit
12d7a50368
1 file changed
+29
-19
@@ -8,23 +8,33 @@ if (!common.hasCrypto) {
|
||||
const assert = require('assert');
|
||||
const tls = require('tls');
|
||||
|
||||
const singles = 'C=US\nST=CA\nL=SF\nO=Node.js Foundation\nOU=Node.js\n' +
|
||||
'CN=ca1\nemailAddress=ry@clouds.org';
|
||||
const singlesOut = tls.parseCertString(singles);
|
||||
assert.deepStrictEqual(singlesOut, {
|
||||
C: 'US',
|
||||
ST: 'CA',
|
||||
L: 'SF',
|
||||
O: 'Node.js Foundation',
|
||||
OU: 'Node.js',
|
||||
CN: 'ca1',
|
||||
emailAddress: 'ry@clouds.org'
|
||||
});
|
||||
{
|
||||
const singles = 'C=US\nST=CA\nL=SF\nO=Node.js Foundation\nOU=Node.js\n' +
|
||||
'CN=ca1\nemailAddress=ry@clouds.org';
|
||||
const singlesOut = tls.parseCertString(singles);
|
||||
assert.deepStrictEqual(singlesOut, {
|
||||
C: 'US',
|
||||
ST: 'CA',
|
||||
L: 'SF',
|
||||
O: 'Node.js Foundation',
|
||||
OU: 'Node.js',
|
||||
CN: 'ca1',
|
||||
emailAddress: 'ry@clouds.org'
|
||||
});
|
||||
}
|
||||
|
||||
const doubles = 'OU=Domain Control Validated\nOU=PositiveSSL Wildcard\n' +
|
||||
'CN=*.nodejs.org';
|
||||
const doublesOut = tls.parseCertString(doubles);
|
||||
assert.deepStrictEqual(doublesOut, {
|
||||
OU: [ 'Domain Control Validated', 'PositiveSSL Wildcard' ],
|
||||
CN: '*.nodejs.org'
|
||||
});
|
||||
{
|
||||
const doubles = 'OU=Domain Control Validated\nOU=PositiveSSL Wildcard\n' +
|
||||
'CN=*.nodejs.org';
|
||||
const doublesOut = tls.parseCertString(doubles);
|
||||
assert.deepStrictEqual(doublesOut, {
|
||||
OU: [ 'Domain Control Validated', 'PositiveSSL Wildcard' ],
|
||||
CN: '*.nodejs.org'
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
const invalid = 'fhqwhgads';
|
||||
const invalidOut = tls.parseCertString(invalid);
|
||||
assert.deepStrictEqual(invalidOut, {});
|
||||
}
|
||||
Reference in new issue
Block a user