node/test/sequential/test-https-connect-localport.js
Ben Noordhuis 1b2749ecbe dns: default to verbatim=true in dns.lookup()
Switch the default from `ipv4first` to `verbatim` (return them exactly
as the resolver sent them to us).

PR-URL: https://github.com/nodejs/node/pull/39987
Fixes: https://github.com/nodejs/node/issues/31566
Refs: https://github.com/nodejs/node/issues/6307
Refs: https://github.com/nodejs/node/pull/20710
Refs: https://github.com/nodejs/node/pull/38099
Co-authored-by: treysis <treysis@gmx.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2021-09-12 21:05:35 +02:00

35 lines
863 B
JavaScript

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
if (!common.hasCrypto)
common.skip('missing crypto');
const https = require('https');
const assert = require('assert');
{
const server = https.createServer({
cert: fixtures.readKey('agent1-cert.pem'),
key: fixtures.readKey('agent1-key.pem'),
}, common.mustCall((req, res) => {
server.close();
res.end();
}));
server.listen(0, '127.0.0.1', common.mustCall(() => {
const port = server.address().port;
const req = https.get({
host: 'localhost',
pathname: '/',
port,
family: 4,
localPort: common.PORT,
rejectUnauthorized: false,
}, common.mustCall(() => {
assert.strictEqual(req.socket.localPort, common.PORT);
assert.strictEqual(req.socket.remotePort, port);
}));
}));
}