|
@@ -93,9 +93,9 @@ const char* const other_zone_rrs =
|
|
"mx.delegation.example.com. 3600 IN A 192.0.2.100\n";
|
|
"mx.delegation.example.com. 3600 IN A 192.0.2.100\n";
|
|
|
|
|
|
// This is a mock Zone class for testing.
|
|
// 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
|
|
// 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.
|
|
// behavior.
|
|
// For simplicity, most names are assumed to be "in zone"; there's only
|
|
// For simplicity, most names are assumed to be "in zone"; there's only
|
|
// one zone cut at the point of name "delegation.example.com".
|
|
// one zone cut at the point of name "delegation.example.com".
|
|
@@ -103,15 +103,16 @@ const char* const other_zone_rrs =
|
|
// will result in DNAME.
|
|
// will result in DNAME.
|
|
// This mock zone doesn't handle empty non terminal nodes (if we need to test
|
|
// This mock zone doesn't handle empty non terminal nodes (if we need to test
|
|
// such cases find() should have specialized code for it).
|
|
// such cases find() should have specialized code for it).
|
|
-class MockZone : public Zone {
|
|
|
|
|
|
+class MockZoneFinder : public ZoneFinder {
|
|
public:
|
|
public:
|
|
- MockZone() :
|
|
|
|
|
|
+ MockZoneFinder() :
|
|
origin_(Name("example.com")),
|
|
origin_(Name("example.com")),
|
|
delegation_name_("delegation.example.com"),
|
|
delegation_name_("delegation.example.com"),
|
|
dname_name_("dname.example.com"),
|
|
dname_name_("dname.example.com"),
|
|
has_SOA_(true),
|
|
has_SOA_(true),
|
|
has_apex_NS_(true),
|
|
has_apex_NS_(true),
|
|
- rrclass_(RRClass::IN())
|
|
|
|
|
|
+ rrclass_(RRClass::IN()),
|
|
|
|
+ include_rrsig_anyway_(false)
|
|
{
|
|
{
|
|
stringstream zone_stream;
|
|
stringstream zone_stream;
|
|
zone_stream << soa_txt << zone_ns_txt << ns_addrs_txt <<
|
|
zone_stream << soa_txt << zone_ns_txt << ns_addrs_txt <<
|
|
@@ -120,14 +121,14 @@ public:
|
|
other_zone_rrs;
|
|
other_zone_rrs;
|
|
|
|
|
|
masterLoad(zone_stream, origin_, rrclass_,
|
|
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_); }
|
|
|
|
|
|
+ virtual isc::dns::Name getOrigin() const { return (origin_); }
|
|
|
|
+ virtual isc::dns::RRClass getClass() const { return (rrclass_); }
|
|
virtual FindResult find(const isc::dns::Name& name,
|
|
virtual FindResult find(const isc::dns::Name& name,
|
|
const isc::dns::RRType& type,
|
|
const isc::dns::RRType& type,
|
|
RRsetList* target = NULL,
|
|
RRsetList* target = NULL,
|
|
- const FindOptions options = FIND_DEFAULT) const;
|
|
|
|
|
|
+ const FindOptions options = FIND_DEFAULT);
|
|
|
|
|
|
// If false is passed, it makes the zone broken as if it didn't have the
|
|
// If false is passed, it makes the zone broken as if it didn't have the
|
|
// SOA.
|
|
// SOA.
|
|
@@ -137,11 +138,18 @@ public:
|
|
// the apex NS.
|
|
// the apex NS.
|
|
void setApexNSFlag(bool on) { has_apex_NS_ = on; }
|
|
void setApexNSFlag(bool on) { has_apex_NS_ = on; }
|
|
|
|
|
|
|
|
+ // Turn this on if you want it to return RRSIGs regardless of FIND_GLUE_OK
|
|
|
|
+ void setIncludeRRSIGAnyway(bool on) { include_rrsig_anyway_ = on; }
|
|
|
|
+
|
|
|
|
+ Name findPreviousName(const Name&) const {
|
|
|
|
+ isc_throw(isc::NotImplemented, "Mock doesn't support previous name");
|
|
|
|
+ }
|
|
|
|
+
|
|
private:
|
|
private:
|
|
typedef map<RRType, ConstRRsetPtr> RRsetStore;
|
|
typedef map<RRType, ConstRRsetPtr> RRsetStore;
|
|
typedef map<Name, RRsetStore> Domains;
|
|
typedef map<Name, RRsetStore> Domains;
|
|
Domains domains_;
|
|
Domains domains_;
|
|
- void loadRRset(ConstRRsetPtr rrset) {
|
|
|
|
|
|
+ void loadRRset(RRsetPtr rrset) {
|
|
domains_[rrset->getName()][rrset->getType()] = rrset;
|
|
domains_[rrset->getName()][rrset->getType()] = rrset;
|
|
if (rrset->getName() == delegation_name_ &&
|
|
if (rrset->getName() == delegation_name_ &&
|
|
rrset->getType() == RRType::NS()) {
|
|
rrset->getType() == RRType::NS()) {
|
|
@@ -149,6 +157,26 @@ private:
|
|
} else if (rrset->getName() == dname_name_ &&
|
|
} else if (rrset->getName() == dname_name_ &&
|
|
rrset->getType() == RRType::DNAME()) {
|
|
rrset->getType() == RRType::DNAME()) {
|
|
dname_rrset_ = rrset;
|
|
dname_rrset_ = rrset;
|
|
|
|
+ // Add some signatures
|
|
|
|
+ } else if (rrset->getName() == Name("example.com.") &&
|
|
|
|
+ rrset->getType() == RRType::NS()) {
|
|
|
|
+ rrset->addRRsig(RdataPtr(new generic::RRSIG("NS 5 3 3600 "
|
|
|
|
+ "20000101000000 "
|
|
|
|
+ "20000201000000 "
|
|
|
|
+ "12345 example.com. "
|
|
|
|
+ "FAKEFAKEFAKE")));
|
|
|
|
+ } else if (rrset->getType() == RRType::A()) {
|
|
|
|
+ rrset->addRRsig(RdataPtr(new generic::RRSIG("A 5 3 3600 "
|
|
|
|
+ "20000101000000 "
|
|
|
|
+ "20000201000000 "
|
|
|
|
+ "12345 example.com. "
|
|
|
|
+ "FAKEFAKEFAKE")));
|
|
|
|
+ } else if (rrset->getType() == RRType::AAAA()) {
|
|
|
|
+ rrset->addRRsig(RdataPtr(new generic::RRSIG("AAAA 5 3 3600 "
|
|
|
|
+ "20000101000000 "
|
|
|
|
+ "20000201000000 "
|
|
|
|
+ "12345 example.com. "
|
|
|
|
+ "FAKEFAKEFAKE")));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -161,11 +189,12 @@ private:
|
|
ConstRRsetPtr delegation_rrset_;
|
|
ConstRRsetPtr delegation_rrset_;
|
|
ConstRRsetPtr dname_rrset_;
|
|
ConstRRsetPtr dname_rrset_;
|
|
const RRClass rrclass_;
|
|
const RRClass rrclass_;
|
|
|
|
+ bool include_rrsig_anyway_;
|
|
};
|
|
};
|
|
|
|
|
|
-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)
|
|
{
|
|
{
|
|
// Emulating a broken zone: mandatory apex RRs are missing if specifically
|
|
// Emulating a broken zone: mandatory apex RRs are missing if specifically
|
|
// configured so (which are rare cases).
|
|
// configured so (which are rare cases).
|
|
@@ -195,7 +224,26 @@ MockZone::find(const Name& name, const RRType& type,
|
|
RRsetStore::const_iterator found_rrset =
|
|
RRsetStore::const_iterator found_rrset =
|
|
found_domain->second.find(type);
|
|
found_domain->second.find(type);
|
|
if (found_rrset != found_domain->second.end()) {
|
|
if (found_rrset != found_domain->second.end()) {
|
|
- return (FindResult(SUCCESS, found_rrset->second));
|
|
|
|
|
|
+ ConstRRsetPtr rrset;
|
|
|
|
+ // Strip whatever signature there is in case DNSSEC is not required
|
|
|
|
+ // Just to make sure the Query asks for it when it is needed
|
|
|
|
+ if (options & ZoneFinder::FIND_DNSSEC ||
|
|
|
|
+ include_rrsig_anyway_ ||
|
|
|
|
+ !found_rrset->second->getRRsig()) {
|
|
|
|
+ rrset = found_rrset->second;
|
|
|
|
+ } else {
|
|
|
|
+ RRsetPtr noconst(new RRset(found_rrset->second->getName(),
|
|
|
|
+ found_rrset->second->getClass(),
|
|
|
|
+ found_rrset->second->getType(),
|
|
|
|
+ found_rrset->second->getTTL()));
|
|
|
|
+ for (RdataIteratorPtr
|
|
|
|
+ i(found_rrset->second->getRdataIterator());
|
|
|
|
+ !i->isLast(); i->next()) {
|
|
|
|
+ noconst->addRdata(i->getCurrent());
|
|
|
|
+ }
|
|
|
|
+ rrset = noconst;
|
|
|
|
+ }
|
|
|
|
+ return (FindResult(SUCCESS, rrset));
|
|
}
|
|
}
|
|
|
|
|
|
// If not found but we have a target, fill it with all RRsets here
|
|
// If not found but we have a target, fill it with all RRsets here
|
|
@@ -233,11 +281,15 @@ protected:
|
|
response.setRcode(Rcode::NOERROR());
|
|
response.setRcode(Rcode::NOERROR());
|
|
response.setOpcode(Opcode::QUERY());
|
|
response.setOpcode(Opcode::QUERY());
|
|
// create and add a matching zone.
|
|
// 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 Name qname;
|
|
const RRClass qclass;
|
|
const RRClass qclass;
|
|
const RRType qtype;
|
|
const RRType qtype;
|
|
@@ -286,24 +338,76 @@ responseCheck(Message& response, const isc::dns::Rcode& rcode,
|
|
TEST_F(QueryTest, noZone) {
|
|
TEST_F(QueryTest, noZone) {
|
|
// There's no zone in the memory datasource. So the response should have
|
|
// There's no zone in the memory datasource. So the response should have
|
|
// REFUSED.
|
|
// 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_NO_THROW(nozone_query.process());
|
|
EXPECT_EQ(Rcode::REFUSED(), response.getRcode());
|
|
EXPECT_EQ(Rcode::REFUSED(), response.getRcode());
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, exactMatch) {
|
|
TEST_F(QueryTest, exactMatch) {
|
|
- Query query(memory_datasrc, qname, qtype, response);
|
|
|
|
|
|
+ Query query(memory_client, qname, qtype, response);
|
|
EXPECT_NO_THROW(query.process());
|
|
EXPECT_NO_THROW(query.process());
|
|
// find match rrset
|
|
// find match rrset
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
www_a_txt, zone_ns_txt, ns_addrs_txt);
|
|
www_a_txt, zone_ns_txt, ns_addrs_txt);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+TEST_F(QueryTest, exactMatchIgnoreSIG) {
|
|
|
|
+ // Check that we do not include the RRSIG when not requested even when
|
|
|
|
+ // we receive it from the data source.
|
|
|
|
+ mock_finder->setIncludeRRSIGAnyway(true);
|
|
|
|
+ Query query(memory_client, qname, qtype, response);
|
|
|
|
+ EXPECT_NO_THROW(query.process());
|
|
|
|
+ // find match rrset
|
|
|
|
+ responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
|
|
+ www_a_txt, zone_ns_txt, ns_addrs_txt);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TEST_F(QueryTest, dnssecPositive) {
|
|
|
|
+ // Just like exactMatch, but the signatures should be included as well
|
|
|
|
+ Query query(memory_client, qname, qtype, response, true);
|
|
|
|
+ EXPECT_NO_THROW(query.process());
|
|
|
|
+ // find match rrset
|
|
|
|
+ // We can't let responseCheck to check the additional section as well,
|
|
|
|
+ // it gets confused by the two RRs for glue.delegation.../RRSIG due
|
|
|
|
+ // to it's design and fixing it would be hard. Therefore we simply
|
|
|
|
+ // check manually this one time.
|
|
|
|
+ responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 4, 6,
|
|
|
|
+ (www_a_txt + std::string("www.example.com. 3600 IN RRSIG "
|
|
|
|
+ "A 5 3 3600 20000101000000 "
|
|
|
|
+ "20000201000000 12345 example.com. "
|
|
|
|
+ "FAKEFAKEFAKE\n")).c_str(),
|
|
|
|
+ (zone_ns_txt + std::string("example.com. 3600 IN RRSIG NS 5 "
|
|
|
|
+ "3 3600 20000101000000 "
|
|
|
|
+ "20000201000000 12345 "
|
|
|
|
+ "example.com. FAKEFAKEFAKE\n")).
|
|
|
|
+ c_str(), NULL);
|
|
|
|
+ RRsetIterator iterator(response.beginSection(Message::SECTION_ADDITIONAL));
|
|
|
|
+ const char* additional[] = {
|
|
|
|
+ "glue.delegation.example.com. 3600 IN A 192.0.2.153\n",
|
|
|
|
+ "glue.delegation.example.com. 3600 IN RRSIG A 5 3 3600 20000101000000 "
|
|
|
|
+ "20000201000000 12345 example.com. FAKEFAKEFAKE\n",
|
|
|
|
+ "glue.delegation.example.com. 3600 IN AAAA 2001:db8::53\n",
|
|
|
|
+ "glue.delegation.example.com. 3600 IN RRSIG AAAA 5 3 3600 "
|
|
|
|
+ "20000101000000 20000201000000 12345 example.com. FAKEFAKEFAKE\n",
|
|
|
|
+ "noglue.example.com. 3600 IN A 192.0.2.53\n",
|
|
|
|
+ "noglue.example.com. 3600 IN RRSIG A 5 3 3600 20000101000000 "
|
|
|
|
+ "20000201000000 12345 example.com. FAKEFAKEFAKE\n",
|
|
|
|
+ NULL
|
|
|
|
+ };
|
|
|
|
+ for (const char** rr(additional); *rr != NULL; ++ rr) {
|
|
|
|
+ ASSERT_FALSE(iterator ==
|
|
|
|
+ response.endSection(Message::SECTION_ADDITIONAL));
|
|
|
|
+ EXPECT_EQ(*rr, (*iterator)->toText());
|
|
|
|
+ iterator ++;
|
|
|
|
+ }
|
|
|
|
+ EXPECT_TRUE(iterator == response.endSection(Message::SECTION_ADDITIONAL));
|
|
|
|
+}
|
|
|
|
+
|
|
TEST_F(QueryTest, exactAddrMatch) {
|
|
TEST_F(QueryTest, exactAddrMatch) {
|
|
// find match rrset, omit additional data which has already been provided
|
|
// find match rrset, omit additional data which has already been provided
|
|
// in the answer section from the additional.
|
|
// 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());
|
|
response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 2,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 2,
|
|
@@ -315,7 +419,7 @@ TEST_F(QueryTest, exactAddrMatch) {
|
|
TEST_F(QueryTest, apexNSMatch) {
|
|
TEST_F(QueryTest, apexNSMatch) {
|
|
// find match rrset, omit authority data which has already been provided
|
|
// find match rrset, omit authority data which has already been provided
|
|
// in the answer section from the authority section.
|
|
// 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());
|
|
response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 3, 0, 3,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 3, 0, 3,
|
|
@@ -326,7 +430,7 @@ TEST_F(QueryTest, apexNSMatch) {
|
|
TEST_F(QueryTest, exactAnyMatch) {
|
|
TEST_F(QueryTest, exactAnyMatch) {
|
|
// find match rrset, omit additional data which has already been provided
|
|
// find match rrset, omit additional data which has already been provided
|
|
// in the answer section from the additional.
|
|
// 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());
|
|
RRType::ANY(), response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 2,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 2,
|
|
@@ -339,18 +443,18 @@ TEST_F(QueryTest, exactAnyMatch) {
|
|
TEST_F(QueryTest, apexAnyMatch) {
|
|
TEST_F(QueryTest, apexAnyMatch) {
|
|
// find match rrset, omit additional data which has already been provided
|
|
// find match rrset, omit additional data which has already been provided
|
|
// in the answer section from the additional.
|
|
// 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());
|
|
RRType::ANY(), response).process());
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 4, 0, 3,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 4, 0, 3,
|
|
"example.com. 3600 IN SOA . . 0 0 0 0 0\n"
|
|
"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 glue.delegation.example.com.\n"
|
|
"example.com. 3600 IN NS noglue.example.com.\n"
|
|
"example.com. 3600 IN NS noglue.example.com.\n"
|
|
"example.com. 3600 IN NS example.net.\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) {
|
|
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());
|
|
RRType::ANY(), response).process());
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 3, 3, 4,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 3, 3, 4,
|
|
mx_txt, zone_ns_txt,
|
|
mx_txt, zone_ns_txt,
|
|
@@ -358,17 +462,17 @@ TEST_F(QueryTest, mxANYMatch) {
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, glueANYMatch) {
|
|
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());
|
|
RRType::ANY(), response).process());
|
|
responseCheck(response, Rcode::NOERROR(), 0, 0, 4, 3,
|
|
responseCheck(response, Rcode::NOERROR(), 0, 0, 4, 3,
|
|
NULL, delegation_txt, ns_addrs_txt);
|
|
NULL, delegation_txt, ns_addrs_txt);
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, nodomainANY) {
|
|
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());
|
|
RRType::ANY(), response).process());
|
|
responseCheck(response, Rcode::NXDOMAIN(), AA_FLAG, 0, 1, 0,
|
|
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
|
|
// This tests that when we need to look up Zone's apex NS records for
|
|
@@ -376,15 +480,15 @@ TEST_F(QueryTest, nodomainANY) {
|
|
// throw in that case.
|
|
// throw in that case.
|
|
TEST_F(QueryTest, noApexNS) {
|
|
TEST_F(QueryTest, noApexNS) {
|
|
// Disable apex NS record
|
|
// 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);
|
|
response).process(), Query::NoApexNS);
|
|
// We don't look into the response, as it threw
|
|
// We don't look into the response, as it threw
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, delegation) {
|
|
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());
|
|
qtype, response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), 0, 0, 4, 3,
|
|
responseCheck(response, Rcode::NOERROR(), 0, 0, 4, 3,
|
|
@@ -392,18 +496,18 @@ TEST_F(QueryTest, delegation) {
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, nxdomain) {
|
|
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());
|
|
response).process());
|
|
responseCheck(response, Rcode::NXDOMAIN(), AA_FLAG, 0, 1, 0,
|
|
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) {
|
|
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());
|
|
RRType::TXT(), response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 0, 1, 0,
|
|
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 +516,22 @@ TEST_F(QueryTest, nxrrset) {
|
|
*/
|
|
*/
|
|
TEST_F(QueryTest, noSOA) {
|
|
TEST_F(QueryTest, noSOA) {
|
|
// disable zone's SOA RR.
|
|
// disable zone's SOA RR.
|
|
- mock_zone->setSOAFlag(false);
|
|
|
|
|
|
+ mock_finder->setSOAFlag(false);
|
|
|
|
|
|
// The NX Domain
|
|
// 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);
|
|
qtype, response).process(), Query::NoSOA);
|
|
// Of course, we don't look into the response, as it throwed
|
|
// Of course, we don't look into the response, as it throwed
|
|
|
|
|
|
// NXRRSET
|
|
// NXRRSET
|
|
- EXPECT_THROW(Query(memory_datasrc, Name("nxrrset.example.com"),
|
|
|
|
|
|
+ EXPECT_THROW(Query(memory_client, Name("nxrrset.example.com"),
|
|
qtype, response).process(), Query::NoSOA);
|
|
qtype, response).process(), Query::NoSOA);
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(QueryTest, noMatchZone) {
|
|
TEST_F(QueryTest, noMatchZone) {
|
|
// there's a zone in the memory datasource but it doesn't match the qname.
|
|
// there's a zone in the memory datasource but it doesn't match the qname.
|
|
// should result in REFUSED.
|
|
// 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());
|
|
EXPECT_EQ(Rcode::REFUSED(), response.getRcode());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -438,7 +542,7 @@ TEST_F(QueryTest, noMatchZone) {
|
|
* A record, other to unknown out of zone one.
|
|
* A record, other to unknown out of zone one.
|
|
*/
|
|
*/
|
|
TEST_F(QueryTest, MX) {
|
|
TEST_F(QueryTest, MX) {
|
|
- Query(memory_datasrc, Name("mx.example.com"), RRType::MX(),
|
|
|
|
|
|
+ Query(memory_client, Name("mx.example.com"), RRType::MX(),
|
|
response).process();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 3, 3, 4,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 3, 3, 4,
|
|
@@ -452,7 +556,7 @@ TEST_F(QueryTest, MX) {
|
|
* This should not trigger the additional processing for the exchange.
|
|
* This should not trigger the additional processing for the exchange.
|
|
*/
|
|
*/
|
|
TEST_F(QueryTest, MXAlias) {
|
|
TEST_F(QueryTest, MXAlias) {
|
|
- Query(memory_datasrc, Name("cnamemx.example.com"), RRType::MX(),
|
|
|
|
|
|
+ Query(memory_client, Name("cnamemx.example.com"), RRType::MX(),
|
|
response).process();
|
|
response).process();
|
|
|
|
|
|
// there shouldn't be no additional RRs for the exchanges (we have 3
|
|
// there shouldn't be no additional RRs for the exchanges (we have 3
|
|
@@ -472,7 +576,7 @@ TEST_F(QueryTest, MXAlias) {
|
|
* returned.
|
|
* returned.
|
|
*/
|
|
*/
|
|
TEST_F(QueryTest, CNAME) {
|
|
TEST_F(QueryTest, CNAME) {
|
|
- Query(memory_datasrc, Name("cname.example.com"), RRType::A(),
|
|
|
|
|
|
+ Query(memory_client, Name("cname.example.com"), RRType::A(),
|
|
response).process();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
@@ -482,7 +586,7 @@ TEST_F(QueryTest, CNAME) {
|
|
TEST_F(QueryTest, explicitCNAME) {
|
|
TEST_F(QueryTest, explicitCNAME) {
|
|
// same owner name as the CNAME test but explicitly query for CNAME RR.
|
|
// 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.
|
|
// 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();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -494,7 +598,7 @@ TEST_F(QueryTest, CNAME_NX_RRSET) {
|
|
// note: with chaining, what should be expected is not trivial:
|
|
// note: with chaining, what should be expected is not trivial:
|
|
// BIND 9 returns the CNAME in answer and SOA in authority, no additional.
|
|
// 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.
|
|
// 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();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
@@ -503,7 +607,7 @@ TEST_F(QueryTest, CNAME_NX_RRSET) {
|
|
|
|
|
|
TEST_F(QueryTest, explicitCNAME_NX_RRSET) {
|
|
TEST_F(QueryTest, explicitCNAME_NX_RRSET) {
|
|
// same owner name as the NXRRSET test but explicitly query for CNAME RR.
|
|
// 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();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -517,7 +621,7 @@ TEST_F(QueryTest, CNAME_NX_DOMAIN) {
|
|
// RCODE being NXDOMAIN.
|
|
// RCODE being NXDOMAIN.
|
|
// NSD returns the CNAME, NS in authority, A/AAAA for NS in additional,
|
|
// NSD returns the CNAME, NS in authority, A/AAAA for NS in additional,
|
|
// RCODE being NOERROR.
|
|
// RCODE being NOERROR.
|
|
- Query(memory_datasrc, Name("cnamenxdom.example.com"), RRType::A(),
|
|
|
|
|
|
+ Query(memory_client, Name("cnamenxdom.example.com"), RRType::A(),
|
|
response).process();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
@@ -526,7 +630,7 @@ TEST_F(QueryTest, CNAME_NX_DOMAIN) {
|
|
|
|
|
|
TEST_F(QueryTest, explicitCNAME_NX_DOMAIN) {
|
|
TEST_F(QueryTest, explicitCNAME_NX_DOMAIN) {
|
|
// same owner name as the NXDOMAIN test but explicitly query for CNAME RR.
|
|
// 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();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -542,7 +646,7 @@ TEST_F(QueryTest, CNAME_OUT) {
|
|
* Then the same test should be done with .org included there and
|
|
* Then the same test should be done with .org included there and
|
|
* see what it does (depends on what we want to do)
|
|
* 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();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
|
|
@@ -551,7 +655,7 @@ TEST_F(QueryTest, CNAME_OUT) {
|
|
|
|
|
|
TEST_F(QueryTest, explicitCNAME_OUT) {
|
|
TEST_F(QueryTest, explicitCNAME_OUT) {
|
|
// same owner name as the OUT test but explicitly query for CNAME RR.
|
|
// 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();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -567,7 +671,7 @@ TEST_F(QueryTest, explicitCNAME_OUT) {
|
|
* pointing to NXRRSET and NXDOMAIN cases (similarly as with CNAME).
|
|
* pointing to NXRRSET and NXDOMAIN cases (similarly as with CNAME).
|
|
*/
|
|
*/
|
|
TEST_F(QueryTest, DNAME) {
|
|
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();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 0, 0,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 0, 0,
|
|
@@ -583,7 +687,7 @@ TEST_F(QueryTest, DNAME) {
|
|
* DNAME.
|
|
* DNAME.
|
|
*/
|
|
*/
|
|
TEST_F(QueryTest, DNAME_ANY) {
|
|
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();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 0, 0,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 0, 0,
|
|
@@ -592,7 +696,7 @@ TEST_F(QueryTest, DNAME_ANY) {
|
|
|
|
|
|
// Test when we ask for DNAME explicitly, it does no synthetizing.
|
|
// Test when we ask for DNAME explicitly, it does no synthetizing.
|
|
TEST_F(QueryTest, explicitDNAME) {
|
|
TEST_F(QueryTest, explicitDNAME) {
|
|
- Query(memory_datasrc, Name("dname.example.com"), RRType::DNAME(),
|
|
|
|
|
|
+ Query(memory_client, Name("dname.example.com"), RRType::DNAME(),
|
|
response).process();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -604,7 +708,7 @@ TEST_F(QueryTest, explicitDNAME) {
|
|
* the CNAME, it should return the RRset.
|
|
* the CNAME, it should return the RRset.
|
|
*/
|
|
*/
|
|
TEST_F(QueryTest, DNAME_A) {
|
|
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();
|
|
response).process();
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
|
|
@@ -616,11 +720,11 @@ TEST_F(QueryTest, DNAME_A) {
|
|
* It should not synthetize the CNAME.
|
|
* It should not synthetize the CNAME.
|
|
*/
|
|
*/
|
|
TEST_F(QueryTest, DNAME_NX_RRSET) {
|
|
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());
|
|
RRType::TXT(), response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::NOERROR(), AA_FLAG, 0, 1, 0,
|
|
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 +740,7 @@ TEST_F(QueryTest, LongDNAME) {
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
"dname.example.com.");
|
|
"dname.example.com.");
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, longname, RRType::A(),
|
|
|
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, longname, RRType::A(),
|
|
response).process());
|
|
response).process());
|
|
|
|
|
|
responseCheck(response, Rcode::YXDOMAIN(), AA_FLAG, 1, 0, 0,
|
|
responseCheck(response, Rcode::YXDOMAIN(), AA_FLAG, 1, 0, 0,
|
|
@@ -655,7 +759,7 @@ TEST_F(QueryTest, MaxLenDNAME) {
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
|
|
"dname.example.com.");
|
|
"dname.example.com.");
|
|
- EXPECT_NO_THROW(Query(memory_datasrc, longname, RRType::A(),
|
|
|
|
|
|
+ EXPECT_NO_THROW(Query(memory_client, longname, RRType::A(),
|
|
response).process());
|
|
response).process());
|
|
|
|
|
|
// Check the answer is OK
|
|
// Check the answer is OK
|