Skip to content
Permalink
Browse files

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: #4921
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Brian White <mscdex@mscdex.net>
  • Loading branch information...
dturing authored and silverwind committed Feb 8, 2016
1 parent 76bc4c7 commit c4ab861a494eea9c18698fbf955025ca265b0b92
Showing with 89 additions and 0 deletions.
  1. +89 −0 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) {

0 comments on commit c4ab861

Please sign in to comment.
You can’t perform that action at this time.