Skip to content

Commit 6737201

Browse files
joyeecheungtargos
authored andcommitted
test: move test that depends on dns query to internet
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]>
1 parent 4862ce1 commit 6737201

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

test/internet/test-dns-lookup.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
3+
require('../common');
4+
const dnsPromises = require('dns').promises;
5+
const { addresses } = require('../common/internet');
6+
const assert = require('assert');
7+
8+
assert.rejects(
9+
dnsPromises.lookup(addresses.INVALID_HOST, {
10+
hints: 0,
11+
family: 0,
12+
all: false
13+
}),
14+
{
15+
code: 'ENOTFOUND',
16+
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
17+
}
18+
);
19+
20+
assert.rejects(
21+
dnsPromises.lookup(addresses.INVALID_HOST, {
22+
hints: 0,
23+
family: 0,
24+
all: true
25+
}),
26+
{
27+
code: 'ENOTFOUND',
28+
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
29+
}
30+
);

test/parallel/test-dns-lookup.js

-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
const common = require('../common');
3-
const { addresses } = require('../common/internet');
43
const assert = require('assert');
54
const cares = process.binding('cares_wrap');
65
const dns = require('dns');
@@ -93,30 +92,6 @@ common.expectsError(() => {
9392
all: false
9493
});
9594
assert.deepStrictEqual(res, { address: '127.0.0.1', family: 4 });
96-
97-
assert.rejects(
98-
dnsPromises.lookup(addresses.INVALID_HOST, {
99-
hints: 0,
100-
family: 0,
101-
all: false
102-
}),
103-
{
104-
code: 'ENOTFOUND',
105-
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
106-
}
107-
);
108-
109-
assert.rejects(
110-
dnsPromises.lookup(addresses.INVALID_HOST, {
111-
hints: 0,
112-
family: 0,
113-
all: true
114-
}),
115-
{
116-
code: 'ENOTFOUND',
117-
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
118-
}
119-
);
12095
})();
12196

12297
dns.lookup(false, {

0 commit comments

Comments
 (0)