[svn] commit: r4076 - /branches/trac455/src/bin/auth/tests/query_unittest.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Dec 29 12:59:51 UTC 2010


Author: vorner
Date: Wed Dec 29 12:59:51 2010
New Revision: 4076

Log:
Test for missing SOA

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 Wed Dec 29 12:59:51 2010
@@ -45,7 +45,9 @@
 // else return DNAME
 class MockZone : public Zone {
 public:
-    MockZone() : origin_(Name("example.com"))
+    MockZone(bool has_SOA = true) :
+        origin_(Name("example.com")),
+        has_SOA_(has_SOA)
     {}
     virtual const isc::dns::Name& getOrigin() const;
     virtual const isc::dns::RRClass& getClass() const;
@@ -55,6 +57,7 @@
 
 private:
     Name origin_;
+    bool has_SOA_;
 };
 
 const Name&
@@ -72,7 +75,9 @@
     // hardcode the find results
     if (name == Name("www.example.com")) {
         return (FindResult(SUCCESS, a_rrset));
-    } else if (name == Name("example.com") && type == RRType::SOA()) {
+    } else if (name == Name("example.com") && type == RRType::SOA() &&
+        has_SOA_)
+    {
         return (FindResult(SUCCESS, soa_rrset));
     } else if (name == Name("delegation.example.com")) {
         return (FindResult(DELEGATION, RRsetPtr()));
@@ -141,6 +146,25 @@
         Name("example.com"), RRClass::IN(), RRType::SOA()));
 }
 
+/*
+ * This tests that when there's no SOA and we need a negative answer. It should
+ * throw in that case.
+ */
+TEST_F(QueryTest, noSOA) {
+    memory_datasrc.addZone(ZonePtr(new MockZone(false)));
+
+    // The NX Domain
+    const Name nxdomain_name(Name("nxdomain.example.com"));
+    Query nxdomain_query(memory_datasrc, nxdomain_name, qtype, response);
+    EXPECT_THROW(nxdomain_query.process(), Query::NoSOA);
+    // Of course, we don't look into the response, as it throwed
+
+    // NXRRSET
+    const Name nxrrset_name(Name("nxrrset.example.com"));
+    Query nxrrset_query(memory_datasrc, nxrrset_name, qtype, response);
+    EXPECT_THROW(nxrrset_query.process(), Query::NoSOA);
+}
+
 TEST_F(QueryTest, noMatchZone) {
     // there's a zone in the memory datasource but it doesn't match the qname.
     // should result in REFUSED.




More information about the bind10-changes mailing list