BIND 10 master, updated. 44bd4bc6dc7df56905071933a542e00e91f84837 Merge branch 'master' of git+ssh://git.bind10.isc.org/var/bind10/git/bind10
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Aug 16 14:30:54 UTC 2011
The branch, master has been updated
via 44bd4bc6dc7df56905071933a542e00e91f84837 (commit)
via 006d0fab3f44ec9caa2b23da3866bbbd841cd5d3 (commit)
via 68da925f226966a2760a193e9f9a3cdbdfcfacec (commit)
via 09e8c50958a1fca313c2be427c2991c39798f90f (commit)
via 0fe4f0151ae7a994aaf305e7985d4ba9f992e482 (commit)
via b06a3e2ba1febb9e34458c5106f8d1629a191d5f (commit)
via 4cbf309be8a302afe3bc041da11c24b593464157 (commit)
via b3bcd825cfb9c19a62a7db4d12717e85aca0b1e8 (commit)
via 3f5a0900a568436b011fc14b628b71bb130ae5f7 (commit)
via 3ce7b09732207eac03998fa5e267672760e475c9 (commit)
via b9f87e9332895be6915e2f2960a2e921375e8e7f (commit)
via 978ae99ac4aa211ba4ba960f56bb6cdd84b648ae (commit)
via e021b84f7fc20b3e3927093ed87e9c873d33a443 (commit)
via 62432e71ef943744fd4ca9ce216da1b0a7250573 (commit)
via 005c77dfe53b54cef92ce51d91f615eb9c2769c4 (commit)
via ce3bc8504d765ecc9b453398efb18662bd4f277a (commit)
via 94fc6d8d303053c47064c9408947cd49a8e11975 (commit)
via c5cf3cc081042fec0e2baea7cdf7f22a8a84664a (commit)
via adcbbb141bdb09a6fd999f3369e15c2881f843ba (commit)
via 80014655d76e758868e8e1ed36472be9a606eb2a (commit)
from d1b580f1780e5ebdbbf6fe8655cc923fbd5c02de (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 44bd4bc6dc7df56905071933a542e00e91f84837
Merge: 006d0fab3f44ec9caa2b23da3866bbbd841cd5d3 d1b580f1780e5ebdbbf6fe8655cc923fbd5c02de
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Aug 16 16:30:51 2011 +0200
Merge branch 'master' of git+ssh://git.bind10.isc.org/var/bind10/git/bind10
commit 006d0fab3f44ec9caa2b23da3866bbbd841cd5d3
Merge: 68da925f226966a2760a193e9f9a3cdbdfcfacec b06a3e2ba1febb9e34458c5106f8d1629a191d5f
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Aug 16 16:24:30 2011 +0200
Merge branch #1074
Conflicts:
src/lib/datasrc/database.cc
src/lib/datasrc/tests/database_unittest.cc
commit 68da925f226966a2760a193e9f9a3cdbdfcfacec
Merge: 09e8c50958a1fca313c2be427c2991c39798f90f 0fe4f0151ae7a994aaf305e7985d4ba9f992e482
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Aug 16 16:08:25 2011 +0200
Merge branch #1063
commit 09e8c50958a1fca313c2be427c2991c39798f90f
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Aug 16 16:07:10 2011 +0200
Fix lexical cast
(missing boost::)
Reviewed on jabber.
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/database.cc | 255 ++++++++++-----
src/lib/datasrc/database.h | 53 +++-
src/lib/datasrc/datasrc_messages.mes | 14 +
src/lib/datasrc/tests/database_unittest.cc | 482 +++++++++++++++++++++-------
src/lib/dns/rdata/generic/afsdb_18.cc | 4 +-
5 files changed, 611 insertions(+), 197 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/database.cc b/src/lib/datasrc/database.cc
index d2202cd..04fb44c 100644
--- a/src/lib/datasrc/database.cc
+++ b/src/lib/datasrc/database.cc
@@ -49,16 +49,18 @@ DatabaseClient::findZone(const Name& name) const {
if (zone.first) {
return (FindResult(result::SUCCESS,
ZoneFinderPtr(new Finder(database_,
- zone.second))));
+ zone.second, name))));
}
- // Than super domains
+ // Then super domains
// Start from 1, as 0 is covered above
for (size_t i(1); i < name.getLabelCount(); ++i) {
- zone = database_->getZone(name.split(i));
+ isc::dns::Name superdomain(name.split(i));
+ zone = database_->getZone(superdomain);
if (zone.first) {
return (FindResult(result::PARTIALMATCH,
ZoneFinderPtr(new Finder(database_,
- zone.second))));
+ zone.second,
+ superdomain))));
}
}
// No, really nothing
@@ -66,9 +68,11 @@ DatabaseClient::findZone(const Name& name) const {
}
DatabaseClient::Finder::Finder(boost::shared_ptr<DatabaseAccessor>
- database, int zone_id) :
+ database, int zone_id,
+ const isc::dns::Name& origin) :
database_(database),
- zone_id_(zone_id)
+ zone_id_(zone_id),
+ origin_(origin)
{ }
namespace {
@@ -162,96 +166,187 @@ private:
};
}
+std::pair<bool, isc::dns::RRsetPtr>
+DatabaseClient::Finder::getRRset(const isc::dns::Name& name,
+ const isc::dns::RRType* type,
+ bool want_cname, bool want_dname,
+ bool want_ns)
+{
+ RRsigStore sig_store;
+ database_->searchForRecords(zone_id_, name.toText());
+ bool records_found = false;
+ isc::dns::RRsetPtr result_rrset;
+
+ std::string columns[DatabaseAccessor::COLUMN_COUNT];
+ while (database_->getNextRecord(columns, DatabaseAccessor::COLUMN_COUNT)) {
+ if (!records_found) {
+ records_found = true;
+ }
+
+ try {
+ const isc::dns::RRType cur_type(columns[DatabaseAccessor::
+ TYPE_COLUMN]);
+ const isc::dns::RRTTL cur_ttl(columns[DatabaseAccessor::
+ TTL_COLUMN]);
+ // Ths sigtype column was an optimization for finding the
+ // relevant RRSIG RRs for a lookup. Currently this column is
+ // not used in this revised datasource implementation. We
+ // should either start using it again, or remove it from use
+ // completely (i.e. also remove it from the schema and the
+ // backend implementation).
+ // Note that because we don't use it now, we also won't notice
+ // it if the value is wrong (i.e. if the sigtype column
+ // contains an rrtype that is different from the actual value
+ // of the 'type covered' field in the RRSIG Rdata).
+ //cur_sigtype(columns[SIGTYPE_COLUMN]);
+
+ // Check for delegations before checking for the right type.
+ // This is needed to properly delegate request for the NS
+ // record itself.
+ //
+ // This happens with NS only, CNAME must be alone and DNAME
+ // is not checked in the exact queried domain.
+ if (want_ns && cur_type == isc::dns::RRType::NS()) {
+ if (result_rrset &&
+ result_rrset->getType() != isc::dns::RRType::NS()) {
+ isc_throw(DataSourceError, "NS found together with data"
+ " in non-apex domain " + name.toText());
+ }
+ addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl,
+ columns[DatabaseAccessor::RDATA_COLUMN],
+ *database_);
+ } else if (type != NULL && cur_type == *type) {
+ if (result_rrset &&
+ result_rrset->getType() == isc::dns::RRType::CNAME()) {
+ isc_throw(DataSourceError, "CNAME found but it is not "
+ "the only record for " + name.toText());
+ } else if (result_rrset && want_ns &&
+ result_rrset->getType() == isc::dns::RRType::NS()) {
+ isc_throw(DataSourceError, "NS found together with data"
+ " in non-apex domain " + name.toText());
+ }
+ addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl,
+ columns[DatabaseAccessor::RDATA_COLUMN],
+ *database_);
+ } else if (want_cname && cur_type == isc::dns::RRType::CNAME()) {
+ // There should be no other data, so result_rrset should
+ // be empty.
+ if (result_rrset) {
+ isc_throw(DataSourceError, "CNAME found but it is not "
+ "the only record for " + name.toText());
+ }
+ addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl,
+ columns[DatabaseAccessor::RDATA_COLUMN],
+ *database_);
+ } else if (want_dname && cur_type == isc::dns::RRType::DNAME()) {
+ // There should be max one RR of DNAME present
+ if (result_rrset &&
+ result_rrset->getType() == isc::dns::RRType::DNAME()) {
+ isc_throw(DataSourceError, "DNAME with multiple RRs in " +
+ name.toText());
+ }
+ addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl,
+ columns[DatabaseAccessor::RDATA_COLUMN],
+ *database_);
+ } else if (cur_type == isc::dns::RRType::RRSIG()) {
+ // If we get signatures before we get the actual data, we
+ // can't know which ones to keep and which to drop...
+ // So we keep a separate store of any signature that may be
+ // relevant and add them to the final RRset when we are
+ // done.
+ // A possible optimization here is to not store them for
+ // types we are certain we don't need
+ sig_store.addSig(isc::dns::rdata::createRdata(cur_type,
+ getClass(), columns[DatabaseAccessor::RDATA_COLUMN]));
+ }
+ } catch (const isc::dns::InvalidRRType& irt) {
+ isc_throw(DataSourceError, "Invalid RRType in database for " <<
+ name << ": " << columns[DatabaseAccessor::
+ TYPE_COLUMN]);
+ } catch (const isc::dns::InvalidRRTTL& irttl) {
+ isc_throw(DataSourceError, "Invalid TTL in database for " <<
+ name << ": " << columns[DatabaseAccessor::
+ TTL_COLUMN]);
+ } catch (const isc::dns::rdata::InvalidRdataText& ird) {
+ isc_throw(DataSourceError, "Invalid rdata in database for " <<
+ name << ": " << columns[DatabaseAccessor::
+ RDATA_COLUMN]);
+ }
+ }
+ if (result_rrset) {
+ sig_store.appendSignatures(result_rrset);
+ }
+ return (std::pair<bool, isc::dns::RRsetPtr>(records_found, result_rrset));
+}
+
ZoneFinder::FindResult
DatabaseClient::Finder::find(const isc::dns::Name& name,
const isc::dns::RRType& type,
isc::dns::RRsetList*,
- const FindOptions)
+ const FindOptions options)
{
// This variable is used to determine the difference between
// NXDOMAIN and NXRRSET
bool records_found = false;
+ bool glue_ok(options & FIND_GLUE_OK);
isc::dns::RRsetPtr result_rrset;
ZoneFinder::Result result_status = SUCCESS;
- RRsigStore sig_store;
+ std::pair<bool, isc::dns::RRsetPtr> found;
logger.debug(DBG_TRACE_DETAILED, DATASRC_DATABASE_FIND_RECORDS)
.arg(database_->getDBName()).arg(name).arg(type);
try {
- database_->searchForRecords(zone_id_, name.toText());
+ // First, do we have any kind of delegation (NS/DNAME) here?
+ Name origin(getOrigin());
+ size_t origin_label_count(origin.getLabelCount());
+ size_t current_label_count(name.getLabelCount());
+ // This is how many labels we remove to get origin
+ size_t remove_labels(current_label_count - origin_label_count);
- std::string columns[DatabaseAccessor::COLUMN_COUNT];
- while (database_->getNextRecord(columns,
- DatabaseAccessor::COLUMN_COUNT)) {
- if (!records_found) {
- records_found = true;
+ // Now go trough all superdomains from origin down
+ for (int i(remove_labels); i > 0; --i) {
+ Name superdomain(name.split(i));
+ // Look if there's NS or DNAME (but ignore the NS in origin)
+ found = getRRset(superdomain, NULL, false, true,
+ i != remove_labels && !glue_ok);
+ if (found.second) {
+ // We found something redirecting somewhere else
+ // (it can be only NS or DNAME here)
+ result_rrset = found.second;
+ if (result_rrset->getType() == isc::dns::RRType::NS()) {
+ LOG_DEBUG(logger, DBG_TRACE_DETAILED,
+ DATASRC_DATABASE_FOUND_DELEGATION).
+ arg(database_->getDBName()).arg(superdomain);
+ result_status = DELEGATION;
+ } else {
+ LOG_DEBUG(logger, DBG_TRACE_DETAILED,
+ DATASRC_DATABASE_FOUND_DNAME).
+ arg(database_->getDBName()).arg(superdomain);
+ result_status = DNAME;
+ }
+ // Don't search more
+ break;
}
+ }
- try {
- const isc::dns::RRType cur_type(columns[DatabaseAccessor::
- TYPE_COLUMN]);
- const isc::dns::RRTTL cur_ttl(columns[DatabaseAccessor::
- TTL_COLUMN]);
- // Ths sigtype column was an optimization for finding the
- // relevant RRSIG RRs for a lookup. Currently this column is
- // not used in this revised datasource implementation. We
- // should either start using it again, or remove it from use
- // completely (i.e. also remove it from the schema and the
- // backend implementation).
- // Note that because we don't use it now, we also won't notice
- // it if the value is wrong (i.e. if the sigtype column
- // contains an rrtype that is different from the actual value
- // of the 'type covered' field in the RRSIG Rdata).
- //cur_sigtype(columns[SIGTYPE_COLUMN]);
-
- if (cur_type == type) {
- if (result_rrset &&
- result_rrset->getType() == isc::dns::RRType::CNAME()) {
- isc_throw(DataSourceError, "CNAME found but it is not "
- "the only record for " + name.toText());
- }
- addOrCreate(result_rrset, name, getClass(), cur_type,
- cur_ttl, columns[DatabaseAccessor::
- RDATA_COLUMN],
- *database_);
- } else if (cur_type == isc::dns::RRType::CNAME()) {
- // There should be no other data, so result_rrset should
- // be empty.
- if (result_rrset) {
- isc_throw(DataSourceError, "CNAME found but it is not "
- "the only record for " + name.toText());
- }
- addOrCreate(result_rrset, name, getClass(), cur_type,
- cur_ttl, columns[DatabaseAccessor::
- RDATA_COLUMN],
- *database_);
- result_status = CNAME;
- } else if (cur_type == isc::dns::RRType::RRSIG()) {
- // If we get signatures before we get the actual data, we
- // can't know which ones to keep and which to drop...
- // So we keep a separate store of any signature that may be
- // relevant and add them to the final RRset when we are
- // done.
- // A possible optimization here is to not store them for
- // types we are certain we don't need
- sig_store.addSig(isc::dns::rdata::createRdata(cur_type,
- getClass(),
- columns[DatabaseAccessor::
- RDATA_COLUMN]));
- }
- } catch (const isc::dns::InvalidRRType& irt) {
- isc_throw(DataSourceError, "Invalid RRType in database for " <<
- name << ": " << columns[DatabaseAccessor::
- TYPE_COLUMN]);
- } catch (const isc::dns::InvalidRRTTL& irttl) {
- isc_throw(DataSourceError, "Invalid TTL in database for " <<
- name << ": " << columns[DatabaseAccessor::
- TTL_COLUMN]);
- } catch (const isc::dns::rdata::InvalidRdataText& ird) {
- isc_throw(DataSourceError, "Invalid rdata in database for " <<
- name << ": " << columns[DatabaseAccessor::
- RDATA_COLUMN]);
+ if (!result_rrset) { // Only if we didn't find a redirect already
+ // Try getting the final result and extract it
+ // It is special if there's a CNAME or NS, DNAME is ignored here
+ // And we don't consider the NS in origin
+ found = getRRset(name, &type, true, false,
+ name != origin && !glue_ok);
+ records_found = found.first;
+ result_rrset = found.second;
+ if (result_rrset && name != origin && !glue_ok &&
+ result_rrset->getType() == isc::dns::RRType::NS()) {
+ LOG_DEBUG(logger, DBG_TRACE_DETAILED,
+ DATASRC_DATABASE_FOUND_DELEGATION_EXACT).
+ arg(database_->getDBName()).arg(name);
+ result_status = DELEGATION;
+ } else if (result_rrset && type != isc::dns::RRType::CNAME() &&
+ result_rrset->getType() == isc::dns::RRType::CNAME()) {
+ result_status = CNAME;
}
}
} catch (const DataSourceError& dse) {
@@ -288,7 +383,6 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
result_status = NXDOMAIN;
}
} else {
- sig_store.appendSignatures(result_rrset);
logger.debug(DBG_TRACE_DETAILED,
DATASRC_DATABASE_FOUND_RRSET)
.arg(database_->getDBName()).arg(*result_rrset);
@@ -298,8 +392,7 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
Name
DatabaseClient::Finder::getOrigin() const {
- // TODO Implement
- return (Name("."));
+ return (origin_);
}
isc::dns::RRClass
diff --git a/src/lib/datasrc/database.h b/src/lib/datasrc/database.h
index 5253e60..95782ef 100644
--- a/src/lib/datasrc/database.h
+++ b/src/lib/datasrc/database.h
@@ -17,6 +17,8 @@
#include <datasrc/client.h>
+#include <dns/name.h>
+
namespace isc {
namespace datasrc {
@@ -218,8 +220,12 @@ public:
* \param zone_id The zone ID which was returned from
* DatabaseAccessor::getZone and which will be passed to further
* calls to the database.
+ * \param origin The name of the origin of this zone. It could query
+ * it from database, but as the DatabaseClient just searched for
+ * the zone using the name, it should have it.
*/
- Finder(boost::shared_ptr<DatabaseAccessor> database, int zone_id);
+ Finder(boost::shared_ptr<DatabaseAccessor> database, int zone_id,
+ const isc::dns::Name& origin);
// The following three methods are just implementations of inherited
// ZoneFinder's pure virtual methods.
virtual isc::dns::Name getOrigin() const;
@@ -262,7 +268,8 @@ public:
* \param name The name to find
* \param type The RRType to find
* \param target Unused at this moment
- * \param options Unused at this moment
+ * \param options Options about how to search.
+ * See ZoneFinder::FindOptions.
*/
virtual FindResult find(const isc::dns::Name& name,
const isc::dns::RRType& type,
@@ -290,6 +297,48 @@ public:
private:
boost::shared_ptr<DatabaseAccessor> database_;
const int zone_id_;
+ const isc::dns::Name origin_;
+ /**
+ * \brief Searches database for an RRset
+ *
+ * This method scans RRs of single domain specified by name and finds
+ * RRset with given type or any of redirection RRsets that are
+ * requested.
+ *
+ * This function is used internally by find(), because this part is
+ * called multiple times with slightly different parameters.
+ *
+ * \param name Which domain name should be scanned.
+ * \param type The RRType which is requested. This can be NULL, in
+ * which case the method will look for the redirections only.
+ * \param want_cname If this is true, CNAME redirection may be returned
+ * instead of the RRset with given type. If there's CNAME and
+ * something else or the CNAME has multiple RRs, it throws
+ * DataSourceError.
+ * \param want_dname If this is true, DNAME redirection may be returned
+ * instead. This is with type = NULL only and is not checked in
+ * other circumstances. If the DNAME has multiple RRs, it throws
+ * DataSourceError.
+ * \param want_ns This allows redirection by NS to be returned. If
+ * any other data is met as well, DataSourceError is thrown.
+ * \note It may happen that some of the above error conditions are not
+ * detected in some circumstances. The goal here is not to validate
+ * the domain in DB, but to avoid bad behaviour resulting from
+ * broken data.
+ * \return First part of the result tells if the domain contains any
+ * RRs. This can be used to decide between NXDOMAIN and NXRRSET.
+ * The second part is the RRset found (if any) with any relevant
+ * signatures attached to it.
+ * \todo This interface doesn't look very elegant. Any better idea
+ * would be nice.
+ */
+ std::pair<bool, isc::dns::RRsetPtr> getRRset(const isc::dns::Name&
+ name,
+ const isc::dns::RRType*
+ type,
+ bool want_cname,
+ bool want_dname,
+ bool want_ns);
};
/**
* \brief Find a zone in the database
diff --git a/src/lib/datasrc/datasrc_messages.mes b/src/lib/datasrc/datasrc_messages.mes
index 6af4fe6..190adbe 100644
--- a/src/lib/datasrc/datasrc_messages.mes
+++ b/src/lib/datasrc/datasrc_messages.mes
@@ -90,6 +90,20 @@ most likely points to a logic error in the code, and can be considered a bug.
The current search is aborted. Specific information about the exception is
printed in this error message.
+% DATASRC_DATABASE_FOUND_DELEGATION Found delegation at %2 in %1
+When searching for a domain, the program met a delegation to a different zone
+at the given domain name. It will return that one instead.
+
+% DATASRC_DATABASE_FOUND_DELEGATION_EXACT Found delegation at %2 (exact match) in %1
+The program found the domain requested, but it is a delegation point to a
+different zone, therefore it is not authoritative for this domain name.
+It will return the NS record instead.
+
+% DATASRC_DATABASE_FOUND_DNAME Found DNAME at %2 in %1
+When searching for a domain, the program met a DNAME redirection to a different
+place in the domain space at the given domain name. It will return that one
+instead.
+
% DATASRC_DATABASE_FOUND_NXDOMAIN search in datasource %1 resulted in NXDOMAIN for %2/%3/%4
The data returned by the database backend did not contain any data for the given
domain name, class and type.
diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc
index fcfcefe..8fad14b 100644
--- a/src/lib/datasrc/tests/database_unittest.cc
+++ b/src/lib/datasrc/tests/database_unittest.cc
@@ -263,6 +263,46 @@ private:
addRecord("A", "3600", "", "192.0.2.1");
addRecord("RRSIG", "3600", "TXT", "A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
addCurName("badsigtype.example.org.");
+
+ // Data for testing delegation (with NS and DNAME)
+ addRecord("NS", "3600", "", "ns.example.com.");
+ addRecord("NS", "3600", "", "ns.delegation.example.org.");
+ addRecord("RRSIG", "3600", "", "NS 5 3 3600 20000101000000 "
+ "20000201000000 12345 example.org. FAKEFAKEFAKE");
+ addCurName("delegation.example.org.");
+ addRecord("A", "3600", "", "192.0.2.1");
+ addCurName("ns.delegation.example.org.");
+ addRecord("A", "3600", "", "192.0.2.1");
+ addCurName("deep.below.delegation.example.org.");
+
+ addRecord("A", "3600", "", "192.0.2.1");
+ addRecord("DNAME", "3600", "", "dname.example.com.");
+ addRecord("RRSIG", "3600", "", "DNAME 5 3 3600 20000101000000 "
+ "20000201000000 12345 example.org. FAKEFAKEFAKE");
+ addCurName("dname.example.org.");
+ addRecord("A", "3600", "", "192.0.2.1");
+ addCurName("below.dname.example.org.");
+
+ // Broken NS
+ addRecord("A", "3600", "", "192.0.2.1");
+ addRecord("NS", "3600", "", "ns.example.com.");
+ addCurName("brokenns1.example.org.");
+ addRecord("NS", "3600", "", "ns.example.com.");
+ addRecord("A", "3600", "", "192.0.2.1");
+ addCurName("brokenns2.example.org.");
+
+ // Now double DNAME, to test failure mode
+ addRecord("DNAME", "3600", "", "dname1.example.com.");
+ addRecord("DNAME", "3600", "", "dname2.example.com.");
+ addCurName("baddname.example.org.");
+
+ // Put some data into apex (including NS) so we can check our NS
+ // doesn't break anything
+ addRecord("NS", "3600", "", "ns.example.com.");
+ addRecord("A", "3600", "", "192.0.2.1");
+ addRecord("RRSIG", "3600", "", "NS 5 3 3600 20000101000000 "
+ "20000201000000 12345 example.org. FAKEFAKEFAKE");
+ addCurName("example.org.");
}
};
@@ -298,6 +338,21 @@ public:
EXPECT_EQ(42, finder->zone_id());
EXPECT_EQ(current_database_, &finder->database());
}
+
+ shared_ptr<DatabaseClient::Finder> getFinder() {
+ DataSourceClient::FindResult zone(
+ client_->findZone(Name("example.org")));
+ EXPECT_EQ(result::SUCCESS, zone.code);
+ shared_ptr<DatabaseClient::Finder> finder(
+ dynamic_pointer_cast<DatabaseClient::Finder>(zone.zone_finder));
+ EXPECT_EQ(42, finder->zone_id());
+ EXPECT_FALSE(current_database_->searchRunning());
+
+ return (finder);
+ }
+
+ std::vector<std::string> expected_rdatas_;
+ std::vector<std::string> expected_sig_rdatas_;
};
TEST_F(DatabaseClientTest, zoneNotFound) {
@@ -353,19 +408,24 @@ doFindTest(shared_ptr<DatabaseClient::Finder> finder,
const isc::dns::RRTTL expected_ttl,
ZoneFinder::Result expected_result,
const std::vector<std::string>& expected_rdatas,
- const std::vector<std::string>& expected_sig_rdatas)
+ const std::vector<std::string>& expected_sig_rdatas,
+ const isc::dns::Name& expected_name = isc::dns::Name::ROOT_NAME(),
+ const ZoneFinder::FindOptions options = ZoneFinder::FIND_DEFAULT)
{
+ SCOPED_TRACE("doFindTest " + name.toText() + " " + type.toText());
ZoneFinder::FindResult result =
- finder->find(name, type, NULL, ZoneFinder::FIND_DEFAULT);
+ finder->find(name, type, NULL, options);
ASSERT_EQ(expected_result, result.code) << name << " " << type;
if (expected_rdatas.size() > 0) {
- checkRRset(result.rrset, name, finder->getClass(),
- expected_type, expected_ttl, expected_rdatas);
+ checkRRset(result.rrset, expected_name != Name(".") ? expected_name :
+ name, finder->getClass(), expected_type, expected_ttl,
+ expected_rdatas);
if (expected_sig_rdatas.size() > 0) {
- checkRRset(result.rrset->getRRsig(), name,
- finder->getClass(), isc::dns::RRType::RRSIG(),
- expected_ttl, expected_sig_rdatas);
+ checkRRset(result.rrset->getRRsig(), expected_name != Name(".") ?
+ expected_name : name, finder->getClass(),
+ isc::dns::RRType::RRSIG(), expected_ttl,
+ expected_sig_rdatas);
} else {
EXPECT_EQ(isc::dns::RRsetPtr(), result.rrset->getRRsig());
}
@@ -376,227 +436,220 @@ doFindTest(shared_ptr<DatabaseClient::Finder> finder,
} // end anonymous namespace
TEST_F(DatabaseClientTest, find) {
- DataSourceClient::FindResult zone(client_->findZone(Name("example.org")));
- ASSERT_EQ(result::SUCCESS, zone.code);
- shared_ptr<DatabaseClient::Finder> finder(
- dynamic_pointer_cast<DatabaseClient::Finder>(zone.zone_finder));
- EXPECT_EQ(42, finder->zone_id());
- EXPECT_FALSE(current_database_->searchRunning());
- std::vector<std::string> expected_rdatas;
- std::vector<std::string> expected_sig_rdatas;
+ shared_ptr<DatabaseClient::Finder> finder(getFinder());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("192.0.2.1");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
doFindTest(finder, isc::dns::Name("www.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::A(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("192.0.2.1");
- expected_rdatas.push_back("192.0.2.2");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
+ expected_rdatas_.push_back("192.0.2.2");
doFindTest(finder, isc::dns::Name("www2.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::A(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("2001:db8::1");
- expected_rdatas.push_back("2001:db8::2");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("2001:db8::1");
+ expected_rdatas_.push_back("2001:db8::2");
doFindTest(finder, isc::dns::Name("www.example.org."),
isc::dns::RRType::AAAA(), isc::dns::RRType::AAAA(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
doFindTest(finder, isc::dns::Name("www.example.org."),
isc::dns::RRType::TXT(), isc::dns::RRType::TXT(),
isc::dns::RRTTL(3600),
ZoneFinder::NXRRSET,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("www.example.org.");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("www.example.org.");
doFindTest(finder, isc::dns::Name("cname.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::CNAME(),
isc::dns::RRTTL(3600),
ZoneFinder::CNAME,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("www.example.org.");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("www.example.org.");
doFindTest(finder, isc::dns::Name("cname.example.org."),
isc::dns::RRType::CNAME(), isc::dns::RRType::CNAME(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
doFindTest(finder, isc::dns::Name("doesnotexist.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::A(),
isc::dns::RRTTL(3600),
ZoneFinder::NXDOMAIN,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("192.0.2.1");
- expected_sig_rdatas.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
- expected_sig_rdatas.push_back("A 5 3 3600 20000101000000 20000201000000 12346 example.org. FAKEFAKEFAKE");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
+ expected_sig_rdatas_.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
+ expected_sig_rdatas_.push_back("A 5 3 3600 20000101000000 20000201000000 12346 example.org. FAKEFAKEFAKE");
doFindTest(finder, isc::dns::Name("signed1.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::A(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("2001:db8::1");
- expected_rdatas.push_back("2001:db8::2");
- expected_sig_rdatas.push_back("AAAA 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("2001:db8::1");
+ expected_rdatas_.push_back("2001:db8::2");
+ expected_sig_rdatas_.push_back("AAAA 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
doFindTest(finder, isc::dns::Name("signed1.example.org."),
isc::dns::RRType::AAAA(), isc::dns::RRType::AAAA(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
doFindTest(finder, isc::dns::Name("signed1.example.org."),
isc::dns::RRType::TXT(), isc::dns::RRType::TXT(),
isc::dns::RRTTL(3600),
ZoneFinder::NXRRSET,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("www.example.org.");
- expected_sig_rdatas.push_back("CNAME 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("www.example.org.");
+ expected_sig_rdatas_.push_back("CNAME 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
doFindTest(finder, isc::dns::Name("signedcname1.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::CNAME(),
isc::dns::RRTTL(3600),
ZoneFinder::CNAME,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("192.0.2.1");
- expected_sig_rdatas.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
- expected_sig_rdatas.push_back("A 5 3 3600 20000101000000 20000201000000 12346 example.org. FAKEFAKEFAKE");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
+ expected_sig_rdatas_.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
+ expected_sig_rdatas_.push_back("A 5 3 3600 20000101000000 20000201000000 12346 example.org. FAKEFAKEFAKE");
doFindTest(finder, isc::dns::Name("signed2.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::A(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("2001:db8::2");
- expected_rdatas.push_back("2001:db8::1");
- expected_sig_rdatas.push_back("AAAA 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("2001:db8::2");
+ expected_rdatas_.push_back("2001:db8::1");
+ expected_sig_rdatas_.push_back("AAAA 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
doFindTest(finder, isc::dns::Name("signed2.example.org."),
isc::dns::RRType::AAAA(), isc::dns::RRType::AAAA(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
doFindTest(finder, isc::dns::Name("signed2.example.org."),
isc::dns::RRType::TXT(), isc::dns::RRType::TXT(),
isc::dns::RRTTL(3600),
ZoneFinder::NXRRSET,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("www.example.org.");
- expected_sig_rdatas.push_back("CNAME 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("www.example.org.");
+ expected_sig_rdatas_.push_back("CNAME 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
doFindTest(finder, isc::dns::Name("signedcname2.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::CNAME(),
isc::dns::RRTTL(3600),
ZoneFinder::CNAME,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("192.0.2.1");
- expected_sig_rdatas.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
+ expected_sig_rdatas_.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
doFindTest(finder, isc::dns::Name("acnamesig1.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::A(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("192.0.2.1");
- expected_sig_rdatas.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
+ expected_sig_rdatas_.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
doFindTest(finder, isc::dns::Name("acnamesig2.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::A(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("192.0.2.1");
- expected_sig_rdatas.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
+ expected_sig_rdatas_.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
doFindTest(finder, isc::dns::Name("acnamesig3.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::A(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("192.0.2.1");
- expected_rdatas.push_back("192.0.2.2");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
+ expected_rdatas_.push_back("192.0.2.2");
doFindTest(finder, isc::dns::Name("ttldiff1.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::A(),
isc::dns::RRTTL(360),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("192.0.2.1");
- expected_rdatas.push_back("192.0.2.2");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
+ expected_rdatas_.push_back("192.0.2.2");
doFindTest(finder, isc::dns::Name("ttldiff2.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::A(),
isc::dns::RRTTL(360),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
EXPECT_FALSE(current_database_->searchRunning());
@@ -672,16 +725,219 @@ TEST_F(DatabaseClientTest, find) {
// This RRSIG has the wrong sigtype field, which should be
// an error if we decide to keep using that field
// Right now the field is ignored, so it does not error
- expected_rdatas.clear();
- expected_sig_rdatas.clear();
- expected_rdatas.push_back("192.0.2.1");
- expected_sig_rdatas.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
+ expected_sig_rdatas_.push_back("A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE");
doFindTest(finder, isc::dns::Name("badsigtype.example.org."),
isc::dns::RRType::A(), isc::dns::RRType::A(),
isc::dns::RRTTL(3600),
ZoneFinder::SUCCESS,
- expected_rdatas, expected_sig_rdatas);
+ expected_rdatas_, expected_sig_rdatas_);
+ EXPECT_FALSE(current_database_->searchRunning());
+}
+
+TEST_F(DatabaseClientTest, findDelegation) {
+ shared_ptr<DatabaseClient::Finder> finder(getFinder());
+
+ // The apex should not be considered delegation point and we can access
+ // data
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
+ doFindTest(finder, isc::dns::Name("example.org."),
+ isc::dns::RRType::A(), isc::dns::RRType::A(),
+ isc::dns::RRTTL(3600), ZoneFinder::SUCCESS, expected_rdatas_,
+ expected_sig_rdatas_);
+ EXPECT_FALSE(current_database_->searchRunning());
+
+ expected_rdatas_.clear();
+ expected_rdatas_.push_back("ns.example.com.");
+ expected_sig_rdatas_.push_back("NS 5 3 3600 20000101000000 20000201000000 "
+ "12345 example.org. FAKEFAKEFAKE");
+ doFindTest(finder, isc::dns::Name("example.org."),
+ isc::dns::RRType::NS(), isc::dns::RRType::NS(),
+ isc::dns::RRTTL(3600), ZoneFinder::SUCCESS, expected_rdatas_,
+ expected_sig_rdatas_);
+ EXPECT_FALSE(current_database_->searchRunning());
+
+ // Check when we ask for something below delegation point, we get the NS
+ // (Both when the RRset there exists and doesn't)
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ expected_rdatas_.push_back("ns.example.com.");
+ expected_rdatas_.push_back("ns.delegation.example.org.");
+ expected_sig_rdatas_.push_back("NS 5 3 3600 20000101000000 20000201000000 "
+ "12345 example.org. FAKEFAKEFAKE");
+ doFindTest(finder, isc::dns::Name("ns.delegation.example.org."),
+ isc::dns::RRType::A(), isc::dns::RRType::NS(),
+ isc::dns::RRTTL(3600), ZoneFinder::DELEGATION, expected_rdatas_,
+ expected_sig_rdatas_,
+ isc::dns::Name("delegation.example.org."));
+ EXPECT_FALSE(current_database_->searchRunning());
+ doFindTest(finder, isc::dns::Name("ns.delegation.example.org."),
+ isc::dns::RRType::AAAA(), isc::dns::RRType::NS(),
+ isc::dns::RRTTL(3600), ZoneFinder::DELEGATION, expected_rdatas_,
+ expected_sig_rdatas_,
+ isc::dns::Name("delegation.example.org."));
+ doFindTest(finder, isc::dns::Name("deep.below.delegation.example.org."),
+ isc::dns::RRType::AAAA(), isc::dns::RRType::NS(),
+ isc::dns::RRTTL(3600), ZoneFinder::DELEGATION, expected_rdatas_,
+ expected_sig_rdatas_,
+ isc::dns::Name("delegation.example.org."));
+ EXPECT_FALSE(current_database_->searchRunning());
+
+ // Even when we check directly at the delegation point, we should get
+ // the NS
+ doFindTest(finder, isc::dns::Name("delegation.example.org."),
+ isc::dns::RRType::AAAA(), isc::dns::RRType::NS(),
+ isc::dns::RRTTL(3600), ZoneFinder::DELEGATION, expected_rdatas_,
+ expected_sig_rdatas_);
+ EXPECT_FALSE(current_database_->searchRunning());
+
+ // And when we ask direcly for the NS, we should still get delegation
+ doFindTest(finder, isc::dns::Name("delegation.example.org."),
+ isc::dns::RRType::NS(), isc::dns::RRType::NS(),
+ isc::dns::RRTTL(3600), ZoneFinder::DELEGATION, expected_rdatas_,
+ expected_sig_rdatas_);
+ EXPECT_FALSE(current_database_->searchRunning());
+
+ // Now test delegation. If it is below the delegation point, we should get
+ // the DNAME (the one with data under DNAME is invalid zone, but we test
+ // the behaviour anyway just to make sure)
+ expected_rdatas_.clear();
+ expected_rdatas_.push_back("dname.example.com.");
+ expected_sig_rdatas_.clear();
+ expected_sig_rdatas_.push_back("DNAME 5 3 3600 20000101000000 "
+ "20000201000000 12345 example.org. "
+ "FAKEFAKEFAKE");
+ doFindTest(finder, isc::dns::Name("below.dname.example.org."),
+ isc::dns::RRType::A(), isc::dns::RRType::DNAME(),
+ isc::dns::RRTTL(3600), ZoneFinder::DNAME, expected_rdatas_,
+ expected_sig_rdatas_, isc::dns::Name("dname.example.org."));
+ EXPECT_FALSE(current_database_->searchRunning());
+ doFindTest(finder, isc::dns::Name("below.dname.example.org."),
+ isc::dns::RRType::AAAA(), isc::dns::RRType::DNAME(),
+ isc::dns::RRTTL(3600), ZoneFinder::DNAME, expected_rdatas_,
+ expected_sig_rdatas_, isc::dns::Name("dname.example.org."));
+ EXPECT_FALSE(current_database_->searchRunning());
+ doFindTest(finder, isc::dns::Name("really.deep.below.dname.example.org."),
+ isc::dns::RRType::AAAA(), isc::dns::RRType::DNAME(),
+ isc::dns::RRTTL(3600), ZoneFinder::DNAME, expected_rdatas_,
+ expected_sig_rdatas_, isc::dns::Name("dname.example.org."));
+ EXPECT_FALSE(current_database_->searchRunning());
+
+ // Asking direcly for DNAME should give SUCCESS
+ doFindTest(finder, isc::dns::Name("dname.example.org."),
+ isc::dns::RRType::DNAME(), isc::dns::RRType::DNAME(),
+ isc::dns::RRTTL(3600), ZoneFinder::SUCCESS, expected_rdatas_,
+ expected_sig_rdatas_);
+
+ // But we don't delegate at DNAME point
+ expected_rdatas_.clear();
+ expected_rdatas_.push_back("192.0.2.1");
+ expected_sig_rdatas_.clear();
+ doFindTest(finder, isc::dns::Name("dname.example.org."),
+ isc::dns::RRType::A(), isc::dns::RRType::A(),
+ isc::dns::RRTTL(3600), ZoneFinder::SUCCESS, expected_rdatas_,
+ expected_sig_rdatas_);
+ EXPECT_FALSE(current_database_->searchRunning());
+ expected_rdatas_.clear();
+ doFindTest(finder, isc::dns::Name("dname.example.org."),
+ isc::dns::RRType::AAAA(), isc::dns::RRType::AAAA(),
+ isc::dns::RRTTL(3600), ZoneFinder::NXRRSET, expected_rdatas_,
+ expected_sig_rdatas_);
+ EXPECT_FALSE(current_database_->searchRunning());
+
+ // This is broken dname, it contains two targets
+ EXPECT_THROW(finder->find(isc::dns::Name("below.baddname.example.org."),
+ isc::dns::RRType::A(), NULL,
+ ZoneFinder::FIND_DEFAULT),
+ DataSourceError);
+ EXPECT_FALSE(current_database_->searchRunning());
+
+ // Broken NS - it lives together with something else
+ EXPECT_FALSE(current_database_->searchRunning());
+ EXPECT_THROW(finder->find(isc::dns::Name("brokenns1.example.org."),
+ isc::dns::RRType::A(), NULL,
+ ZoneFinder::FIND_DEFAULT),
+ DataSourceError);
+ EXPECT_FALSE(current_database_->searchRunning());
+ EXPECT_THROW(finder->find(isc::dns::Name("brokenns2.example.org."),
+ isc::dns::RRType::A(), NULL,
+ ZoneFinder::FIND_DEFAULT),
+ DataSourceError);
EXPECT_FALSE(current_database_->searchRunning());
}
+// Glue-OK mode. Just go trough NS delegations down (but not trough
+// DNAME) and pretend it is not there.
+TEST_F(DatabaseClientTest, glueOK) {
+ shared_ptr<DatabaseClient::Finder> finder(getFinder());
+
+ expected_rdatas_.clear();
+ expected_sig_rdatas_.clear();
+ doFindTest(finder, isc::dns::Name("ns.delegation.example.org."),
+ isc::dns::RRType::AAAA(), isc::dns::RRType::AAAA(),
+ isc::dns::RRTTL(3600), ZoneFinder::NXRRSET,
+ expected_rdatas_, expected_sig_rdatas_,
+ isc::dns::Name("ns.delegation.example.org."),
+ ZoneFinder::FIND_GLUE_OK);
+ doFindTest(finder, isc::dns::Name("nothere.delegation.example.org."),
+ isc::dns::RRType::AAAA(), isc::dns::RRType::AAAA(),
+ isc::dns::RRTTL(3600), ZoneFinder::NXDOMAIN,
+ expected_rdatas_, expected_sig_rdatas_,
+ isc::dns::Name("nothere.delegation.example.org."),
+ ZoneFinder::FIND_GLUE_OK);
+ expected_rdatas_.push_back("192.0.2.1");
+ doFindTest(finder, isc::dns::Name("ns.delegation.example.org."),
+ isc::dns::RRType::A(), isc::dns::RRType::A(),
+ isc::dns::RRTTL(3600), ZoneFinder::SUCCESS,
+ expected_rdatas_, expected_sig_rdatas_,
+ isc::dns::Name("ns.delegation.example.org."),
+ ZoneFinder::FIND_GLUE_OK);
+ expected_rdatas_.clear();
+ expected_rdatas_.push_back("ns.example.com.");
+ expected_rdatas_.push_back("ns.delegation.example.org.");
+ expected_sig_rdatas_.clear();
+ expected_sig_rdatas_.push_back("NS 5 3 3600 20000101000000 "
+ "20000201000000 12345 example.org. "
+ "FAKEFAKEFAKE");
+ // When we request the NS, it should be SUCCESS, not DELEGATION
+ // (different in GLUE_OK)
+ doFindTest(finder, isc::dns::Name("delegation.example.org."),
+ isc::dns::RRType::NS(), isc::dns::RRType::NS(),
+ isc::dns::RRTTL(3600), ZoneFinder::SUCCESS,
+ expected_rdatas_, expected_sig_rdatas_,
+ isc::dns::Name("delegation.example.org."),
+ ZoneFinder::FIND_GLUE_OK);
+ expected_rdatas_.clear();
+ expected_rdatas_.push_back("dname.example.com.");
+ expected_sig_rdatas_.clear();
+ expected_sig_rdatas_.push_back("DNAME 5 3 3600 20000101000000 "
+ "20000201000000 12345 example.org. "
+ "FAKEFAKEFAKE");
+ doFindTest(finder, isc::dns::Name("below.dname.example.org."),
+ isc::dns::RRType::A(), isc::dns::RRType::DNAME(),
+ isc::dns::RRTTL(3600), ZoneFinder::DNAME, expected_rdatas_,
+ expected_sig_rdatas_, isc::dns::Name("dname.example.org."),
+ ZoneFinder::FIND_GLUE_OK);
+ EXPECT_FALSE(current_database_->searchRunning());
+ doFindTest(finder, isc::dns::Name("below.dname.example.org."),
+ isc::dns::RRType::AAAA(), isc::dns::RRType::DNAME(),
+ isc::dns::RRTTL(3600), ZoneFinder::DNAME, expected_rdatas_,
+ expected_sig_rdatas_, isc::dns::Name("dname.example.org."),
+ ZoneFinder::FIND_GLUE_OK);
+ EXPECT_FALSE(current_database_->searchRunning());
+}
+
+TEST_F(DatabaseClientTest, getOrigin) {
+ DataSourceClient::FindResult zone(client_->findZone(Name("example.org")));
+ ASSERT_EQ(result::SUCCESS, zone.code);
+ shared_ptr<DatabaseClient::Finder> finder(
+ dynamic_pointer_cast<DatabaseClient::Finder>(zone.zone_finder));
+ EXPECT_EQ(42, finder->zone_id());
+ EXPECT_EQ(isc::dns::Name("example.org"), finder->getOrigin());
+}
+
}
diff --git a/src/lib/dns/rdata/generic/afsdb_18.cc b/src/lib/dns/rdata/generic/afsdb_18.cc
index 0aca23f..dd7fa5f 100644
--- a/src/lib/dns/rdata/generic/afsdb_18.cc
+++ b/src/lib/dns/rdata/generic/afsdb_18.cc
@@ -23,6 +23,8 @@
#include <dns/rdata.h>
#include <dns/rdataclass.h>
+#include <boost/lexical_cast.hpp>
+
using namespace std;
using namespace isc::util::str;
@@ -109,7 +111,7 @@ AFSDB::operator=(const AFSDB& source) {
/// \return A \c string object that represents the \c AFSDB object.
string
AFSDB::toText() const {
- return (lexical_cast<string>(subtype_) + " " + server_.toText());
+ return (boost::lexical_cast<string>(subtype_) + " " + server_.toText());
}
/// \brief Render the \c AFSDB in the wire format without name compression.
More information about the bind10-changes
mailing list