Skip to content
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: use invalid host according to RFC2606 #14863

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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