[svn] commit: r1479 - in /trunk/src/lib/auth: data_source.cc tests/datasrc_unittest.cc tests/test_datasrc.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Mar 17 16:33:44 UTC 2010
Author: each
Date: Wed Mar 17 16:33:43 2010
New Revision: 1479
Log:
Fixed unit tests for NSEC/NSEC3 in the wildcard case. (They were based
on a flawed understanding of the protocol, and once the code had been
corrected, the tests needed to be corrected as well.)
Modified:
trunk/src/lib/auth/data_source.cc
trunk/src/lib/auth/tests/datasrc_unittest.cc
trunk/src/lib/auth/tests/test_datasrc.cc
Modified: trunk/src/lib/auth/data_source.cc
==============================================================================
--- trunk/src/lib/auth/data_source.cc (original)
+++ trunk/src/lib/auth/data_source.cc Wed Mar 17 16:33:43 2010
@@ -452,35 +452,38 @@
QueryTask::AUTH_QUERY);
result = doQueryTask(ds, zonename, newtask, wild);
if (result == DataSrc::SUCCESS) {
- task->flags &= ~DataSrc::NAME_NOT_FOUND;
- task->flags &= ~DataSrc::TYPE_NOT_FOUND;
if (newtask.flags == 0) {
+ task->flags &= ~DataSrc::NAME_NOT_FOUND;
+ task->flags &= ~DataSrc::TYPE_NOT_FOUND;
found = true;
break;
} else if ((newtask.flags & DataSrc::CNAME_FOUND) != 0) {
+ task->flags &= ~DataSrc::NAME_NOT_FOUND;
+ task->flags &= ~DataSrc::TYPE_NOT_FOUND;
task->flags |= DataSrc::CNAME_FOUND;
found = true;
cname = true;
break;
} else if ((newtask.flags & DataSrc::TYPE_NOT_FOUND) != 0) {
+ task->flags &= ~DataSrc::NAME_NOT_FOUND;
task->flags |= DataSrc::TYPE_NOT_FOUND;
break;
}
}
}
- // A wildcard was found. Add the data to the answer
- // section (but with the name changed to match the
- // qname), and then continue as if this were a normal
- // answer: if a CNAME, chase the target, otherwise
- // add authority.
+ // A wildcard was found.
if (found) {
+ // Prove the nonexistence of the name we were looking for
result = proveNX(q, task, ds, *zonename, true);
if (result != DataSrc::SUCCESS) {
m.setRcode(Rcode::SERVFAIL());
return (DataSrc::ERROR);
}
+ // Add the data to the answer section (but with the name changed to
+ // match the qname), and then continue as if this were a normal
+ // answer: if a CNAME, chase the target, otherwise add authority.
if (cname) {
RRsetPtr rrset = wild.findRRset(RRType::CNAME(), q.qclass());
if (rrset != NULL) {
Modified: trunk/src/lib/auth/tests/datasrc_unittest.cc
==============================================================================
--- trunk/src/lib/auth/tests/datasrc_unittest.cc (original)
+++ trunk/src/lib/auth/tests/datasrc_unittest.cc Wed Mar 17 16:33:43 2010
@@ -251,7 +251,7 @@
TEST_F(DataSrcTest, Wildcard) {
readAndProcessQuery("testdata/q_wild_a");
- headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 4, 6);
+ headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 6, 6);
RRsetIterator rit = msg.beginSection(Section::ANSWER());
RRsetPtr rrset = *rit;
@@ -266,6 +266,13 @@
EXPECT_TRUE(it->isLast());
rit = msg.beginSection(Section::AUTHORITY());
+ rrset = *rit;
+ EXPECT_EQ(Name("*.wild.example.com"), rrset->getName());
+ EXPECT_EQ(RRType::NSEC(), rrset->getType());
+ EXPECT_EQ(RRClass::IN(), rrset->getClass());
+ ++rit;
+ ++rit;
+
rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -307,7 +314,7 @@
// correctly
readAndProcessQuery("testdata/q_wild2_a");
- headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 4, 6);
+ headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 6, 6);
RRsetIterator rit = msg.beginSection(Section::ANSWER());
RRsetPtr rrset = *rit;
@@ -335,6 +342,13 @@
EXPECT_TRUE(it->isLast());
rit = msg.beginSection(Section::AUTHORITY());
+ rrset = *rit;
+ EXPECT_EQ(Name("*.wild2.example.com"), rrset->getName());
+ EXPECT_EQ(RRType::NSEC(), rrset->getType());
+ EXPECT_EQ(RRClass::IN(), rrset->getClass());
+ ++rit;
+ ++rit;
+
rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
Modified: trunk/src/lib/auth/tests/test_datasrc.cc
==============================================================================
--- trunk/src/lib/auth/tests/test_datasrc.cc (original)
+++ trunk/src/lib/auth/tests/test_datasrc.cc Wed Mar 17 16:33:43 2010
@@ -815,14 +815,14 @@
target = foo;
} else if (qname < subzone) {
target = sql1;
- } else if (qname < www) {
+ } else if (qname < wild) {
target = subzone;
- } else if (qname < wild) {
- target = www;
} else if (qname < wild2) {
target = wild;
+ } else if (qname < www) {
+ target = wild2;
} else {
- target = wild2;
+ target = www;
}
} else {
if (qname >= sql1 || qname < www_sql1) {
More information about the bind10-changes
mailing list