BIND 10 trac2427, updated. 90094d0add9f2047b2dbd307f800d4fb9ccccd73 [2427] Several more tests for $ORIGIN

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Dec 17 14:42:35 UTC 2012


The branch, trac2427 has been updated
       via  90094d0add9f2047b2dbd307f800d4fb9ccccd73 (commit)
      from  dc3f31bea1c264125464906dae050a995829e816 (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 90094d0add9f2047b2dbd307f800d4fb9ccccd73
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Dec 17 15:40:28 2012 +0100

    [2427] Several more tests for $ORIGIN
    
    Some corner cases and error crossbreeding with other features.

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

Summary of changes:
 src/lib/dns/tests/master_loader_unittest.cc |   43 +++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/tests/master_loader_unittest.cc b/src/lib/dns/tests/master_loader_unittest.cc
index f983e9b..c10018e 100644
--- a/src/lib/dns/tests/master_loader_unittest.cc
+++ b/src/lib/dns/tests/master_loader_unittest.cc
@@ -46,6 +46,11 @@ public:
                                &warnings_, _1, _2, _3))
     {}
 
+    void TearDown() {
+        // Check there are no more RRs we didn't expect
+        EXPECT_TRUE(rrsets_.empty());
+    }
+
     /// Concatenate file, line, and reason, and add it to either errors
     /// or warnings
     void callback(vector<string>* target, const std::string& file, size_t line,
@@ -289,6 +294,7 @@ TEST_F(MasterLoaderTest, incrementalLoad) {
     EXPECT_TRUE(warnings_.empty());
 
     checkRR("www.example.org", RRType::A(), "192.0.2.1");
+    checkRR("www.example.org", RRType::AAAA(), "2001:db8::1");
 }
 
 // Try loading from file that doesn't exist. There should be single error
@@ -325,6 +331,7 @@ struct ErrorCase {
     { "www      3600    IN  \"A\"   192.0.2.1", "Quoted type" },
     { "unbalanced)paren 3600    IN  A   192.0.2.1", "Token error 1" },
     { "www  3600    unbalanced)paren    A   192.0.2.1", "Token error 2" },
+    { ")www     3600    IN  A   192.0.2.1", "Token error 3" },
     // Check the unknown directive. The rest looks like ordinary RR,
     // so we see the $ is actually special.
     { "$UNKNOWN 3600    IN  A   192.0.2.1", "Unknown $ directive" },
@@ -336,6 +343,8 @@ struct ErrorCase {
         "Include file not found and garbage at the end of line" },
     { "$ORIGIN", "Missing origin name" },
     { "$ORIGIN invalid...name", "Invalid name for origin" },
+    { "$ORIGIN )brokentoken", "Broken token in origin" },
+    { "$ORIGIN example.org. garbage", "Garbage after origin" },
     { "$ORIGI name.", "$ORIGIN too short" },
     { "$ORIGINAL name.", "$ORIGIN too long" },
     { NULL, NULL }
@@ -468,6 +477,24 @@ TEST_F(MasterLoaderTest, includeAndOrigin) {
     checkARR("www.example.org");
 }
 
+// Like above, but the origin after include is bogus. The whole line should
+// be rejected.
+TEST_F(MasterLoaderTest, includeAndBadOrigin) {
+    const string include_string =
+        "$INCLUDE " TEST_DATA_SRCDIR "/example.org example..org.\n"
+        // Another RR to see the switch survives after we exit include
+        "www    1H  IN  A   192.0.2.1\n";
+    stringstream ss(include_string);
+    setLoader(ss, Name("example.org"), RRClass::IN(),
+              MasterLoader::MANY_ERRORS);
+    loader_->load();
+    EXPECT_FALSE(loader_->loadedSucessfully());
+    EXPECT_EQ(1, errors_.size());
+    EXPECT_TRUE(warnings_.empty());
+    // And check it's the correct data
+    checkARR("www.example.org");
+}
+
 // Check the origin doesn't get outside of the included file.
 TEST_F(MasterLoaderTest, includeOriginRestore) {
     const string include_string = "$INCLUDE " TEST_DATA_SRCDIR "/origincheck.txt\n"
@@ -523,6 +550,9 @@ TEST_F(MasterLoaderTest, loadTwice) {
 
     loader_->load();
     EXPECT_THROW(loader_->load(), isc::InvalidOperation);
+    // Don't check them, they are not interesting, so suppress the error
+    // at TearDown
+    rrsets_.clear();
 }
 
 // Load 0 items should be rejected
@@ -551,4 +581,17 @@ TEST_F(MasterLoaderTest, noEOLN) {
             "admin.example.org. 1234 3600 1800 2419200 7200");
 }
 
+// Test it rejects when we don't have the previous name to use in place of
+// initial whitespace
+TEST_F(MasterLoaderTest, noPreviousName) {
+    const string input("    1H  IN  A   192.0.2.1\n");
+    stringstream ss(input);
+    setLoader(ss, Name("example.org."), RRClass::IN(),
+              MasterLoader::MANY_ERRORS);
+    loader_->load();
+    EXPECT_FALSE(loader_->loadedSucessfully());
+    EXPECT_EQ(1, errors_.size());
+    EXPECT_TRUE(warnings_.empty());
+}
+
 }



More information about the bind10-changes mailing list