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);
}
// 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();
}
}
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?
// 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.