Skip to content

Commit

Permalink
test: move dgram invalid host test to internet tests
Browse files Browse the repository at this point in the history
This moves a dgram test from `parallel` to `internet` because it relies
on a DNS request.
In certain cases, ISPs hijack invalid IETF-reserved invalid names which
causes a false negative failure.

Fixes: #27341

PR-URL: #27565
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Benjamin Ki authored and targos committed May 14, 2019
1 parent ae8b64d commit f01183c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
21 changes: 21 additions & 0 deletions test/internet/test-dgram-connect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const common = require('../common');
const { addresses } = require('../common/internet');
const assert = require('assert');
const dgram = require('dgram');

const PORT = 12345;

const client = dgram.createSocket('udp4');
client.connect(PORT, addresses.INVALID_HOST, common.mustCall((err) => {
assert.ok(err.code === 'ENOTFOUND' || err.code === 'EAI_AGAIN');

client.once('error', common.mustCall((err) => {
assert.ok(err.code === 'ENOTFOUND' || err.code === 'EAI_AGAIN');
client.once('connect', common.mustCall(() => client.close()));
client.connect(PORT);
}));

client.connect(PORT, addresses.INVALID_HOST);
}));
14 changes: 2 additions & 12 deletions test/parallel/test-dgram-connect.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const common = require('../common');
const { addresses } = require('../common/internet');
const assert = require('assert');
const dgram = require('dgram');

Expand Down Expand Up @@ -36,17 +35,8 @@ client.connect(PORT, common.mustCall(() => {
code: 'ERR_SOCKET_DGRAM_NOT_CONNECTED'
});

client.connect(PORT, addresses.INVALID_HOST, common.mustCall((err) => {
assert.ok(err.code === 'ENOTFOUND' || err.code === 'EAI_AGAIN');

client.once('error', common.mustCall((err) => {
assert.ok(err.code === 'ENOTFOUND' || err.code === 'EAI_AGAIN');
client.once('connect', common.mustCall(() => client.close()));
client.connect(PORT);
}));

client.connect(PORT, addresses.INVALID_HOST);
}));
client.once('connect', common.mustCall(() => client.close()));
client.connect(PORT);
}));

assert.throws(() => {
Expand Down

0 comments on commit f01183c

Please sign in to comment.