BIND 10 trac1793, updated. 4deb49cf84c399a0ca1a84fef1cd0dee4ca4d5d5 [1793] More tests

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Apr 17 11:38:02 UTC 2012


The branch, trac1793 has been updated
       via  4deb49cf84c399a0ca1a84fef1cd0dee4ca4d5d5 (commit)
      from  f00dd21c6c495e180feb855139d36fc7f99f23d8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4deb49cf84c399a0ca1a84fef1cd0dee4ca4d5d5
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Apr 17 13:36:34 2012 +0200

    [1793] More tests
    
    Checking various error modes, like unreadable database, wrong or missing
    configuration.

-----------------------------------------------------------------------

Summary of changes:
 src/bin/auth/tests/command_unittest.cc |   85 +++++++++++++++++++++++++++-----
 1 files changed, 73 insertions(+), 12 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/auth/tests/command_unittest.cc b/src/bin/auth/tests/command_unittest.cc
index 5e6be95..52f60b3 100644
--- a/src/bin/auth/tests/command_unittest.cc
+++ b/src/bin/auth/tests/command_unittest.cc
@@ -264,6 +264,7 @@ TEST_F(AuthCommandTest,
 {
     // Prepare the database first
     const string test_db = TEST_DATA_BUILDDIR "/auth_test.sqlite3.copied";
+    const string bad_db = TEST_DATA_BUILDDIR "/does-not-exist.sqlite3";
     stringstream ss("example.org. 3600 IN SOA . . 0 0 0 0 0\n");
     createSQLite3DB(RRClass::IN(), Name("example.org"), test_db.c_str(), ss);
 
@@ -276,18 +277,19 @@ TEST_F(AuthCommandTest,
     ModuleCCSession moduleSession(SPEC_FILE, session, NULL, NULL, false,
                                   false);
     // This describes the data source in the configuration
-    ElementPtr map(Element::fromJSON("{\"datasources\": ["
-                                     "  {"
-                                     "    \"type\": \"memory\","
-                                     "    \"zones\": ["
-                                     "      {"
-                                     "        \"origin\": \"example.org\","
-                                     "        \"file\": \"" + test_db + "\","
-                                     "        \"filetype\": \"sqlite3\""
-                                     "      }"
-                                     "    ]"
-                                     "  }"
-                                     "]}"));
+    const ElementPtr
+        map(Element::fromJSON("{\"datasources\": ["
+                              "  {"
+                              "    \"type\": \"memory\","
+                              "    \"zones\": ["
+                              "      {"
+                              "        \"origin\": \"example.org\","
+                              "        \"file\": \"" + test_db + "\","
+                              "        \"filetype\": \"sqlite3\""
+                              "      }"
+                              "    ]"
+                              "  }"
+                              "]}"));
     moduleSession.setLocalConfig(map);
     server_.setConfigSession(&moduleSession);
 
@@ -309,6 +311,65 @@ TEST_F(AuthCommandTest,
     EXPECT_EQ(ZoneFinder::SUCCESS, server_.getInMemoryClient(RRClass::IN())->
               findZone(Name("example.org")).zone_finder->
               find(Name("example.org"), RRType::SOA())->code);
+
+    // Some error cases. First, the zone has no configuration.
+    dsrc->addZone(ZoneFinderPtr(new InMemoryZoneFinder(RRClass::IN(),
+                                                       Name("example.com"))));
+    result_ = execAuthServerCommand(server_, "loadzone",
+        Element::fromJSON("{\"origin\": \"example.com\"}"));
+    checkAnswer(1);
+
+    EXPECT_EQ(ZoneFinder::SUCCESS, server_.getInMemoryClient(RRClass::IN())->
+              findZone(Name("example.org")).zone_finder->
+              find(Name("example.org"), RRType::SOA())->code);
+
+    moduleSession.setLocalConfig(Element::fromJSON("{\"datasources\": []}"));
+    result_ = execAuthServerCommand(server_, "loadzone",
+        Element::fromJSON("{\"origin\": \"example.org\"}"));
+    checkAnswer(1);
+
+    // The previous zone is not hurt in any way
+    EXPECT_EQ(ZoneFinder::SUCCESS, server_.getInMemoryClient(RRClass::IN())->
+              findZone(Name("example.org")).zone_finder->
+              find(Name("example.org"), RRType::SOA())->code);
+    // Configure an unreadable zone. Should fail, but leave the original zone
+    // data there
+    const ElementPtr
+        mapBad(Element::fromJSON("{\"datasources\": ["
+                                 "  {"
+                                 "    \"type\": \"memory\","
+                                 "    \"zones\": ["
+                                 "      {"
+                                 "        \"origin\": \"example.org\","
+                                 "        \"file\": \"" + bad_db + "\","
+                                 "        \"filetype\": \"sqlite3\""
+                                 "      }"
+                                 "    ]"
+                                 "  }"
+                                 "]}"));
+    moduleSession.setLocalConfig(mapBad);
+    result_ = execAuthServerCommand(server_, "loadzone",
+        Element::fromJSON("{\"origin\": \"example.com\"}"));
+    checkAnswer(1);
+    // The previous zone is not hurt in any way
+    EXPECT_EQ(ZoneFinder::SUCCESS, server_.getInMemoryClient(RRClass::IN())->
+              findZone(Name("example.org")).zone_finder->
+              find(Name("example.org"), RRType::SOA())->code);
+
+    // Broken configuration (not valid against the spec)
+    const ElementPtr
+        broken(Element::fromJSON("{\"datasources\": ["
+                                 "  {"
+                                 "    \"type\": \"memory\","
+                                 "    \"zones\": [[]]"
+                                 "  }"
+                                 "]}"));
+    moduleSession.setLocalConfig(broken);
+    checkAnswer(1);
+    // The previous zone is not hurt in any way
+    EXPECT_EQ(ZoneFinder::SUCCESS, server_.getInMemoryClient(RRClass::IN())->
+              findZone(Name("example.org")).zone_finder->
+              find(Name("example.org"), RRType::SOA())->code);
 }
 
 TEST_F(AuthCommandTest, loadBrokenZone) {



More information about the bind10-changes mailing list