]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2429] some other cases with $TTL, including more than one $TTL w/ change val.
authorJINMEI Tatuya <jinmei@isc.org>
Wed, 12 Dec 2012 04:45:34 +0000 (20:45 -0800)
committerJINMEI Tatuya <jinmei@isc.org>
Thu, 13 Dec 2012 07:44:11 +0000 (23:44 -0800)
src/lib/dns/master_loader.cc
src/lib/dns/tests/master_loader_unittest.cc

index bdae59ba0cb442c9a61fac15ee98c0f43fb95e5d..e81ab5c560dd4aab2736d45a90db56c0829e91cf 100644 (file)
@@ -142,8 +142,9 @@ public:
     void setDefaultTTL(const string& ttl_txt) {
         if (!default_ttl_) {
             default_ttl_.reset(new RRTTL(ttl_txt));
+        } else {
+            *default_ttl_ = RRTTL(ttl_txt);
         }
-        //setCurrentTTL(*default_ttl_);
         eatUntilEOL(true);
     }
 
@@ -288,9 +289,12 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
 
             // The parameters
             MasterToken rrparam_token = lexer_.getNextToken();
+
+            bool explicit_ttl = false;
             if (rrparam_token.getType() == MasterToken::STRING) {
                 // Try TTL
                 if (setCurrentTTL(rrparam_token.getString())) {
+                    explicit_ttl = true;
                     rrparam_token = lexer_.getNextToken();
                 }
             }
@@ -303,6 +307,8 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
                 if (default_ttl_) {
                     setCurrentTTL(*default_ttl_);
                 } // TBD: else: try SOA min TTL for default, then error
+            } else if (!explicit_ttl && default_ttl_) {
+                setCurrentTTL(*default_ttl_);
             }
 
             // TODO: Some more validation?
index 7e4354ce1f1b8c7d5abdeb1903cb6d49de370393..a2cea04ac2f9165a23a4e73e8fe051100702809f 100644 (file)
@@ -389,15 +389,22 @@ TEST_F(MasterLoaderTest, includeWithGarbage) {
 
 // Test for "$TTL"
 TEST_F(MasterLoaderTest, ttlDirective) {
+    stringstream zone_stream;
+
     // Set the default TTL with $TTL followed by an RR omitting the TTL
-    const string input("$TTL 1800\n"
-                       "example.org. IN A 192.0.2.1\n");
-    stringstream zone_stream(input);
+    zone_stream << "$TTL 1800\nexample.org. IN A 192.0.2.1\n";
+    // $TTL can be quoted.  Also testing the case of $TTL being changed.
+    zone_stream << "\"$TTL\" 100\na1.example.org. IN A 192.0.2.2\n";
+    // Extended TTL form is accepted.
+    zone_stream << "$TTL 1H\na2.example.org. IN A 192.0.2.3\n";
+
     setLoader(zone_stream, Name("example.org."), RRClass::IN(),
               MasterLoader::DEFAULT);
     loader_->load();
     EXPECT_TRUE(loader_->loadedSucessfully());
     checkRR("example.org", RRType::A(), "192.0.2.1", RRTTL(1800));
+    checkRR("a1.example.org", RRType::A(), "192.0.2.2", RRTTL(100));
+    checkRR("a2.example.org", RRType::A(), "192.0.2.3", RRTTL(3600));
 }
 
 // Test the constructor rejects empty add callback.