From 0b9c3a30d67b404198e3c91f3631ec98c61f4983 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Mon, 14 Dec 2015 18:33:47 -0600 Subject: [PATCH] test: add test for tls.parseCertString It does not currently have any explicit tests to verify the behavior. PR-URL: https://github.com/nodejs/node/pull/4283 Reviewed-By: Ben Noordhuis --- test/parallel/test-tls-parse-cert-string.js | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/parallel/test-tls-parse-cert-string.js diff --git a/test/parallel/test-tls-parse-cert-string.js b/test/parallel/test-tls-parse-cert-string.js new file mode 100644 index 00000000000000..57180c9ce9df56 --- /dev/null +++ b/test/parallel/test-tls-parse-cert-string.js @@ -0,0 +1,26 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const tls = require('tls'); + +const singles = 'C=US\nST=CA\nL=SF\nO=Node.js Foundation\nOU=Node.js\nCN=ca1\n' + + 'emailAddress=ry@clouds.org'; +const singlesOut = tls.parseCertString(singles); +assert.deepEqual(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.deepEqual(doublesOut, { + OU: [ 'Domain Control Validated', 'PositiveSSL Wildcard' ], + CN: '*.nodejs.org' +});