Commit 1f1d6219 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2429] some other cases with $TTL, including more than one $TTL w/ change val.

parent 84a3a650
......@@ -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?
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment