Skip to content

Commit 3161870

Browse files
committed
test: use "semver" module, disable the HTTPS over HTTPS test for node >= v0.11.3
For now... See: nodejs/node-v0.x-archive#6204
1 parent cf45e9c commit 3161870

2 files changed

Lines changed: 36 additions & 26 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"devDependencies": {
3030
"mocha": "~1.12.0",
31-
"proxy": "~0.2.0"
31+
"proxy": "~0.2.0",
32+
"semver": "~2.1.0"
3233
}
3334
}

test/test.js

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ var http = require('http');
99
var https = require('https');
1010
var assert = require('assert');
1111
var Proxy = require('proxy');
12+
var Semver = require('semver');
13+
var version = new Semver(process.version);
1214
var HttpsProxyAgent = require('../');
1315

1416
describe('HttpsProxyAgent', function () {
@@ -204,36 +206,43 @@ describe('HttpsProxyAgent', function () {
204206
});
205207
});
206208
});
207-
it('should work over an HTTPS proxy', function (done) {
208-
// set HTTP "request" event handler for this test
209-
sslServer.once('request', function (req, res) {
210-
res.end(JSON.stringify(req.headers));
211-
});
212-
213-
var proxy = process.env.HTTPS_PROXY || process.env.https_proxy || 'https://127.0.0.1:' + sslProxyPort;
214-
proxy = url.parse(proxy);
215-
// `rejectUnauthorized` is actually necessary this time since the HTTPS
216-
// proxy server itself is using a self-signed SSL certificate…
217-
proxy.rejectUnauthorized = false;
218-
var agent = new HttpsProxyAgent(proxy);
219209

220-
var opts = url.parse('https://127.0.0.1:' + sslServerPort);
221-
opts.agent = agent;
222-
opts.rejectUnauthorized = false;
210+
if (version.compare('0.11.3') < 0) {
211+
// This test is disabled on node >= 0.11.3, since it currently segfaults :(
212+
// See: https://github.com/joyent/node/issues/6204
223213

224-
https.get(opts, function (res) {
225-
var data = '';
226-
res.setEncoding('utf8');
227-
res.on('data', function (b) {
228-
data += b;
214+
it('should work over an HTTPS proxy', function (done) {
215+
// set HTTP "request" event handler for this test
216+
sslServer.once('request', function (req, res) {
217+
res.end(JSON.stringify(req.headers));
229218
});
230-
res.on('end', function () {
231-
data = JSON.parse(data);
232-
assert.equal('127.0.0.1:' + sslServerPort, data.host);
233-
done();
219+
220+
var proxy = process.env.HTTPS_PROXY || process.env.https_proxy || 'https://127.0.0.1:' + sslProxyPort;
221+
proxy = url.parse(proxy);
222+
// `rejectUnauthorized` is actually necessary this time since the HTTPS
223+
// proxy server itself is using a self-signed SSL certificate…
224+
proxy.rejectUnauthorized = false;
225+
var agent = new HttpsProxyAgent(proxy);
226+
227+
var opts = url.parse('https://127.0.0.1:' + sslServerPort);
228+
opts.agent = agent;
229+
opts.rejectUnauthorized = false;
230+
231+
https.get(opts, function (res) {
232+
var data = '';
233+
res.setEncoding('utf8');
234+
res.on('data', function (b) {
235+
data += b;
236+
});
237+
res.on('end', function () {
238+
data = JSON.parse(data);
239+
assert.equal('127.0.0.1:' + sslServerPort, data.host);
240+
done();
241+
});
234242
});
235243
});
236-
});
244+
}
245+
237246
});
238247

239248
});

0 commit comments

Comments
 (0)