Files
node/test/parallel/test-https-connect-address-family.js
T
Brian White 9a8acad6ff test: use random ports where possible
This helps to prevent issues where a failed test can keep a bound
socket open long enough to cause other tests to fail with EADDRINUSE
because the same port number is used.

PR-URL: https://github.com/nodejs/node/pull/7045
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2016-07-14 12:45:24 -07:00

29 lines
694 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const https = require('https');
if (!common.hasIPv6) {
common.skip('no IPv6 support');
return;
}
const ciphers = 'AECDH-NULL-SHA';
https.createServer({ ciphers }, function(req, res) {
this.close();
res.end();
}).listen(0, '::1', function() {
const options = {
host: 'localhost',
port: this.address().port,
family: 6,
ciphers: ciphers,
rejectUnauthorized: false,
};
// Will fail with ECONNREFUSED if the address family is not honored.
https.get(options, common.mustCall(function() {
assert.strictEqual('::1', this.socket.remoteAddress);
this.destroy();
}));
});