Skip to content

Commit

Permalink
test: move test that depends on dns query to internet
Browse files Browse the repository at this point in the history
These test cases in `test/parallel/test-dns-lookup.js` send
dns requests and depend on the results, which could fail
if the DNS service for invalid hosts is hijacked by the ISP.

PR-URL: #22516
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
joyeecheung authored and targos committed Sep 3, 2018
1 parent 4862ce1 commit 6737201
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
30 changes: 30 additions & 0 deletions test/internet/test-dns-lookup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

require('../common');
const dnsPromises = require('dns').promises;
const { addresses } = require('../common/internet');
const assert = require('assert');

assert.rejects(
dnsPromises.lookup(addresses.INVALID_HOST, {
hints: 0,
family: 0,
all: false
}),
{
code: 'ENOTFOUND',
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
}
);

assert.rejects(
dnsPromises.lookup(addresses.INVALID_HOST, {
hints: 0,
family: 0,
all: true
}),
{
code: 'ENOTFOUND',
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
}
);
25 changes: 0 additions & 25 deletions test/parallel/test-dns-lookup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';
const common = require('../common');
const { addresses } = require('../common/internet');
const assert = require('assert');
const cares = process.binding('cares_wrap');
const dns = require('dns');
Expand Down Expand Up @@ -93,30 +92,6 @@ common.expectsError(() => {
all: false
});
assert.deepStrictEqual(res, { address: '127.0.0.1', family: 4 });

assert.rejects(
dnsPromises.lookup(addresses.INVALID_HOST, {
hints: 0,
family: 0,
all: false
}),
{
code: 'ENOTFOUND',
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
}
);

assert.rejects(
dnsPromises.lookup(addresses.INVALID_HOST, {
hints: 0,
family: 0,
all: true
}),
{
code: 'ENOTFOUND',
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
}
);
})();

dns.lookup(false, {
Expand Down

0 comments on commit 6737201

Please sign in to comment.