|
@@ -93,9 +93,9 @@ const char* const other_zone_rrs =
|
|
|
"mx.delegation.example.com. 3600 IN A 192.0.2.100\n";
|
|
|
|
|
|
// This is a mock Zone class for testing.
|
|
|
-// It is a derived class of Zone for the convenient of tests.
|
|
|
+// It is a derived class of ZoneFinder for the convenient of tests.
|
|
|
// Its find() method emulates the common behavior of protocol compliant
|
|
|
-// zone classes, but simplifies some minor cases and also supports broken
|
|
|
+// ZoneFinder classes, but simplifies some minor cases and also supports broken
|
|
|
// behavior.
|
|
|
// For simplicity, most names are assumed to be "in zone"; there's only
|
|
|
// one zone cut at the point of name "delegation.example.com".
|
|
@@ -103,9 +103,9 @@ const char* const other_zone_rrs =
|
|
|
// will result in DNAME.
|
|
|
// This mock zone doesn't handle empty non terminal nodes (if we need to test
|
|
|
// such cases find() should have specialized code for it).
|
|
|
-class MockZone : public Zone {
|
|
|
+class MockZoneFinder : public ZoneFinder {
|
|
|
public:
|
|
|
- MockZone() :
|
|
|
+ MockZoneFinder() :
|
|
|
origin_(Name("example.com")),
|
|
|
delegation_name_("delegation.example.com"),
|
|
|
dname_name_("dname.example.com"),
|
|
@@ -120,7 +120,7 @@ public:
|
|
|
other_zone_rrs;
|
|
|
|
|
|
masterLoad(zone_stream, origin_, rrclass_,
|
|
|
- boost::bind(&MockZone::loadRRset, this, _1));
|
|
|
+ boost::bind(&MockZoneFinder::loadRRset, this, _1));
|
|
|
}
|
|
|
virtual const isc::dns::Name& getOrigin() const { return (origin_); }
|
|
|
virtual const isc::dns::RRClass& getClass() const { return (rrclass_); }
|
|
@@ -163,9 +163,9 @@ private:
|
|
|
const RRClass rrclass_;
|
|
|
};
|
|
|
|
|
|
-Zone::FindResult
|
|
|
-MockZone::find(const Name& name, const RRType& type,
|
|
|
- RRsetList* target, const FindOptions options) const
|
|
|
+ZoneFinder::FindResult
|
|
|
+MockZoneFinder::find(const Name& name, const RRType& type,
|
|
|
+ RRsetList* target, const FindOptions options) const
|
|
|
{
|
|
|
// Emulating a broken zone: mandatory apex RRs are missing if specifically
|
|
|
// configured so (which are rare cases).
|
|
@@ -233,11 +233,15 @@ protected:
|
|
|
response.setRcode(Rcode::NOERROR());
|
|
|
response.setOpcode(Opcode::QUERY());
|
|
|
// create and add a matching zone.
|
|
|
- mock_zone = new MockZone();
|
|
|
- memory_datasrc.addZone(ZonePtr(mock_zone));
|
|
|
+ mock_finder = new MockZoneFinder();
|
|
|
+ memory_client.addZone(ZoneFinderPtr(mock_finder));
|
|
|
}
|
|
|
- MockZone* mock_zone;
|
|
|
- MemoryDataSrc memory_datasrc;
|
|
|
+ MockZoneFinder* mock_finder;
|
|
|
+ // We use InMemoryClient here. We could have some kind of mock client
|
|
|
+ // here, but historically, the Query supported only InMemoryClient
|
|
|
+ // (originally named MemoryDataSrc) and was tested with it, so we keep
|
|
|
+ // it like this for now.
|
|
|
+ InMemoryClient memory_client;
|
|
|
const Name qname;
|
|
|
const RRClass qclass;
|
|
|
const RRType qtype;
|
|
@@ -286,14 +290,14 @@ responseCheck(Message& response, const isc::dns::Rcode& rcode,
|
|
|
TEST_F(QueryTest, noZone) {
|
|
|
// There's no zone in the memory datasource. So the response should have
|
|
|
// REFUSED.
|
|
|
- MemoryDataSrc empty_memory_datasrc;
|
|
|
- Query nozone_query(empty_memory_datasrc, qname, qtype, response);
|
|
|
+ InMemoryClient empty_memory_client;
|
|
|
+ Query nozone_query(empty_memory_client, qname, qtype, response);
|
|
|
EXPECT_NO_THROW(nozone_query.process());
|
|
|
EXPECT_EQ(Rcode::REFUSED(), response.getRcode());
|
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, exactMatch) {
|
|
|
- Query query(memory_datasrc, qname, qtype, response);
|
|
|
+ Query query(memory_client, qname, qtype, response);
|
|
|
EXPECT_NO_THROW(query.process());
|
|
|
// find match rrset
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -303,7 +307,7 @@ TEST_F(QueryTest, exactMatch) {
|
|
|
TEST_F(QueryTest, exactAddrMatch) {
|
|
|
// find match rrset, omit additional data which has already been provided
|
|
|
// in the answer section from the additional.
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, Name("noglue.example.com"), qtype,
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, Name("noglue.example.com"), qtype,
|
|
|
response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 2,
|
|
@@ -315,7 +319,7 @@ TEST_F(QueryTest, exactAddrMatch) {
|
|
|
TEST_F(QueryTest, apexNSMatch) {
|
|
|
// find match rrset, omit authority data which has already been provided
|
|
|
// in the answer section from the authority section.
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, Name("example.com"), RRType::NS(),
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, Name("example.com"), RRType::NS(),
|
|
|
response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 3, 0, 3,
|
|
@@ -326,7 +330,7 @@ TEST_F(QueryTest, apexNSMatch) {
|
|
|
TEST_F(QueryTest, exactAnyMatch) {
|
|
|
// find match rrset, omit additional data which has already been provided
|
|
|
// in the answer section from the additional.
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, Name("noglue.example.com"),
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, Name("noglue.example.com"),
|
|
|
RRType::ANY(), response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 2,
|
|
@@ -339,18 +343,18 @@ TEST_F(QueryTest, exactAnyMatch) {
|
|
|
TEST_F(QueryTest, apexAnyMatch) {
|
|
|
// find match rrset, omit additional data which has already been provided
|
|
|
// in the answer section from the additional.
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, Name("example.com"),
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, Name("example.com"),
|
|
|
RRType::ANY(), response).process());
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 4, 0, 3,
|
|
|
"example.com. 3600 IN SOA . . 0 0 0 0 0\n"
|
|
|
"example.com. 3600 IN NS glue.delegation.example.com.\n"
|
|
|
"example.com. 3600 IN NS noglue.example.com.\n"
|
|
|
"example.com. 3600 IN NS example.net.\n",
|
|
|
- NULL, ns_addrs_txt, mock_zone->getOrigin());
|
|
|
+ NULL, ns_addrs_txt, mock_finder->getOrigin());
|
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, mxANYMatch) {
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, Name("mx.example.com"),
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, Name("mx.example.com"),
|
|
|
RRType::ANY(), response).process());
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 3, 3, 4,
|
|
|
mx_txt, zone_ns_txt,
|
|
@@ -358,17 +362,17 @@ TEST_F(QueryTest, mxANYMatch) {
|
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, glueANYMatch) {
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, Name("delegation.example.com"),
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, Name("delegation.example.com"),
|
|
|
RRType::ANY(), response).process());
|
|
|
responseCheck(response, Rcode::NOERROR(), 0, 0, 4, 3,
|
|
|
NULL, delegation_txt, ns_addrs_txt);
|
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, nodomainANY) {
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, Name("nxdomain.example.com"),
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, Name("nxdomain.example.com"),
|
|
|
RRType::ANY(), response).process());
|
|
|
responseCheck(response, Rcode::NXDOMAIN(), AA_FLAG, 0, 1, 0,
|
|
|
- NULL, soa_txt, NULL, mock_zone->getOrigin());
|
|
|
+ NULL, soa_txt, NULL, mock_finder->getOrigin());
|
|
|
}
|
|
|
|
|
|
// This tests that when we need to look up Zone's apex NS records for
|
|
@@ -376,15 +380,15 @@ TEST_F(QueryTest, nodomainANY) {
|
|
|
// throw in that case.
|
|
|
TEST_F(QueryTest, noApexNS) {
|
|
|
// Disable apex NS record
|
|
|
- mock_zone->setApexNSFlag(false);
|
|
|
+ mock_finder->setApexNSFlag(false);
|
|
|
|
|
|
- EXPECT_THROW(Query(memory_datasrc, Name("noglue.example.com"), qtype,
|
|
|
+ EXPECT_THROW(Query(memory_client, Name("noglue.example.com"), qtype,
|
|
|
response).process(), Query::NoApexNS);
|
|
|
// We don't look into the response, as it threw
|
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, delegation) {
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, Name("delegation.example.com"),
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, Name("delegation.example.com"),
|
|
|
qtype, response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), 0, 0, 4, 3,
|
|
@@ -392,18 +396,18 @@ TEST_F(QueryTest, delegation) {
|
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, nxdomain) {
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, Name("nxdomain.example.com"), qtype,
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, Name("nxdomain.example.com"), qtype,
|
|
|
response).process());
|
|
|
responseCheck(response, Rcode::NXDOMAIN(), AA_FLAG, 0, 1, 0,
|
|
|
- NULL, soa_txt, NULL, mock_zone->getOrigin());
|
|
|
+ NULL, soa_txt, NULL, mock_finder->getOrigin());
|
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, nxrrset) {
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, Name("www.example.com"),
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, Name("www.example.com"),
|
|
|
RRType::TXT(), response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 0, 1, 0,
|
|
|
- NULL, soa_txt, NULL, mock_zone->getOrigin());
|
|
|
+ NULL, soa_txt, NULL, mock_finder->getOrigin());
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -412,22 +416,22 @@ TEST_F(QueryTest, nxrrset) {
|
|
|
*/
|
|
|
TEST_F(QueryTest, noSOA) {
|
|
|
// disable zone's SOA RR.
|
|
|
- mock_zone->setSOAFlag(false);
|
|
|
+ mock_finder->setSOAFlag(false);
|
|
|
|
|
|
// The NX Domain
|
|
|
- EXPECT_THROW(Query(memory_datasrc, Name("nxdomain.example.com"),
|
|
|
+ EXPECT_THROW(Query(memory_client, Name("nxdomain.example.com"),
|
|
|
qtype, response).process(), Query::NoSOA);
|
|
|
// Of course, we don't look into the response, as it throwed
|
|
|
|
|
|
// NXRRSET
|
|
|
- EXPECT_THROW(Query(memory_datasrc, Name("nxrrset.example.com"),
|
|
|
+ EXPECT_THROW(Query(memory_client, Name("nxrrset.example.com"),
|
|
|
qtype, response).process(), Query::NoSOA);
|
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, noMatchZone) {
|
|
|
// there's a zone in the memory datasource but it doesn't match the qname.
|
|
|
// should result in REFUSED.
|
|
|
- Query(memory_datasrc, Name("example.org"), qtype, response).process();
|
|
|
+ Query(memory_client, Name("example.org"), qtype, response).process();
|
|
|
EXPECT_EQ(Rcode::REFUSED(), response.getRcode());
|
|
|
}
|
|
|
|
|
@@ -438,7 +442,7 @@ TEST_F(QueryTest, noMatchZone) {
|
|
|
* A record, other to unknown out of zone one.
|
|
|
*/
|
|
|
TEST_F(QueryTest, MX) {
|
|
|
- Query(memory_datasrc, Name("mx.example.com"), RRType::MX(),
|
|
|
+ Query(memory_client, Name("mx.example.com"), RRType::MX(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 3, 3, 4,
|
|
@@ -452,7 +456,7 @@ TEST_F(QueryTest, MX) {
|
|
|
* This should not trigger the additional processing for the exchange.
|
|
|
*/
|
|
|
TEST_F(QueryTest, MXAlias) {
|
|
|
- Query(memory_datasrc, Name("cnamemx.example.com"), RRType::MX(),
|
|
|
+ Query(memory_client, Name("cnamemx.example.com"), RRType::MX(),
|
|
|
response).process();
|
|
|
|
|
|
// there shouldn't be no additional RRs for the exchanges (we have 3
|
|
@@ -472,7 +476,7 @@ TEST_F(QueryTest, MXAlias) {
|
|
|
* returned.
|
|
|
*/
|
|
|
TEST_F(QueryTest, CNAME) {
|
|
|
- Query(memory_datasrc, Name("cname.example.com"), RRType::A(),
|
|
|
+ Query(memory_client, Name("cname.example.com"), RRType::A(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
@@ -482,7 +486,7 @@ TEST_F(QueryTest, CNAME) {
|
|
|
TEST_F(QueryTest, explicitCNAME) {
|
|
|
// same owner name as the CNAME test but explicitly query for CNAME RR.
|
|
|
// expect the same response as we don't provide a full chain yet.
|
|
|
- Query(memory_datasrc, Name("cname.example.com"), RRType::CNAME(),
|
|
|
+ Query(memory_client, Name("cname.example.com"), RRType::CNAME(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -494,7 +498,7 @@ TEST_F(QueryTest, CNAME_NX_RRSET) {
|
|
|
// note: with chaining, what should be expected is not trivial:
|
|
|
// BIND 9 returns the CNAME in answer and SOA in authority, no additional.
|
|
|
// NSD returns the CNAME, NS in authority, A/AAAA for NS in additional.
|
|
|
- Query(memory_datasrc, Name("cname.example.com"), RRType::TXT(),
|
|
|
+ Query(memory_client, Name("cname.example.com"), RRType::TXT(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
@@ -503,7 +507,7 @@ TEST_F(QueryTest, CNAME_NX_RRSET) {
|
|
|
|
|
|
TEST_F(QueryTest, explicitCNAME_NX_RRSET) {
|
|
|
// same owner name as the NXRRSET test but explicitly query for CNAME RR.
|
|
|
- Query(memory_datasrc, Name("cname.example.com"), RRType::CNAME(),
|
|
|
+ Query(memory_client, Name("cname.example.com"), RRType::CNAME(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -517,7 +521,7 @@ TEST_F(QueryTest, CNAME_NX_DOMAIN) {
|
|
|
// RCODE being NXDOMAIN.
|
|
|
// NSD returns the CNAME, NS in authority, A/AAAA for NS in additional,
|
|
|
// RCODE being NOERROR.
|
|
|
- Query(memory_datasrc, Name("cnamenxdom.example.com"), RRType::A(),
|
|
|
+ Query(memory_client, Name("cnamenxdom.example.com"), RRType::A(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
@@ -526,7 +530,7 @@ TEST_F(QueryTest, CNAME_NX_DOMAIN) {
|
|
|
|
|
|
TEST_F(QueryTest, explicitCNAME_NX_DOMAIN) {
|
|
|
// same owner name as the NXDOMAIN test but explicitly query for CNAME RR.
|
|
|
- Query(memory_datasrc, Name("cnamenxdom.example.com"), RRType::CNAME(),
|
|
|
+ Query(memory_client, Name("cnamenxdom.example.com"), RRType::CNAME(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -542,7 +546,7 @@ TEST_F(QueryTest, CNAME_OUT) {
|
|
|
* Then the same test should be done with .org included there and
|
|
|
* see what it does (depends on what we want to do)
|
|
|
*/
|
|
|
- Query(memory_datasrc, Name("cnameout.example.com"), RRType::A(),
|
|
|
+ Query(memory_client, Name("cnameout.example.com"), RRType::A(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
@@ -551,7 +555,7 @@ TEST_F(QueryTest, CNAME_OUT) {
|
|
|
|
|
|
TEST_F(QueryTest, explicitCNAME_OUT) {
|
|
|
// same owner name as the OUT test but explicitly query for CNAME RR.
|
|
|
- Query(memory_datasrc, Name("cnameout.example.com"), RRType::CNAME(),
|
|
|
+ Query(memory_client, Name("cnameout.example.com"), RRType::CNAME(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -567,7 +571,7 @@ TEST_F(QueryTest, explicitCNAME_OUT) {
|
|
|
* pointing to NXRRSET and NXDOMAIN cases (similarly as with CNAME).
|
|
|
*/
|
|
|
TEST_F(QueryTest, DNAME) {
|
|
|
- Query(memory_datasrc, Name("www.dname.example.com"), RRType::A(),
|
|
|
+ Query(memory_client, Name("www.dname.example.com"), RRType::A(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 0, 0,
|
|
@@ -583,7 +587,7 @@ TEST_F(QueryTest, DNAME) {
|
|
|
* DNAME.
|
|
|
*/
|
|
|
TEST_F(QueryTest, DNAME_ANY) {
|
|
|
- Query(memory_datasrc, Name("www.dname.example.com"), RRType::ANY(),
|
|
|
+ Query(memory_client, Name("www.dname.example.com"), RRType::ANY(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 0, 0,
|
|
@@ -592,7 +596,7 @@ TEST_F(QueryTest, DNAME_ANY) {
|
|
|
|
|
|
// Test when we ask for DNAME explicitly, it does no synthetizing.
|
|
|
TEST_F(QueryTest, explicitDNAME) {
|
|
|
- Query(memory_datasrc, Name("dname.example.com"), RRType::DNAME(),
|
|
|
+ Query(memory_client, Name("dname.example.com"), RRType::DNAME(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -604,7 +608,7 @@ TEST_F(QueryTest, explicitDNAME) {
|
|
|
* the CNAME, it should return the RRset.
|
|
|
*/
|
|
|
TEST_F(QueryTest, DNAME_A) {
|
|
|
- Query(memory_datasrc, Name("dname.example.com"), RRType::A(),
|
|
|
+ Query(memory_client, Name("dname.example.com"), RRType::A(),
|
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -616,11 +620,11 @@ TEST_F(QueryTest, DNAME_A) {
|
|
|
* It should not synthetize the CNAME.
|
|
|
*/
|
|
|
TEST_F(QueryTest, DNAME_NX_RRSET) {
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, Name("dname.example.com"),
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, Name("dname.example.com"),
|
|
|
RRType::TXT(), response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 0, 1, 0,
|
|
|
- NULL, soa_txt, NULL, mock_zone->getOrigin());
|
|
|
+ NULL, soa_txt, NULL, mock_finder->getOrigin());
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -636,7 +640,7 @@ TEST_F(QueryTest, LongDNAME) {
|
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
|
"dname.example.com.");
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, longname, RRType::A(),
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, longname, RRType::A(),
|
|
|
response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::YXDOMAIN(), AA_FLAG, 1, 0, 0,
|
|
@@ -655,7 +659,7 @@ TEST_F(QueryTest, MaxLenDNAME) {
|
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
|
"dname.example.com.");
|
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, longname, RRType::A(),
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, longname, RRType::A(),
|
|
|
response).process());
|
|
|
|
|
|
// Check the answer is OK
|