Skip to content

Commit

Permalink
test: use invalid host according to RFC2606
Browse files Browse the repository at this point in the history
PR-URL: #14863
Refs: #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>
  • Loading branch information
tniessen committed Aug 18, 2017
1 parent fd8cf79 commit 467385a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions test/internet/test-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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();
});
Expand All @@ -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) {
Expand All @@ -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();
});
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-http-client-req-error-dont-double-fire.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 467385a

Please sign in to comment.