summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-08-25 09:03:09 +0800
committerAnna Henningsen <anna@addaleax.net>2018-08-31 19:10:17 +0200
commita58b8dd5457998d8ce75f2387a18c1b9d5e7ed09 (patch)
tree96aab948a2e9d3d094949122db4f5e9114971270 /test
parent36c56db0b1df9f5f3a7de3440808258c954c26ea (diff)
downloadandroid-node-v8-a58b8dd5457998d8ce75f2387a18c1b9d5e7ed09.tar.gz
android-node-v8-a58b8dd5457998d8ce75f2387a18c1b9d5e7ed09.tar.bz2
android-node-v8-a58b8dd5457998d8ce75f2387a18c1b9d5e7ed09.zip
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')
-rw-r--r--test/internet/test-dns-lookup.js30
-rw-r--r--test/parallel/test-dns-lookup.js25
2 files changed, 30 insertions, 25 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}`
+ }
+);
diff --git a/test/parallel/test-dns-lookup.js b/test/parallel/test-dns-lookup.js
index b20d403d37..438dff0c39 100644
--- a/test/parallel/test-dns-lookup.js
+++ b/test/parallel/test-dns-lookup.js
@@ -1,7 +1,6 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
-const { addresses } = require('../common/internet');
const assert = require('assert');
const { internalBinding } = require('internal/test/binding');
const cares = internalBinding('cares_wrap');
@@ -95,30 +94,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, {