summaryrefslogtreecommitdiff
path: root/test/parallel/test-https-connect-address-family.js
diff options
context:
space:
mode:
authorRefael Ackermann <refack@gmail.com>2017-11-12 15:10:22 -0500
committerRefael Ackermann <refack@gmail.com>2017-11-21 16:37:39 -0500
commit283b949404745314801462f48e379397545bdde2 (patch)
tree0b3a009184c64937114272bc887647b806a0a36c /test/parallel/test-https-connect-address-family.js
parent446c1ecfdaf99de38082d048626f301109da49c6 (diff)
downloadandroid-node-v8-283b949404745314801462f48e379397545bdde2.tar.gz
android-node-v8-283b949404745314801462f48e379397545bdde2.tar.bz2
android-node-v8-283b949404745314801462f48e379397545bdde2.zip
test: bypass dns for IPv6 net tests
PR-URL: https://github.com/nodejs/node/pull/16976 Refs: https://github.com/nodejs/node/pull/16248 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'test/parallel/test-https-connect-address-family.js')
-rw-r--r--test/parallel/test-https-connect-address-family.js32
1 files changed, 14 insertions, 18 deletions
diff --git a/test/parallel/test-https-connect-address-family.js b/test/parallel/test-https-connect-address-family.js
index 28d47b3a96..8b3584b339 100644
--- a/test/parallel/test-https-connect-address-family.js
+++ b/test/parallel/test-https-connect-address-family.js
@@ -1,4 +1,7 @@
'use strict';
+
+// Test that the family option of https.get is honored.
+
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
@@ -9,21 +12,28 @@ if (!common.hasIPv6)
const assert = require('assert');
const fixtures = require('../common/fixtures');
const https = require('https');
-const dns = require('dns');
-function runTest() {
+{
+ // Test that `https` machinery passes host name, and receives IP.
+ const hostAddrIPv6 = '::1';
+ const HOSTNAME = 'dummy';
https.createServer({
cert: fixtures.readKey('agent1-cert.pem'),
key: fixtures.readKey('agent1-key.pem'),
}, common.mustCall(function(req, res) {
this.close();
res.end();
- })).listen(0, '::1', common.mustCall(function() {
+ })).listen(0, hostAddrIPv6, common.mustCall(function() {
const options = {
- host: 'localhost',
+ host: HOSTNAME,
port: this.address().port,
family: 6,
rejectUnauthorized: false,
+ lookup: common.mustCall((addr, opt, cb) => {
+ assert.strictEqual(addr, HOSTNAME);
+ assert.strictEqual(opt.family, 6);
+ cb(null, hostAddrIPv6, opt.family);
+ })
};
// Will fail with ECONNREFUSED if the address family is not honored.
https.get(options, common.mustCall(function() {
@@ -32,17 +42,3 @@ function runTest() {
}));
}));
}
-
-dns.lookup('localhost', { family: 6, all: true }, (err, addresses) => {
- if (err) {
- if (err.code === 'ENOTFOUND' || err.code === 'EAI_AGAIN')
- common.skip('localhost does not resolve to ::1');
-
- throw err;
- }
-
- if (addresses.some((val) => val.address === '::1'))
- runTest();
- else
- common.skip('localhost does not resolve to ::1');
-});