|
@@ -205,6 +205,9 @@ public:
|
|
|
{"*.dnamewild.example.org. 300 IN DNAME dnamewild.example.",
|
|
|
&rr_dnamewild_},
|
|
|
{"*.child.example.org. 300 IN A 192.0.2.1", &rr_child_wild_},
|
|
|
+ {"bar.foo.wild.example.org. 300 IN A 192.0.2.2", &rr_not_wild_},
|
|
|
+ {"baz.foo.wild.example.org. 300 IN A 192.0.2.3",
|
|
|
+ &rr_not_wild_another_},
|
|
|
{NULL, NULL}
|
|
|
};
|
|
|
|
|
@@ -256,6 +259,8 @@ public:
|
|
|
RRsetPtr rr_nswild_, rr_dnamewild_;
|
|
|
RRsetPtr rr_child_wild_;
|
|
|
RRsetPtr rr_under_wild_;
|
|
|
+ RRsetPtr rr_not_wild_;
|
|
|
+ RRsetPtr rr_not_wild_another_;
|
|
|
|
|
|
/**
|
|
|
* \brief Test one find query to the zone.
|
|
@@ -298,6 +303,11 @@ public:
|
|
|
if (check_answer) {
|
|
|
EXPECT_EQ(answer, find_result.rrset);
|
|
|
} else if (check_wild_answer) {
|
|
|
+ ASSERT_NE(ConstRRsetPtr(), answer) <<
|
|
|
+ "Wrong test, don't check for wild names if you expect "
|
|
|
+ "empty answer";
|
|
|
+ ASSERT_NE(ConstRRsetPtr(), find_result.rrset) <<
|
|
|
+ "No answer found";
|
|
|
RdataIteratorPtr expectedIt(answer->getRdataIterator());
|
|
|
RdataIteratorPtr actualIt(
|
|
|
find_result.rrset->getRdataIterator());
|
|
@@ -323,6 +333,8 @@ public:
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ // Internal part of the cancelWildcard test that is multiple times
|
|
|
+ void doCancelWildcardTest();
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -885,6 +897,81 @@ TEST_F(MemoryZoneTest, nestedEmptyWildcard) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// We run this part twice from the below test, in two slightly different
|
|
|
+// situations
|
|
|
+void
|
|
|
+MemoryZoneTest::doCancelWildcardTest() {
|
|
|
+ // These should be canceled
|
|
|
+ {
|
|
|
+ SCOPED_TRACE("Canceled under foo.wild.example.org");
|
|
|
+ findTest(Name("aaa.foo.wild.example.org"), RRType::A(),
|
|
|
+ Zone::NXDOMAIN);
|
|
|
+ findTest(Name("zzz.foo.wild.example.org"), RRType::A(),
|
|
|
+ Zone::NXDOMAIN);
|
|
|
+ }
|
|
|
+
|
|
|
+ // This is existing, non-wildcard domain, shouldn't wildcard at all
|
|
|
+ {
|
|
|
+ SCOPED_TRACE("Existing domain under foo.wild.example.org");
|
|
|
+ findTest(Name("bar.foo.wild.example.org"), RRType::A(), Zone::SUCCESS,
|
|
|
+ true, rr_not_wild_);
|
|
|
+ }
|
|
|
+
|
|
|
+ // These should be caught by the wildcard
|
|
|
+ {
|
|
|
+ SCOPED_TRACE("Neighbor wildcards to foo.wild.example.org");
|
|
|
+
|
|
|
+ const char* names[] = {
|
|
|
+ "aaa.bbb.wild.example.org",
|
|
|
+ "aaa.zzz.wild.example.org",
|
|
|
+ "zzz.wild.example.org",
|
|
|
+ NULL
|
|
|
+ };
|
|
|
+
|
|
|
+ for (const char** name(names); *name != NULL; ++ name) {
|
|
|
+ SCOPED_TRACE(string("Node ") + *name);
|
|
|
+
|
|
|
+ findTest(Name(*name), RRType::A(), Zone::SUCCESS, false, rr_wild_,
|
|
|
+ NULL, NULL, Zone::FIND_DEFAULT, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // This shouldn't be wildcarded, it's an existing domain
|
|
|
+ {
|
|
|
+ SCOPED_TRACE("The foo.wild.example.org itself");
|
|
|
+ findTest(Name("foo.wild.example.org"), RRType::A(), Zone::NXRRSET);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * This tests that if there's a name between the wildcard domain and the
|
|
|
+ * searched one, it will not trigger wildcard, for example, if we have
|
|
|
+ * *.wild.example.org and bar.foo.wild.example.org, then we know
|
|
|
+ * foo.wild.example.org exists and is not wildcard. Therefore, search for
|
|
|
+ * aaa.foo.wild.example.org should return NXDOMAIN.
|
|
|
+ *
|
|
|
+ * Tests few cases "around" the canceled wildcard match, to see something that
|
|
|
+ * shouldn't be canceled isn't.
|
|
|
+ */
|
|
|
+TEST_F(MemoryZoneTest, cancelWildcard) {
|
|
|
+ EXPECT_EQ(SUCCESS, zone_.add(rr_wild_));
|
|
|
+ EXPECT_EQ(SUCCESS, zone_.add(rr_not_wild_));
|
|
|
+
|
|
|
+ {
|
|
|
+ SCOPED_TRACE("Runnig with single entry under foo.wild.example.org");
|
|
|
+ doCancelWildcardTest();
|
|
|
+ }
|
|
|
+
|
|
|
+ // Try putting another one under foo.wild....
|
|
|
+ // The result should be the same but it will be done in another way in the
|
|
|
+ // code, because the foo.wild.example.org will exist in the tree.
|
|
|
+ EXPECT_EQ(SUCCESS, zone_.add(rr_not_wild_another_));
|
|
|
+ {
|
|
|
+ SCOPED_TRACE("Runnig with two entries under foo.wild.example.org");
|
|
|
+ doCancelWildcardTest();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
TEST_F(MemoryZoneTest, loadBadWildcard) {
|
|
|
// We reject loading the zone if it contains a wildcard name for
|
|
|
// NS or DNAME.
|