From: JINMEI Tatuya Date: Wed, 23 Jan 2013 03:12:23 +0000 (-0800) Subject: [2309] implemented ZoneFinder::findAtOrigin for some basic cases. X-Git-Tag: bind10-1.0.0-rc-release~25^2~10^2~13^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c99567a4b1d2f5cfe345239c74b981efc8a4d585;p=thirdparty%2Fkea.git [2309] implemented ZoneFinder::findAtOrigin for some basic cases. --- diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc index 77a624d31a..1032411d4a 100644 --- a/src/lib/datasrc/tests/database_unittest.cc +++ b/src/lib/datasrc/tests/database_unittest.cc @@ -1804,6 +1804,30 @@ doFindTest(ZoneFinder& finder, expected_flags, expected_name, options); } +void +doFindAtOriginTest(ZoneFinder& finder, + const isc::dns::Name& origin, + const isc::dns::RRType& type, + const isc::dns::RRType& expected_type, + const isc::dns::RRTTL expected_ttl, + ZoneFinder::Result expected_result, + const std::vector& expected_rdatas, + const std::vector& expected_sig_rdatas, + ZoneFinder::FindResultFlags expected_flags = + ZoneFinder::RESULT_DEFAULT, + const isc::dns::Name& expected_name = + isc::dns::Name::ROOT_NAME(), + const ZoneFinder::FindOptions options = + ZoneFinder::FIND_DEFAULT) +{ + SCOPED_TRACE("doFindOriginTest " + origin.toText() + " " + type.toText()); + ConstZoneFinderContextPtr result = + finder.findAtOrigin(type, false, options); + findTestCommon(finder, origin, type, result, expected_type, expected_ttl, + expected_result, expected_rdatas, expected_sig_rdatas, + expected_flags, expected_name, options); +} + void doFindAllTestResult(ZoneFinder& finder, const isc::dns::Name& name, ZoneFinder::Result expected_result, @@ -2141,6 +2165,58 @@ TYPED_TEST(DatabaseClientTest, find) { this->expected_rdatas_, this->expected_sig_rdatas_); } +TYPED_TEST(DatabaseClientTest, findAtOrigin) { + ZoneFinderPtr finder(this->getFinder()); + + // Specified type of RR exists, no DNSSEC + this->expected_rdatas_.clear(); + this->expected_rdatas_.push_back("ns.example.com."); + doFindAtOriginTest(*finder, this->zname_, RRType::NS(), RRType::NS(), + this->rrttl_, ZoneFinder::SUCCESS, + this->expected_rdatas_, this->expected_sig_rdatas_); + + // Specified type of RR exists, with DNSSEC + this->expected_sig_rdatas_.push_back("NS 5 3 3600 20000101000000 " + "20000201000000 12345 example.org. " + "FAKEFAKEFAKE"); + doFindAtOriginTest(*finder, this->zname_, RRType::NS(), RRType::NS(), + this->rrttl_, ZoneFinder::SUCCESS, + this->expected_rdatas_, this->expected_sig_rdatas_, + ZoneFinder::RESULT_DEFAULT, this->zname_, + ZoneFinder::FIND_DNSSEC); + + // Specified type of RR doesn't exist, no DNSSEC + this->expected_rdatas_.clear(); + this->expected_sig_rdatas_.clear(); + doFindAtOriginTest(*finder, this->zname_, RRType::TXT(), this->qtype_, + this->rrttl_, ZoneFinder::NXRRSET, + this->expected_rdatas_, this->expected_sig_rdatas_); + + // Specified type of RR doesn't exist, with DNSSEC + this->expected_rdatas_.clear(); + this->expected_sig_rdatas_.clear(); + this->expected_rdatas_.push_back( + "acnamesig1.example.org. A NS RRSIG NSEC"); + this->expected_sig_rdatas_.push_back("NSEC 5 3 3600 20000101000000 " + "20000201000000 12345 example.org. " + "FAKEFAKEFAKE"); + doFindAtOriginTest(*finder, this->zname_, RRType::TXT(), RRType::NSEC(), + this->rrttl_, ZoneFinder::NXRRSET, + this->expected_rdatas_, this->expected_sig_rdatas_, + ZoneFinder::RESULT_NSEC_SIGNED, + this->zname_, ZoneFinder::FIND_DNSSEC); + + // Specified type of RR doesn't exist, with DNSSEC, enabling NSEC3 + this->current_accessor_->enableNSEC3(); + this->expected_rdatas_.clear(); + this->expected_sig_rdatas_.clear(); + doFindAtOriginTest(*finder, this->zname_, RRType::TXT(), RRType::TXT(), + this->rrttl_, ZoneFinder::NXRRSET, + this->expected_rdatas_, this->expected_sig_rdatas_, + ZoneFinder::RESULT_NSEC3_SIGNED, + this->zname_, ZoneFinder::FIND_DNSSEC); +} + TYPED_TEST(DatabaseClientTest, findOutOfZone) { // If the query name is out-of-zone it should result in an exception boost::shared_ptr finder(this->getFinder()); diff --git a/src/lib/datasrc/zone_finder.cc b/src/lib/datasrc/zone_finder.cc index b84edc2a4f..c0f0d41fc7 100644 --- a/src/lib/datasrc/zone_finder.cc +++ b/src/lib/datasrc/zone_finder.cc @@ -26,6 +26,13 @@ using namespace isc::dns::rdata; namespace isc { namespace datasrc { +ZoneFinderContextPtr +ZoneFinder::findAtOrigin(const dns::RRType& type, bool /*use_minmtu*/, + FindOptions options) +{ + return (find(getOrigin(), type, options)); +} + isc::dns::ConstRRsetPtr ZoneFinder::stripRRsigs(isc::dns::ConstRRsetPtr rp, const FindOptions options) { diff --git a/src/lib/datasrc/zone_finder.h b/src/lib/datasrc/zone_finder.h index c7bdcb7212..27263b9aa2 100644 --- a/src/lib/datasrc/zone_finder.h +++ b/src/lib/datasrc/zone_finder.h @@ -407,7 +407,7 @@ public: /// \name Search Methods /// //@{ - /// Search the zone for a given pair of domain name and RR type. + /// \brief Search the zone for a given pair of domain name and RR type. /// /// Each derived version of this method searches the underlying backend /// for the data that best matches the given name and type. @@ -579,6 +579,14 @@ public: const FindOptions options = FIND_DEFAULT) = 0; + /// \brief Search for an RRset of given RR type at the zone origin. + /// + /// This is an equivalent of a call to \c find() where the \c name + /// parameter is the zone origin. + virtual boost::shared_ptr findAtOrigin( + const isc::dns::RRType& type, bool use_minmtu, + FindOptions options); + /// /// \brief Finds all RRsets in the given name. ///