[svn] commit: r4041 - /branches/trac455/src/bin/auth/tests/query_unittest.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Dec 28 13:14:19 UTC 2010
Author: vorner
Date: Tue Dec 28 13:14:18 2010
New Revision: 4041
Log:
Tests for SOA in NXDOMAIN and NXRRSET
Modified:
branches/trac455/src/bin/auth/tests/query_unittest.cc
Modified: branches/trac455/src/bin/auth/tests/query_unittest.cc
==============================================================================
--- branches/trac455/src/bin/auth/tests/query_unittest.cc (original)
+++ branches/trac455/src/bin/auth/tests/query_unittest.cc Tue Dec 28 13:14:18 2010
@@ -17,6 +17,7 @@
#include <dns/rcode.h>
#include <dns/rrttl.h>
#include <dns/rrtype.h>
+#include <dns/rdataclass.h>
#include <datasrc/memory_datasrc.h>
@@ -28,10 +29,14 @@
using namespace isc::datasrc;
using namespace isc::auth;
+namespace {
+
RRsetPtr a_rrset = RRsetPtr(new RRset(Name("www.example.com"),
RRClass::IN(), RRType::A(),
RRTTL(3600)));
-namespace {
+RRsetPtr soa_rrset = RRsetPtr(new RRset(Name("example.com"),
+ RRClass::IN(), RRType::SOA(),
+ RRTTL(3600)));
// This is a mock Zone class for testing.
// It is a derived class of Zone, and simply hardcode the results of find()
// return SUCCESS for "www.example.com",
@@ -64,20 +69,22 @@
}
Zone::FindResult
-MockZone::find(const Name& name, const RRType&) const {
+MockZone::find(const Name& name, const RRType& type) const {
// hardcode the find results
if (name == Name("www.example.com")) {
- return FindResult(SUCCESS, a_rrset);
+ return (FindResult(SUCCESS, a_rrset));
+ } else if (name == Name("example.com") && type == RRType::SOA()) {
+ return (FindResult(SUCCESS, soa_rrset));
} else if (name == Name("delegation.example.com")) {
- return FindResult(DELEGATION, RRsetPtr());
+ return (FindResult(DELEGATION, RRsetPtr()));
} else if (name == Name("nxdomain.example.com")) {
- return FindResult(NXDOMAIN, RRsetPtr());
+ return (FindResult(NXDOMAIN, RRsetPtr()));
} else if (name == Name("nxrrset.example.com")) {
- return FindResult(NXRRSET, RRsetPtr());
+ return (FindResult(NXRRSET, RRsetPtr()));
} else if (name == Name("cname.example.com")) {
- return FindResult(CNAME, RRsetPtr());
+ return (FindResult(CNAME, RRsetPtr()));
} else {
- return FindResult(DNAME, RRsetPtr());
+ return (FindResult(DNAME, RRsetPtr()));
}
}
@@ -106,7 +113,7 @@
}
TEST_F(QueryTest, matchZone) {
- // match qname, normal query
+ // add a matching zone.
memory_datasrc.addZone(ZonePtr(new MockZone()));
query.process();
EXPECT_EQ(Rcode::NOERROR(), response.getRcode());
@@ -119,12 +126,20 @@
Query nxdomain_query(memory_datasrc, nxdomain_name, qtype, response);
nxdomain_query.process();
EXPECT_EQ(Rcode::NXDOMAIN(), response.getRcode());
+ EXPECT_EQ(0, response.getRRCount(Message::SECTION_ANSWER));
+ EXPECT_EQ(0, response.getRRCount(Message::SECTION_ADDITIONAL));
+ EXPECT_TRUE(response.hasRRset(Message::SECTION_AUTHORITY,
+ Name("example.com"), RRClass::IN(), RRType::SOA()));
// NXRRSET
const Name nxrrset_name(Name("nxrrset.example.com"));
Query nxrrset_query(memory_datasrc, nxrrset_name, qtype, response);
nxrrset_query.process();
EXPECT_EQ(Rcode::NOERROR(), response.getRcode());
+ EXPECT_EQ(0, response.getRRCount(Message::SECTION_ANSWER));
+ EXPECT_EQ(0, response.getRRCount(Message::SECTION_ADDITIONAL));
+ EXPECT_TRUE(response.hasRRset(Message::SECTION_AUTHORITY,
+ Name("example.com"), RRClass::IN(), RRType::SOA()));
}
TEST_F(QueryTest, noMatchZone) {
@@ -136,4 +151,5 @@
nomatch_query.process();
EXPECT_EQ(Rcode::REFUSED(), response.getRcode());
}
+
}
More information about the bind10-changes
mailing list