diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-08-25 09:03:09 +0800 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-08-31 19:10:17 +0200 |
commit | a58b8dd5457998d8ce75f2387a18c1b9d5e7ed09 (patch) | |
tree | 96aab948a2e9d3d094949122db4f5e9114971270 /test/internet | |
parent | 36c56db0b1df9f5f3a7de3440808258c954c26ea (diff) | |
download | node-new-a58b8dd5457998d8ce75f2387a18c1b9d5e7ed09.tar.gz |
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: https://github.com/nodejs/node/pull/22516
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/internet')
-rw-r--r-- | test/internet/test-dns-lookup.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/internet/test-dns-lookup.js b/test/internet/test-dns-lookup.js new file mode 100644 index 0000000000..b84f80735f --- /dev/null +++ b/test/internet/test-dns-lookup.js @@ -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}` + } +); |