]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2427] Test for $ORIGIN handling
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Fri, 14 Dec 2012 12:45:48 +0000 (13:45 +0100)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Fri, 14 Dec 2012 12:45:48 +0000 (13:45 +0100)
src/lib/dns/tests/master_loader_unittest.cc

index bfbf9fa357737a3060dece73adfb271fae6369b0..3644f08fcc656c01ef658e802c11bd9c5661dfd3 100644 (file)
@@ -123,6 +123,10 @@ public:
         checkRR("www.example.org", RRType::A(), "192.0.2.1");
     }
 
+    void checkARR(const string& name) {
+        checkRR(name, RRType::A(), "192.0.2.1");
+    }
+
     MasterLoaderCallbacks callbacks_;
     boost::scoped_ptr<MasterLoader> loader_;
     vector<string> errors_;
@@ -179,6 +183,46 @@ TEST_F(MasterLoaderTest, include) {
     }
 }
 
+TEST_F(MasterLoaderTest, origin) {
+    // Varius forms of the directive
+    const char* origins[] = {
+        "$origin",
+        "$ORIGIN",
+        "$Origin",
+        "$OrigiN",
+        "\"$ORIGIN\"",
+        NULL
+    };
+    for (const char** origin = origins; *origin != NULL; ++origin) {
+        SCOPED_TRACE(*origin);
+
+        clear();
+        const string directive = *origin;
+        const string input =
+            "@  1H  IN  A   192.0.2.1\n" +
+            directive + " sub.example.org.\n"
+            "www    1H  IN  A   192.0.2.1\n" +
+            // Relative name in the origin
+            directive + " relative\n"
+            "@  1H  IN  A   192.0.2.1\n"
+            // Origin is _not_ used here (absolute name)
+            "noorigin.example.org.  60M IN  A   192.0.2.1\n";
+        stringstream ss(input);
+        setLoader(ss, Name("example.org."), RRClass::IN(),
+                  MasterLoader::MANY_ERRORS);
+
+        loader_->load();
+        EXPECT_TRUE(loader_->loadedSucessfully());
+        EXPECT_TRUE(errors_.empty());
+        EXPECT_TRUE(warnings_.empty());
+
+        checkARR("example.org");
+        checkARR("www.sub.example.org");
+        checkARR("relative.sub.example.org");
+        checkARR("noorigin.example.org");
+    }
+}
+
 // Test the source is correctly popped even after error
 TEST_F(MasterLoaderTest, popAfterError) {
     const string include_str = "$include " TEST_DATA_SRCDIR