summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-parse-cert-string.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-08-18 19:38:22 -0700
committerRich Trott <rtrott@gmail.com>2016-08-21 22:47:39 -0700
commit12d7a50368cd3974edea1ff7a188b90983f87d38 (patch)
tree64f4965d21f4754e34782761f65280031ce3380d /test/parallel/test-tls-parse-cert-string.js
parent181324e192aa75e923c918af84d9902de4ee3b24 (diff)
downloadnode-new-12d7a50368cd3974edea1ff7a188b90983f87d38.tar.gz
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>
Diffstat (limited to 'test/parallel/test-tls-parse-cert-string.js')
-rw-r--r--test/parallel/test-tls-parse-cert-string.js48
1 files changed, 29 insertions, 19 deletions
diff --git a/test/parallel/test-tls-parse-cert-string.js b/test/parallel/test-tls-parse-cert-string.js
index b90fa2b32c..c6cdbf2e36 100644
--- a/test/parallel/test-tls-parse-cert-string.js
+++ b/test/parallel/test-tls-parse-cert-string.js
@@ -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, {});
+}