Commit 6c90f779 authored by Evan Hunt's avatar Evan Hunt
Browse files

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.)


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1479 e5f2f494-b856-4b98-b285-d166d9295462
parent 8f2f3d07
......@@ -452,35 +452,38 @@ tryWildcard(Query& q, QueryTaskPtr task, const DataSrc* ds,
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) {
......
......@@ -251,7 +251,7 @@ TEST_F(DataSrcTest, NxZone) {
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 @@ TEST_F(DataSrcTest, Wildcard) {
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 @@ TEST_F(DataSrcTest, WildcardCname) {
// 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 @@ TEST_F(DataSrcTest, WildcardCname) {
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());
......
......@@ -815,14 +815,14 @@ TestDataSrc::findPreviousName(const Name& qname,
target = foo;
} else if (qname < subzone) {
target = sql1;
} else if (qname < www) {
target = subzone;
} else if (qname < wild) {
target = www;
target = subzone;
} else if (qname < wild2) {
target = wild;
} else {
} else if (qname < www) {
target = wild2;
} else {
target = www;
}
} else {
if (qname >= sql1 || qname < www_sql1) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment