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>
This commit is contained in:
parent
36c56db0b1
commit
a58b8dd545
30
test/internet/test-dns-lookup.js
Normal file
30
test/internet/test-dns-lookup.js
Normal file
@ -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}`
|
||||||
|
}
|
||||||
|
);
|
@ -1,7 +1,6 @@
|
|||||||
// Flags: --expose-internals
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const { addresses } = require('../common/internet');
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { internalBinding } = require('internal/test/binding');
|
const { internalBinding } = require('internal/test/binding');
|
||||||
const cares = internalBinding('cares_wrap');
|
const cares = internalBinding('cares_wrap');
|
||||||
@ -95,30 +94,6 @@ common.expectsError(() => {
|
|||||||
all: false
|
all: false
|
||||||
});
|
});
|
||||||
assert.deepStrictEqual(res, { address: '127.0.0.1', family: 4 });
|
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, {
|
dns.lookup(false, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user