Browse Source

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

Evan Hunt 15 years ago
parent
commit
6c90f779a9

+ 10 - 7
src/lib/auth/data_source.cc

@@ -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) {

+ 16 - 2
src/lib/auth/tests/datasrc_unittest.cc

@@ -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;
@@ -267,6 +267,13 @@ TEST_F(DataSrcTest, Wildcard) {
 
     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());
     EXPECT_EQ(RRClass::IN(), rrset->getClass());
@@ -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;
@@ -336,6 +343,13 @@ TEST_F(DataSrcTest, WildcardCname) {
 
     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());
     EXPECT_EQ(RRClass::IN(), rrset->getClass());

+ 4 - 4
src/lib/auth/tests/test_datasrc.cc

@@ -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) {