Commit 8fd5cc45 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2427] Test for $ORIGIN handling

parent a7e16e85
......@@ -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
......
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