summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/test/test.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/test/test.js')
-rw-r--r--deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/test/test.js81
1 files changed, 48 insertions, 33 deletions
diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/test/test.js b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/test/test.js
index 2ee6724ea1..9017701f55 100644
--- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/test/test.js
+++ b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/test/test.js
@@ -9,8 +9,6 @@ var http = require('http');
var https = require('https');
var assert = require('assert');
var Proxy = require('proxy');
-var Semver = require('semver');
-var version = new Semver(process.version);
var HttpsProxyAgent = require('../');
describe('HttpsProxyAgent', function () {
@@ -181,7 +179,6 @@ describe('HttpsProxyAgent', function () {
});
res.on('end', function () {
data = JSON.parse(data);
- console.log(data);
assert.equal('127.0.0.1:' + serverPort, data.host);
done();
});
@@ -224,6 +221,31 @@ describe('HttpsProxyAgent', function () {
done();
});
});
+
+ it('should allow custom proxy "headers"', function (done) {
+ server.once('connect', function (req, socket, head) {
+ assert.equal('CONNECT', req.method);
+ assert.equal('bar', req.headers.foo);
+ socket.destroy();
+ done();
+ });
+
+ var uri = 'http://127.0.0.1:' + serverPort;
+ var proxyOpts = url.parse(uri);
+ proxyOpts.headers = {
+ 'Foo': 'bar'
+ };
+ var agent = new HttpsProxyAgent(proxyOpts);
+
+ var opts = {};
+ // `host` and `port` don't really matter since the proxy will reject anyways
+ opts.host = '127.0.0.1';
+ opts.port = 80;
+ opts.agent = agent;
+
+ http.get(opts);
+ });
+
});
describe('"https" module', function () {
@@ -253,40 +275,33 @@ describe('HttpsProxyAgent', function () {
});
});
- if (version.compare('0.11.3') < 0 || version.compare('0.11.8') >= 0) {
- // This test is disabled on node >= 0.11.3 && < 0.11.8, since it segfaults :(
- // See: https://github.com/joyent/node/issues/6204
+ it('should work over an HTTPS proxy', function (done) {
+ sslServer.once('request', function (req, res) {
+ res.end(JSON.stringify(req.headers));
+ });
- it('should work over an HTTPS proxy', function (done) {
- sslServer.once('request', function (req, res) {
- res.end(JSON.stringify(req.headers));
- });
+ var proxy = process.env.HTTPS_PROXY || process.env.https_proxy || 'https://127.0.0.1:' + sslProxyPort;
+ proxy = url.parse(proxy);
+ proxy.rejectUnauthorized = false;
+ var agent = new HttpsProxyAgent(proxy);
+
+ var opts = url.parse('https://127.0.0.1:' + sslServerPort);
+ opts.agent = agent;
+ opts.rejectUnauthorized = false;
- var proxy = process.env.HTTPS_PROXY || process.env.https_proxy || 'https://127.0.0.1:' + sslProxyPort;
- proxy = url.parse(proxy);
- proxy.rejectUnauthorized = false;
- var agent = new HttpsProxyAgent(proxy);
-
- var opts = url.parse('https://127.0.0.1:' + sslServerPort);
- opts.agent = agent;
- opts.rejectUnauthorized = false;
-
- https.get(opts, function (res) {
- var data = '';
- res.setEncoding('utf8');
- res.on('data', function (b) {
- data += b;
- });
- res.on('end', function () {
- data = JSON.parse(data);
- assert.equal('127.0.0.1:' + sslServerPort, data.host);
- done();
- });
+ https.get(opts, function (res) {
+ var data = '';
+ res.setEncoding('utf8');
+ res.on('data', function (b) {
+ data += b;
+ });
+ res.on('end', function () {
+ data = JSON.parse(data);
+ assert.equal('127.0.0.1:' + sslServerPort, data.host);
+ done();
});
});
- } else {
- it('should work over an HTTPS proxy');
- }
+ });
});