Browse Source

handled SOA query correctly.

git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1421 e5f2f494-b856-4b98-b285-d166d9295462
JINMEI Tatuya 15 years ago
parent
commit
b15e778ce1
2 changed files with 45 additions and 1 deletions
  1. 19 0
      src/lib/auth/static_datasrc.cc
  2. 26 1
      src/lib/auth/tests/static_unittest.cc

+ 19 - 0
src/lib/auth/static_datasrc.cc

@@ -59,8 +59,10 @@ public:
     // We should revisit this design later.
     RRsetPtr authors;
     RRsetPtr authors_ns;
+    RRsetPtr authors_soa;
     RRsetPtr version;
     RRsetPtr version_ns;
+    RRsetPtr version_soa;
 };
 
 StaticDataSrcImpl::StaticDataSrcImpl() :
@@ -84,6 +86,12 @@ StaticDataSrcImpl::StaticDataSrcImpl() :
                                     RRType::NS(), RRTTL(0)));
     authors_ns->addRdata(generic::NS(authors_name));
 
+    authors_soa = RRsetPtr(new RRset(authors_name, RRClass::CH(),
+                                     RRType::SOA(), RRTTL(86400)));
+    authors_soa->addRdata(generic::SOA(
+                              "authors.bind. hostmaster.authors.bind. "
+                              "0 28800 7200 604800 86400"));
+
     version = RRsetPtr(new RRset(version_name, RRClass::CH(),
                                  RRType::TXT(), RRTTL(0)));
     version->addRdata(generic::TXT("BIND10 0.0.0 (pre-alpha)"));
@@ -91,6 +99,12 @@ StaticDataSrcImpl::StaticDataSrcImpl() :
     version_ns = RRsetPtr(new RRset(version_name, RRClass::CH(),
                                     RRType::NS(), RRTTL(0)));
     version_ns->addRdata(generic::NS(version_name));
+
+    version_soa = RRsetPtr(new RRset(version_name, RRClass::CH(),
+                                     RRType::SOA(), RRTTL(86400)));
+    version_soa->addRdata(generic::SOA(
+                              "version.bind. hostmaster.version.bind. "
+                               "0 28800 7200 604800 86400"));
 }
 
 StaticDataSrc::StaticDataSrc()
@@ -177,6 +191,8 @@ StaticDataSrc::findRRset(const Name& qname,
                 target.addRRset(impl_->version);
             } else if (qtype == RRType::NS()) {
                 target.addRRset(impl_->version_ns);
+            } else if (qtype == RRType::SOA()) {
+                target.addRRset(impl_->version_soa);
             } else {
                 flags = TYPE_NOT_FOUND;
             }
@@ -192,6 +208,9 @@ StaticDataSrc::findRRset(const Name& qname,
             } else if (qtype == RRType::NS()) {
                 target.addRRset(impl_->authors_ns);
                 return (SUCCESS);
+            } else if (qtype == RRType::SOA()) {
+                target.addRRset(impl_->authors_soa);
+                return (SUCCESS);
             } else {
                 flags = TYPE_NOT_FOUND;
             }

+ 26 - 1
src/lib/auth/tests/static_unittest.cc

@@ -45,7 +45,8 @@ protected:
                              authors_name("authors.bind"),
                              nomatch_name("example.com"),
                              rrclass(RRClass::CH()), rrtype(RRType::TXT()),
-                             rrttl(RRTTL(0)), find_flags(0), matched_rdata(0)
+                             rrttl(RRTTL(0)), soa_rrttl(RRTTL(86400)),
+                             find_flags(0), matched_rdata(0)
     {
         // XXX: the following values can change as release/developers change,
         // in which case the test code must be updated accordingly.
@@ -66,6 +67,11 @@ protected:
 
         version_ns_data.push_back("version.bind.");
         authors_ns_data.push_back("authors.bind.");
+
+        version_soa_data.push_back("version.bind. hostmaster.version.bind. "
+                                   "0 28800 7200 604800 86400");
+        authors_soa_data.push_back("authors.bind. hostmaster.authors.bind. "
+                                   "0 28800 7200 604800 86400");
     }
     StaticDataSrc data_source;
     const Name version_name;
@@ -74,6 +80,7 @@ protected:
     const RRClass rrclass;
     RRType rrtype;              // we allow this to be modified in the test
     RRTTL rrttl;
+    RRTTL soa_rrttl;
     RRsetList result_sets;
     uint32_t find_flags;
     unsigned matched_rdata;
@@ -81,6 +88,8 @@ protected:
     vector<string> authors_data;
     vector<string> version_ns_data;
     vector<string> authors_ns_data;
+    vector<string> version_soa_data;
+    vector<string> authors_soa_data;
 };
 
 void
@@ -218,6 +227,14 @@ TEST_F(StaticDataSourceTest, findRRsetVersionNS) {
               rrtype, rrttl, 0, version_ns_data);
 }
 
+TEST_F(StaticDataSourceTest, findRRsetVersionSOA) {
+    rrtype = RRType::SOA();
+    checkFind(data_source, version_name, NULL, rrclass, rrclass,
+              rrtype, soa_rrttl, 0, version_soa_data);
+    checkFind(data_source, version_name, &version_name, rrclass, rrclass,
+              rrtype, soa_rrttl, 0, version_soa_data);
+}
+
 TEST_F(StaticDataSourceTest, findRRsetAuthorsTXT) {
     checkFind(data_source, authors_name, NULL, rrclass, rrclass,
               rrtype, rrttl, 0, authors_data);
@@ -233,6 +250,14 @@ TEST_F(StaticDataSourceTest, findRRsetAuthorsNS) {
               rrtype, rrttl, 0, authors_ns_data);
 }
 
+TEST_F(StaticDataSourceTest, findRRsetAuthorsSOA) {
+    rrtype = RRType::SOA();
+    checkFind(data_source, authors_name, NULL, rrclass, rrclass,
+              rrtype, soa_rrttl, 0, authors_soa_data);
+    checkFind(data_source, authors_name, &authors_name, rrclass, rrclass,
+              rrtype, soa_rrttl, 0, authors_soa_data);
+}
+
 // Class ANY lookup should result in the same answer.
 TEST_F(StaticDataSourceTest, findRRsetVersionClassAny) {
     checkFind(data_source, version_name, NULL, RRClass::ANY(), rrclass,