From 7a93c3d793cfaff57fa4e09ea1283478ad538a1c Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 20 Oct 2016 12:39:05 -0600 Subject: [PATCH] test --- ssl-root-cas.js | 3 ++- test.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 test.js diff --git a/ssl-root-cas.js b/ssl-root-cas.js index 08c19db..e5e081f 100644 --- a/ssl-root-cas.js +++ b/ssl-root-cas.js @@ -4090,7 +4090,8 @@ var originalCas = [ "m+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n" + "-----END CERTIFICATE-----\n" ]; -module.exports.rootCas = module.exports = originalCas.slice(0); +module.exports = originalCas.slice(0); +module.exports.rootCas = module.exports; module.exports.rootCas.inject = function (/*context*/) { var rootCas = this || module.exports.rootCas; var opts = /*context ||*/ require('https').globalAgent.options; diff --git a/test.js b/test.js new file mode 100644 index 0000000..8f954b0 --- /dev/null +++ b/test.js @@ -0,0 +1,51 @@ +'use strict'; + +testDefault(); + +// backwards compat +function testDefault() { + require('https').globalAgent.options.ca = null; + var rootCas = require('./latest'); + var request = require('request'); + + require('https').globalAgent.options.ca = rootCas; + request.get('https://daplie.com/404.html', function (err, resp, body) { + if (err) { + throw err; + } + + testInject(); + }); +} + +function testInject() { + require('https').globalAgent.options.ca = null; + var rootCas = require('./latest').inject(); + var request = require('request'); + + require('https').globalAgent.options.ca = rootCas; + request.get('https://daplie.com/404.html', function (err, resp, body) { + if (err) { + throw err; + } + + testCreate(); + }); +} + +function testCreate() { + require('https').globalAgent.options.ca = null; + var rootCas = require('./latest').create(); + var request = require('request'); + + require('https').globalAgent.options.ca = rootCas; + request.get('https://daplie.com/404.html', function (err, resp, body) { + if (err) { + throw err; + } + + console.log(body); + }); +} + +// TODO test with a company certificate