|
@@ -126,7 +126,9 @@ public:
|
|
|
rr_ns_(new RRset(origin_, class_, RRType::NS(), RRTTL(300))),
|
|
|
rr_ns_a_(new RRset(ns_name_, class_, RRType::A(), RRTTL(300))),
|
|
|
rr_ns_aaaa_(new RRset(ns_name_, class_, RRType::AAAA(), RRTTL(300))),
|
|
|
- rr_a_(new RRset(origin_, class_, RRType::A(), RRTTL(300)))
|
|
|
+ rr_a_(new RRset(origin_, class_, RRType::A(), RRTTL(300))),
|
|
|
+ rr_delegation_(new RRset(Name("subdomain.example.org"), class_,
|
|
|
+ RRType::NS(), RRTTL(300)))
|
|
|
{
|
|
|
}
|
|
|
// Some data to test with
|
|
@@ -151,7 +153,34 @@ public:
|
|
|
// AAAA of ns.example.org
|
|
|
rr_ns_aaaa_,
|
|
|
// A of example.org
|
|
|
- rr_a_;
|
|
|
+ rr_a_,
|
|
|
+ // A subdomain.example.org NS, for delegation
|
|
|
+ rr_delegation_;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * \brief Test one find query to the zone.
|
|
|
+ *
|
|
|
+ * Asks a query to the zone and checks it does not throw and returns
|
|
|
+ * expected results. It returns nothing, it just signals failures
|
|
|
+ * to GTEST.
|
|
|
+ *
|
|
|
+ * \param name The name to ask for.
|
|
|
+ * \param rrtype The RRType to ask of.
|
|
|
+ * \param result The expected code of the result.
|
|
|
+ * \param answer The expected rrset, if any should be returned.
|
|
|
+ */
|
|
|
+ void findTest(const Name& name, const RRType& rrtype, Zone::Result result,
|
|
|
+ const ConstRRsetPtr& answer = ConstRRsetPtr())
|
|
|
+ {
|
|
|
+ // The whole block is inside, because we need to check the result and
|
|
|
+ // we can't assign to FindResult
|
|
|
+ EXPECT_NO_THROW({
|
|
|
+ Zone::FindResult find_result(zone_.find(name, rrtype));
|
|
|
+ // Check it returns correct answers
|
|
|
+ EXPECT_EQ(result, find_result.code);
|
|
|
+ EXPECT_EQ(answer, find_result.rrset);
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -189,4 +218,38 @@ TEST_F(MemoryZoneTest, add) {
|
|
|
EXPECT_NO_THROW(EXPECT_EQ(EXIST, zone_.add(rr_ns_a_)));
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * \brief Test searching.
|
|
|
+ *
|
|
|
+ * Check it finds or does not find correctly and does not throw exceptions.
|
|
|
+ * \todo This doesn't do any kind of CNAME and so on. If it isn't
|
|
|
+ * directly there, it just tells it doesn't exist.
|
|
|
+ */
|
|
|
+TEST_F(MemoryZoneTest, find) {
|
|
|
+ // Fill some data inside
|
|
|
+ using namespace result; // Who should write the prefix all the time
|
|
|
+ // Now put all the data we have there. It should throw nothing
|
|
|
+ EXPECT_NO_THROW(EXPECT_EQ(SUCCESS, zone_.add(rr_ns_)));
|
|
|
+ EXPECT_NO_THROW(EXPECT_EQ(SUCCESS, zone_.add(rr_ns_a_)));
|
|
|
+ EXPECT_NO_THROW(EXPECT_EQ(SUCCESS, zone_.add(rr_ns_aaaa_)));
|
|
|
+ EXPECT_NO_THROW(EXPECT_EQ(SUCCESS, zone_.add(rr_a_)));
|
|
|
+ EXPECT_NO_THROW(EXPECT_EQ(SUCCESS, zone_.add(rr_delegation_)));
|
|
|
+
|
|
|
+ // These two should be successful
|
|
|
+ findTest(origin_, RRType::NS(), Zone::SUCCESS, rr_ns_);
|
|
|
+ findTest(ns_name_, RRType::A(), Zone::SUCCESS, rr_ns_a_);
|
|
|
+
|
|
|
+ // These domain exist but don't have the provided RRType
|
|
|
+ findTest(origin_, RRType::AAAA(), Zone::NXRRSET);
|
|
|
+ findTest(ns_name_, RRType::NS(), Zone::NXRRSET);
|
|
|
+
|
|
|
+ // These domains don't exist (and one is out of the zone)
|
|
|
+ findTest(Name("nothere.example.org"), RRType::A(), Zone::NXDOMAIN);
|
|
|
+ findTest(Name("example.net"), RRType::A(), Zone::NXDOMAIN);
|
|
|
+
|
|
|
+ // This should delegate
|
|
|
+ findTest(Name("a.subdomain.example.org"), RRType::MX(), Zone::DELEGATION,
|
|
|
+ rr_delegation_);
|
|
|
+}
|
|
|
+
|
|
|
}
|