Browse Source

Another test

Zone with unreachable nameserver

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac408@3526 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner 14 years ago
parent
commit
b282bbc216
1 changed files with 42 additions and 0 deletions
  1. 42 0
      src/lib/nsas/tests/nameserver_address_store_unittest.cc

+ 42 - 0
src/lib/nsas/tests/nameserver_address_store_unittest.cc

@@ -296,6 +296,48 @@ TEST_F(NameserverAddressStoreTest, zoneWithoutNameservers) {
     EXPECT_FALSE(NSASCallback::results[0].first);
 }
 
+/**
+ * \short Try looking up a zone that has only an unreachable nameserver.
+ *
+ * It should be unreachable. Furthermore, subsequent questions for that zone
+ * or other zone with the same nameserver should be unreachable right away,
+ * without further asking.
+ */
+TEST_F(NameserverAddressStoreTest, unreachableNS) {
+    DerivedNsas nsas(defaultTestResolver, 10, 10);
+    // Ask it a question
+    nsas.lookup("example.net.", RRClass::IN().getCode(), *authority_,
+        vector<AbstractRRset>(), getCallback());
+    // It should ask for IP addresses for example.com.
+    ASSERT_EQ(2, defaultTestResolver.requests.size());
+    asksIPs(Name("example.com."), 0, 1);
+
+    // Ask another question with different zone but the same nameserver
+    authority_->setName(Name("example.com."));
+    nsas.lookup("example.com.", RRClass::IN().getCode(), *authority_,
+        vector<AbstractRRset>(), getCallback());
+    // It should ask nothing more now
+    EXPECT_EQ(2, defaultTestResolver.requests.size());
+
+    // We say there are no addresses
+    defaultTestResolver.requests[0].second->failure();
+    defaultTestResolver.requests[1].second->failure();
+
+    // We should have 2 answers now
+    EXPECT_EQ(2, NSASCallback::results.size());
+    // When we ask one same and one other zone with the same nameserver,
+    // it should generate no questions and answer right away
+    nsas.lookup("example.net.", RRClass::IN().getCode(), *authority_,
+        vector<AbstractRRset>(), getCallback());
+    nsas.lookup("example.org.", RRClass::IN().getCode(), *authority_,
+        vector<AbstractRRset>(), getCallback());
+    // There should be 4 negative answers now
+    EXPECT_EQ(4, NSASCallback::results.size());
+    BOOST_FOREACH(const NSASCallback::Result& result, NSASCallback::results) {
+        EXPECT_FALSE(result.first);
+    }
+}
+
 /// \short Test invalid authority section.
 TEST_F(NameserverAddressStoreTest, invalidAuthority) {
     DerivedNsas nsas(defaultTestResolver, 2, 2);