Browse Source

[1063] Few more delegation corner-cases tested

Michal 'vorner' Vaner 13 years ago
parent
commit
005c77dfe5
1 changed files with 44 additions and 0 deletions
  1. 44 0
      src/lib/datasrc/tests/database_unittest.cc

+ 44 - 0
src/lib/datasrc/tests/database_unittest.cc

@@ -277,6 +277,14 @@ private:
         addRecord("A", "3600", "", "192.0.2.1");
         addRecord("A", "3600", "", "192.0.2.1");
         addCurName("below.dname.example.org.");
         addCurName("below.dname.example.org.");
 
 
+        // Broken NS
+        addRecord("A", "3600", "", "192.0.2.1");
+        addRecord("NS", "3600", "", "ns.example.com.");
+        addCurName("brokenns1.example.org.");
+        addRecord("NS", "3600", "", "ns.example.com.");
+        addRecord("A", "3600", "", "192.0.2.1");
+        addCurName("brokenns2.example.org.");
+
         // Now double DNAME, to test failure mode
         // Now double DNAME, to test failure mode
         addRecord("DNAME", "3600", "", "dname1.example.com.");
         addRecord("DNAME", "3600", "", "dname1.example.com.");
         addRecord("DNAME", "3600", "", "dname2.example.com.");
         addRecord("DNAME", "3600", "", "dname2.example.com.");
@@ -719,6 +727,14 @@ TEST_F(DatabaseClientTest, find) {
                expected_sig_rdatas);
                expected_sig_rdatas);
     EXPECT_FALSE(current_database_->searchRunning());
     EXPECT_FALSE(current_database_->searchRunning());
 
 
+    expected_rdatas.clear();
+    expected_rdatas.push_back("ns.example.com.");
+    doFindTest(finder, isc::dns::Name("example.org."),
+               isc::dns::RRType::NS(), isc::dns::RRType::NS(),
+               isc::dns::RRTTL(3600), ZoneFinder::SUCCESS, expected_rdatas,
+               expected_sig_rdatas);
+    EXPECT_FALSE(current_database_->searchRunning());
+
     // Check when we ask for something below delegation point, we get the NS
     // Check when we ask for something below delegation point, we get the NS
     // (Both when the RRset there exists and doesn't)
     // (Both when the RRset there exists and doesn't)
     expected_rdatas.clear();
     expected_rdatas.clear();
@@ -749,6 +765,13 @@ TEST_F(DatabaseClientTest, find) {
                expected_sig_rdatas);
                expected_sig_rdatas);
     EXPECT_FALSE(current_database_->searchRunning());
     EXPECT_FALSE(current_database_->searchRunning());
 
 
+    // And when we ask direcly for the NS, we should still get delegation
+    doFindTest(finder, isc::dns::Name("delegation.example.org."),
+               isc::dns::RRType::NS(), isc::dns::RRType::NS(),
+               isc::dns::RRTTL(3600), ZoneFinder::DELEGATION, expected_rdatas,
+               expected_sig_rdatas);
+    EXPECT_FALSE(current_database_->searchRunning());
+
     // Now test delegation. If it is below the delegation point, we should get
     // Now test delegation. If it is below the delegation point, we should get
     // the DNAME (the one with data under DNAME is invalid zone, but we test
     // the DNAME (the one with data under DNAME is invalid zone, but we test
     // the behaviour anyway just to make sure)
     // the behaviour anyway just to make sure)
@@ -780,12 +803,33 @@ TEST_F(DatabaseClientTest, find) {
                expected_sig_rdatas);
                expected_sig_rdatas);
     EXPECT_FALSE(current_database_->searchRunning());
     EXPECT_FALSE(current_database_->searchRunning());
 
 
+    // Asking direcly for DNAME should give SUCCESS
+    expected_rdatas.clear();
+    expected_rdatas.push_back("dname.example.com.");
+    doFindTest(finder, isc::dns::Name("dname.example.org."),
+               isc::dns::RRType::DNAME(), isc::dns::RRType::DNAME(),
+               isc::dns::RRTTL(3600), ZoneFinder::SUCCESS, expected_rdatas,
+               expected_sig_rdatas);
+
     // This is broken dname, it contains two targets
     // This is broken dname, it contains two targets
     EXPECT_THROW(finder->find(isc::dns::Name("below.baddname.example.org."),
     EXPECT_THROW(finder->find(isc::dns::Name("below.baddname.example.org."),
                               isc::dns::RRType::A(), NULL,
                               isc::dns::RRType::A(), NULL,
                               ZoneFinder::FIND_DEFAULT),
                               ZoneFinder::FIND_DEFAULT),
                  DataSourceError);
                  DataSourceError);
     EXPECT_FALSE(current_database_->searchRunning());
     EXPECT_FALSE(current_database_->searchRunning());
+
+    // Broken NS - it lives together with something else
+    EXPECT_FALSE(current_database_->searchRunning());
+    EXPECT_THROW(finder->find(isc::dns::Name("brokenns1.example.org."),
+                              isc::dns::RRType::A(), NULL,
+                              ZoneFinder::FIND_DEFAULT),
+                 DataSourceError);
+    EXPECT_FALSE(current_database_->searchRunning());
+    EXPECT_THROW(finder->find(isc::dns::Name("brokenns2.example.org."),
+                              isc::dns::RRType::A(), NULL,
+                              ZoneFinder::FIND_DEFAULT),
+                 DataSourceError);
+    EXPECT_FALSE(current_database_->searchRunning());
 }
 }
 
 
 TEST_F(DatabaseClientTest, getOrigin) {
 TEST_F(DatabaseClientTest, getOrigin) {