diff options
author | Roman Reiss <me@silverwind.io> | 2015-02-06 21:43:50 +0100 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2015-02-06 17:18:47 -0500 |
commit | 633a9908487efadda6a86026a36d5325a28805c6 (patch) | |
tree | 34f69e1b03c62710bd612cfc0de4b95ec0d22e4e /test/internet/test-dns.js | |
parent | 1cd1d7a182c2d16c28c778ddcd72bbeac6bc5c75 (diff) | |
download | android-node-v8-633a9908487efadda6a86026a36d5325a28805c6.tar.gz android-node-v8-633a9908487efadda6a86026a36d5325a28805c6.tar.bz2 android-node-v8-633a9908487efadda6a86026a36d5325a28805c6.zip |
dns: allow dns.lookup() to return all addresses
This commit adds the 'all' option to dns.lookup(), allowing
all lookup results to be returned.
Semver: Minor
Fixes: https://github.com/iojs/io.js/issues/736
PR-URL: https://github.com/iojs/io.js/pull/744
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/internet/test-dns.js')
-rw-r--r-- | test/internet/test-dns.js | 106 |
1 files changed, 96 insertions, 10 deletions
diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js index 427337c413..b980b822c1 100644 --- a/test/internet/test-dns.js +++ b/test/internet/test-dns.js @@ -226,34 +226,34 @@ TEST(function test_resolveNaptr(done) { TEST(function test_resolveSoa(done) { var req = dns.resolveSoa('nodejs.org', function(err, result) { if (err) throw err; - + assert.ok(result); assert.ok(typeof result === 'object'); - + assert.ok(typeof result.nsname === 'string'); assert.ok(result.nsname.length > 0); - + assert.ok(typeof result.hostmaster === 'string'); assert.ok(result.hostmaster.length > 0); - + assert.ok(typeof result.serial === 'number'); assert.ok((result.serial > 0) && (result.serial < 4294967295)); - + assert.ok(typeof result.refresh === 'number'); - assert.ok((result.refresh > 0) && (result.refresh < 2147483647)); - + assert.ok((result.refresh > 0) && (result.refresh < 2147483647)); + assert.ok(typeof result.retry === 'number'); assert.ok((result.retry > 0) && (result.retry < 2147483647)); - + assert.ok(typeof result.expire === 'number'); assert.ok((result.expire > 0) && (result.expire < 2147483647)); - + assert.ok(typeof result.minttl === 'number'); assert.ok((result.minttl >= 0) && (result.minttl < 2147483647)); done(); }); - + checkWrap(req); }); @@ -471,6 +471,92 @@ TEST(function test_lookup_localhost_ipv4(done) { }); +TEST(function test_lookup_ip_all(done) { + var req = dns.lookup('127.0.0.1', {all: true}, function(err, ips, family) { + if (err) throw err; + assert.ok(Array.isArray(ips)); + assert.ok(ips.length > 0); + assert.strictEqual(ips[0].address, '127.0.0.1'); + assert.strictEqual(ips[0].family, 4); + + done(); + }); + + checkWrap(req); +}); + + +TEST(function test_lookup_null_all(done) { + var req = dns.lookup(null, {all: true}, function(err, ips, family) { + if (err) throw err; + assert.ok(Array.isArray(ips)); + assert.strictEqual(ips.length, 0); + + done(); + }); + + checkWrap(req); +}); + + +TEST(function test_lookup_all_ipv4(done) { + var req = dns.lookup('www.google.com', {all: true, family: 4}, function(err, ips) { + if (err) throw err; + assert.ok(Array.isArray(ips)); + assert.ok(ips.length > 0); + + ips.forEach(function(ip) { + assert.ok(isIPv4(ip.address)); + assert.strictEqual(ip.family, 4); + }); + + done(); + }); + + checkWrap(req); +}); + + +TEST(function test_lookup_all_ipv6(done) { + var req = dns.lookup('www.google.com', {all: true, family: 6}, function(err, ips) { + if (err) throw err; + assert.ok(Array.isArray(ips)); + assert.ok(ips.length > 0); + + ips.forEach(function(ip) { + assert.ok(isIPv6(ip.address)); + assert.strictEqual(ip.family, 6); + }); + + done(); + }); + + checkWrap(req); +}); + + +TEST(function test_lookup_all_mixed(done) { + var req = dns.lookup('www.google.com', {all: true}, function(err, ips) { + if (err) throw err; + assert.ok(Array.isArray(ips)); + assert.ok(ips.length > 0); + + ips.forEach(function(ip) { + if (isIPv4(ip.address)) + assert.equal(ip.family, 4); + else if (isIPv6(ip.address)) + assert.equal(ip.family, 6); + else + assert(false); + }); + + done(); + }); + + checkWrap(req); +}); + + TEST(function test_lookupservice_ip_ipv4(done) { var req = dns.lookupService('127.0.0.1', 80, function(err, host, service) { if (err) throw err; |