test: use invalid host according to RFC2606
PR-URL: https://github.com/nodejs/node/pull/14863 Refs: https://github.com/nodejs/node/pull/14781 Refs: https://tools.ietf.org/html/rfc2606#section-2 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
This commit is contained in:
parent
fd8cf79056
commit
467385a49b
@ -388,12 +388,12 @@ TEST(function test_resolveTxt_failure(done) {
|
||||
|
||||
|
||||
TEST(function test_lookup_failure(done) {
|
||||
const req = dns.lookup('does.not.exist', 4, function(err, ip, family) {
|
||||
const req = dns.lookup('this.hostname.is.invalid', 4, (err, ip, family) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.errno, dns.NOTFOUND);
|
||||
assert.strictEqual(err.errno, 'ENOTFOUND');
|
||||
assert.ok(!/ENOENT/.test(err.message));
|
||||
assert.ok(/does\.not\.exist/.test(err.message));
|
||||
assert.ok(err.message.includes('this.hostname.is.invalid'));
|
||||
|
||||
done();
|
||||
});
|
||||
@ -511,11 +511,11 @@ TEST(function test_reverse_failure(done) {
|
||||
|
||||
|
||||
TEST(function test_lookup_failure(done) {
|
||||
const req = dns.lookup('nosuchhostimsure', function(err) {
|
||||
const req = dns.lookup('this.hostname.is.invalid', (err) => {
|
||||
assert(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND'); // Silly error code...
|
||||
assert.strictEqual(err.hostname, 'nosuchhostimsure');
|
||||
assert.ok(/nosuchhostimsure/.test(err.message));
|
||||
assert.strictEqual(err.hostname, 'this.hostname.is.invalid');
|
||||
assert.ok(err.message.includes('this.hostname.is.invalid'));
|
||||
|
||||
done();
|
||||
});
|
||||
@ -525,7 +525,7 @@ TEST(function test_lookup_failure(done) {
|
||||
|
||||
|
||||
TEST(function test_resolve_failure(done) {
|
||||
const req = dns.resolve4('nosuchhostimsure', function(err) {
|
||||
const req = dns.resolve4('this.hostname.is.invalid', (err) => {
|
||||
assert(err instanceof Error);
|
||||
|
||||
switch (err.code) {
|
||||
@ -537,8 +537,8 @@ TEST(function test_resolve_failure(done) {
|
||||
break;
|
||||
}
|
||||
|
||||
assert.strictEqual(err.hostname, 'nosuchhostimsure');
|
||||
assert.ok(/nosuchhostimsure/.test(err.message));
|
||||
assert.strictEqual(err.hostname, 'this.hostname.is.invalid');
|
||||
assert.ok(err.message.includes('this.hostname.is.invalid'));
|
||||
|
||||
done();
|
||||
});
|
||||
|
@ -3,8 +3,8 @@ const assert = require('assert');
|
||||
const http = require('http');
|
||||
const common = require('../common');
|
||||
|
||||
// not exists host
|
||||
const host = '*'.repeat(256);
|
||||
// Invalid hostname as per https://tools.ietf.org/html/rfc2606#section-2
|
||||
const host = 'this.hostname.is.invalid';
|
||||
const req = http.get({ host });
|
||||
const err = new Error('mock unexpected code error');
|
||||
req.on('error', common.mustCall(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user