Browse Source

[2421] Add unit tests for broken zones during configure()

Mukund Sivaraman 12 years ago
parent
commit
49d6a081b5

+ 8 - 0
src/lib/datasrc/tests/client_list_unittest.cc

@@ -838,16 +838,24 @@ TEST_F(ListTest, BadMasterFile) {
         "   \"cache-enable\": true,"
         "   \"params\": {"
         "       \"example.com.\": \"" TEST_DATA_DIR "/example.com.flattened\","
+        "       \"example.net.\": \"" TEST_DATA_DIR "/example.net-empty\","
+        "       \"example.edu.\": \"" TEST_DATA_DIR "/example.edu-broken\","
+        "       \"example.info.\": \"" TEST_DATA_DIR "/example.info-nonexist\","
         "       \"foo.bar.\": \"" TEST_DATA_DIR "/example.org.nsec3-signed\","
         "       \".\": \"" TEST_DATA_DIR "/root.zone\""
         "   }"
         "}]"));
+
+    // this should not throw even if there are any zone loading errors.
     list_->configure(elem, true);
 
     positiveResult(list_->find(Name("example.com."), true), ds_[0],
                    Name("example.com."), true, "example.com", true);
     EXPECT_TRUE(negative_result_ == list_->find(Name("example.org."), true));
     EXPECT_TRUE(negative_result_ == list_->find(Name("foo.bar"), true));
+    EXPECT_TRUE(negative_result_ == list_->find(Name("example.net."), true));
+    EXPECT_TRUE(negative_result_ == list_->find(Name("example.edu."), true));
+    EXPECT_TRUE(negative_result_ == list_->find(Name("example.info."), true));
     positiveResult(list_->find(Name(".")), ds_[0], Name("."), true, "root",
                    true);
 }

+ 11 - 0
src/lib/datasrc/tests/testdata/example.edu-broken

@@ -0,0 +1,11 @@
+example.edu.	3600	IN	SOA	ns1.example.edu. admin.example.edu. 1234 3600 1800 2419200 7200
+example.edu.	3600	IN	NS	ns1.example.edu.
+example.edu.	3600	IN	NS	ns2.example.edu.
+example.edu.	3600	IN	MX	10 mail.example.edu.
+www.example.edu.	3600	IN	A	192.0.2.1
+ns1.example.edu.	3600	IN	A	192.0.2.3
+ns2.example.edu.	3600	IN	A	192.0.2.4
+
+;; DNAME + NS (non-apex) throws ZoneDataUpdater::AddError
+ns1.example.edu.        3600    IN DNAME    foo.example.edu.
+ns1.example.edu.        3600    IN NS       bar.example.edu.

+ 1 - 0
src/lib/datasrc/tests/testdata/example.net-empty

@@ -0,0 +1 @@
+