From 2b69d136eeb8308e099e8dc058757fa33b94824b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 16 Aug 2017 18:18:21 +0200 Subject: [PATCH 1/2] test: use invalid host according to RFC2606 Refs: https://github.com/nodejs/node/pull/14781 Refs: https://tools.ietf.org/html/rfc2606#section-2 --- test/parallel/test-http-client-req-error-dont-double-fire.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http-client-req-error-dont-double-fire.js b/test/parallel/test-http-client-req-error-dont-double-fire.js index 3fca2aa843fe1d..996540fc96c72e 100644 --- a/test/parallel/test-http-client-req-error-dont-double-fire.js +++ b/test/parallel/test-http-client-req-error-dont-double-fire.js @@ -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(() => { From ce4a7713e9549f354d6acde183f3f29b301c099a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Thu, 17 Aug 2017 19:18:23 +0200 Subject: [PATCH 2/2] test/internet/test-dns.js --- test/internet/test-dns.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js index aa596822df75e9..9e0877059037d3 100644 --- a/test/internet/test-dns.js +++ b/test/internet/test-dns.js @@ -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(); });