Browse Source

dns: add failure test for dns.resolveXXX

test whether the various resolve functions cause ENOTFOUND when trying
to resolve a known invalid domain/hostname.

PR-URL: https://github.com/nodejs/node/pull/4921
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Brian White <mscdex@mscdex.net>
process-exit-stdio-flushing
Daniel Turing 9 years ago
committed by Roman Reiss
parent
commit
c4ab861a49
  1. 89
      test/internet/test-dns.js

89
test/internet/test-dns.js

@ -84,6 +84,18 @@ TEST(function test_resolveMx(done) {
checkWrap(req);
});
TEST(function test_resolveMx_failure(done) {
var req = dns.resolveMx('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
assert.ok(result == undefined);
done();
});
checkWrap(req);
});
TEST(function test_resolveNs(done) {
var req = dns.resolveNs('rackspace.com', function(err, names) {
@ -103,6 +115,18 @@ TEST(function test_resolveNs(done) {
checkWrap(req);
});
TEST(function test_resolveNs_failure(done) {
var req = dns.resolveNs('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
assert.ok(result == undefined);
done();
});
checkWrap(req);
});
TEST(function test_resolveSrv(done) {
var req = dns.resolveSrv('_jabber._tcp.google.com', function(err, result) {
@ -129,6 +153,19 @@ TEST(function test_resolveSrv(done) {
checkWrap(req);
});
TEST(function test_resolveSrv_failure(done) {
var req = dns.resolveSrv('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
assert.ok(result == undefined);
done();
});
checkWrap(req);
});
TEST(function test_resolveNaptr(done) {
var req = dns.resolveNaptr('sip2sip.info', function(err, result) {
if (err) throw err;
@ -154,6 +191,19 @@ TEST(function test_resolveNaptr(done) {
checkWrap(req);
});
TEST(function test_resolveNaptr_failure(done) {
var req = dns.resolveNaptr('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
assert.ok(result == undefined);
done();
});
checkWrap(req);
});
TEST(function test_resolveSoa(done) {
var req = dns.resolveSoa('nodejs.org', function(err, result) {
if (err) throw err;
@ -188,6 +238,19 @@ TEST(function test_resolveSoa(done) {
checkWrap(req);
});
TEST(function test_resolveSoa_failure(done) {
var req = dns.resolveSoa('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
assert.ok(result == undefined);
done();
});
checkWrap(req);
});
TEST(function test_resolveCname(done) {
var req = dns.resolveCname('www.microsoft.com', function(err, names) {
if (err) throw err;
@ -206,6 +269,19 @@ TEST(function test_resolveCname(done) {
checkWrap(req);
});
TEST(function test_resolveCname_failure(done) {
var req = dns.resolveCname('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
assert.ok(result == undefined);
done();
});
checkWrap(req);
});
TEST(function test_resolveTxt(done) {
var req = dns.resolveTxt('google.com', function(err, records) {
@ -219,6 +295,19 @@ TEST(function test_resolveTxt(done) {
checkWrap(req);
});
TEST(function test_resolveTxt_failure(done) {
var req = dns.resolveTxt('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
assert.ok(result == undefined);
done();
});
checkWrap(req);
});
TEST(function test_lookup_failure(done) {
var req = dns.lookup('does.not.exist', 4, function(err, ip, family) {

Loading…
Cancel
Save