-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: make addresses of internet tests configurable #16390
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* eslint-disable required-modules */ | ||
'use strict'; | ||
|
||
// Utilities for internet-related tests | ||
|
||
const addresses = { | ||
// A generic host that has registered common DNS records, | ||
// supports both IPv4 and IPv6, and provides basic HTTP/HTTPS services | ||
INET_HOST: 'nodejs.org', | ||
// A host that provides IPv4 services | ||
INET4_HOST: 'nodejs.org', | ||
// A host that provides IPv6 services | ||
INET6_HOST: 'nodejs.org', | ||
// An accessible IPv4 IP, | ||
// defaults to the Google Public DNS IPv4 address | ||
INET4_IP: '8.8.8.8', | ||
// An accessible IPv6 IP, | ||
// defaults to the Google Public DNS IPv6 address | ||
INET6_IP: '2001:4860:4860::8888', | ||
// An invalid host that cannot be resolved | ||
// See https://tools.ietf.org/html/rfc2606#section-2 | ||
INVALID_HOST: 'something.invalid', | ||
// A host with MX records registered | ||
MX_HOST: 'nodejs.org', | ||
// A host with SRV records registered | ||
SRV_HOST: '_jabber._tcp.google.com', | ||
// A host with PTR records registered | ||
PTR_HOST: '8.8.8.8.in-addr.arpa', | ||
// A host with NAPTR records registered | ||
NAPTR_HOST: 'sip2sip.info', | ||
// A host with SOA records registered | ||
SOA_HOST: 'nodejs.org', | ||
// A host with CNAME records registered | ||
CNAME_HOST: 'blog.nodejs.org', | ||
// A host with NS records registered | ||
NS_HOST: 'nodejs.org', | ||
// A host with TXT records registered | ||
TXT_HOST: 'nodejs.org', | ||
// An accessible IPv4 DNS server | ||
DNS4_SERVER: '8.8.8.8', | ||
// An accessible IPv4 DNS server | ||
DNS6_SERVER: '2001:4860:4860::8888' | ||
}; | ||
|
||
for (const key of Object.keys(addresses)) { | ||
const envName = `NODE_TEST_${key}`; | ||
if (process.env[envName]) { | ||
addresses[key] = process.env[envName]; | ||
} | ||
} | ||
|
||
module.exports = { | ||
addresses | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
'use strict'; | ||
require('../common'); | ||
const common = require('../common'); | ||
const { addresses } = require('../common/internet'); | ||
const assert = require('assert'); | ||
const dns = require('dns'); | ||
const domain = require('domain'); | ||
|
@@ -20,8 +21,8 @@ const methods = [ | |
methods.forEach(function(method) { | ||
const d = domain.create(); | ||
d.run(function() { | ||
dns[method]('google.com', function() { | ||
dns[method](addresses.INET_HOST, common.mustCall(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improving the test at the same time? Nice! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gibfahn There are so many missing |
||
assert.strictEqual(process.domain, d, `${method} retains domain`); | ||
}); | ||
})); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can you please add an entry for this new module to the table of contents near the start of this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Trott Of course!