test: use reserved invalid hostname for tests
PR-URL: https://github.com/nodejs/node/pull/14781 Refs: https://tools.ietf.org/html/rfc2606#section-2 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
parent
4f1eddf84e
commit
0309619aa7
@ -4,12 +4,12 @@ const net = require('net');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
// Using port 0 as hostname used is already invalid.
|
// Using port 0 as hostname used is already invalid.
|
||||||
const c = net.createConnection(0, '***');
|
const c = net.createConnection(0, 'this.hostname.is.invalid');
|
||||||
|
|
||||||
c.on('connect', common.mustNotCall());
|
c.on('connect', common.mustNotCall());
|
||||||
|
|
||||||
c.on('error', common.mustCall(function(e) {
|
c.on('error', common.mustCall(function(e) {
|
||||||
assert.strictEqual(e.code, 'ENOTFOUND');
|
assert.strictEqual(e.code, 'ENOTFOUND');
|
||||||
assert.strictEqual(e.port, 0);
|
assert.strictEqual(e.port, 0);
|
||||||
assert.strictEqual(e.hostname, '***');
|
assert.strictEqual(e.hostname, 'this.hostname.is.invalid');
|
||||||
}));
|
}));
|
||||||
|
@ -24,14 +24,17 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
const client = net.connect({ host: '***', port: common.PORT });
|
const client = net.connect({
|
||||||
|
host: 'this.hostname.is.invalid',
|
||||||
|
port: common.PORT
|
||||||
|
});
|
||||||
|
|
||||||
client.once('error', common.mustCall((err) => {
|
client.once('error', common.mustCall((err) => {
|
||||||
assert(err);
|
assert(err);
|
||||||
assert.strictEqual(err.code, err.errno);
|
assert.strictEqual(err.code, err.errno);
|
||||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||||
assert.strictEqual(err.host, err.hostname);
|
assert.strictEqual(err.host, err.hostname);
|
||||||
assert.strictEqual(err.host, '***');
|
assert.strictEqual(err.host, 'this.hostname.is.invalid');
|
||||||
assert.strictEqual(err.syscall, 'getaddrinfo');
|
assert.strictEqual(err.syscall, 'getaddrinfo');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user