BIND 10 trac2499, updated. dc2aa27ea58ec3be03e742f2f4dd123a2c044200 [2499] Re-enable testcase where invalid data is copied from another data source
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Jan 18 11:25:54 UTC 2013
The branch, trac2499 has been updated
via dc2aa27ea58ec3be03e742f2f4dd123a2c044200 (commit)
from 671b6ae757f8a4f22bec449afa9b743c4ec2d719 (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 dc2aa27ea58ec3be03e742f2f4dd123a2c044200
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Jan 18 16:23:49 2013 +0530
[2499] Re-enable testcase where invalid data is copied from another data source
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/tests/zone_loader_unittest.cc | 139 ++++++++++++++++++++-----
1 file changed, 111 insertions(+), 28 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/tests/zone_loader_unittest.cc b/src/lib/datasrc/tests/zone_loader_unittest.cc
index 3de290e..2ca4cf5 100644
--- a/src/lib/datasrc/tests/zone_loader_unittest.cc
+++ b/src/lib/datasrc/tests/zone_loader_unittest.cc
@@ -21,6 +21,7 @@
#include <dns/rrclass.h>
#include <dns/name.h>
#include <dns/rrset.h>
+#include <dns/rdataclass.h>
#include <util/memory_segment_local.h>
#include <exceptions/exceptions.h>
@@ -32,15 +33,11 @@
#include <string>
#include <vector>
-using isc::dns::RRClass;
-using isc::dns::Name;
-using isc::dns::RRType;
-using isc::dns::ConstRRsetPtr;
-using isc::dns::RRsetPtr;
+using namespace isc::dns;
+using namespace isc::datasrc;
+using boost::shared_ptr;
using std::string;
using std::vector;
-using boost::shared_ptr;
-using namespace isc::datasrc;
namespace {
@@ -51,8 +48,97 @@ public:
missing_zone_(false),
rrclass_(RRClass::IN())
{}
- virtual FindResult findZone(const Name&) const {
- isc_throw(isc::NotImplemented, "Method not used in tests");
+ class Finder : public ZoneFinder {
+ public:
+ Finder(const Name& origin) :
+ origin_(origin)
+ {}
+ Name getOrigin() const {
+ return (origin_);
+ }
+ RRClass getClass() const {
+ return (RRClass::IN());
+ }
+ // The rest is not to be called, so they throw.
+ shared_ptr<Context> find(const Name&, const RRType&,
+ const FindOptions)
+ {
+ isc_throw(isc::NotImplemented, "Not implemented");
+ }
+ shared_ptr<Context> findAll(const Name&,
+ vector<ConstRRsetPtr>&,
+ const FindOptions)
+ {
+ isc_throw(isc::NotImplemented, "Not implemented");
+ }
+ FindNSEC3Result findNSEC3(const Name&, bool) {
+ isc_throw(isc::NotImplemented, "Not implemented");
+ }
+ private:
+ Name origin_;
+ };
+ class Iterator : public ZoneIterator {
+ public:
+ Iterator() :
+ origin_("example.org"),
+ soa_(new RRset(origin_, RRClass::IN(), RRType::SOA(),
+ RRTTL(3600)))
+ {
+ // The RData here is bogus, but it is not used to anything. There
+ // just needs to be some.
+ soa_->addRdata(rdata::generic::SOA(Name::ROOT_NAME(),
+ Name::ROOT_NAME(),
+ 0, 0, 0, 0, 0));
+ rrsets_.push_back(soa_);
+
+ // There is no NS record on purpose here.
+
+ // Dummy A rrset. This is used for checking zone data after
+ // reload.
+ RRsetPtr rrset(new RRset(Name("tstzonedata").concatenate(origin_),
+ RRClass::IN(), RRType::A(),
+ RRTTL(3600)));
+ rrset->addRdata(rdata::in::A("192.0.2.1"));
+ rrsets_.push_back(rrset);
+
+ rrsets_.push_back(ConstRRsetPtr());
+
+ it_ = rrsets_.begin();
+ }
+ virtual isc::dns::ConstRRsetPtr getNextRRset() {
+ ConstRRsetPtr result = *it_;
+ ++it_;
+ return (result);
+ }
+ virtual isc::dns::ConstRRsetPtr getSOA() const {
+ return (soa_);
+ }
+ private:
+ const Name origin_;
+ const RRsetPtr soa_;
+ std::vector<ConstRRsetPtr> rrsets_;
+ std::vector<ConstRRsetPtr>::const_iterator it_;
+ };
+ virtual ZoneIteratorPtr getIterator(const isc::dns::Name& name,
+ bool) const
+ {
+ if (name != Name("example.org")) {
+ isc_throw(DataSourceError, "No such zone");
+ }
+ return (ZoneIteratorPtr(new Iterator()));
+ }
+ virtual FindResult findZone(const Name& name) const {
+ const Name origin("example.org");
+ const ZoneFinderPtr finder(new Finder(origin));
+ NameComparisonResult compar(origin.compare(name));
+ switch (compar.getRelation()) {
+ case NameComparisonResult::EQUAL:
+ return (FindResult(result::SUCCESS, finder));
+ case NameComparisonResult::SUPERDOMAIN:
+ return (FindResult(result::PARTIALMATCH, finder));
+ default:
+ return (FindResult(result::NOTFOUND, ZoneFinderPtr()));
+ }
};
virtual std::pair<ZoneJournalReader::Result, ZoneJournalReaderPtr>
getJournalReader(const Name&, uint32_t, uint32_t) const
@@ -214,13 +300,6 @@ protected:
source_client_(ztable_segment_, rrclass_)
{}
void prepareSource(const Name& zone, const char* filename) {
- // TODO:
- // Currently, source_client_ is of InMemoryClient and its load()
- // uses a different code than the ZoneLoader (so we can cross-check
- // the implementations). Currently, the load() doesn't perform any
- // post-load checks. It will change in #2499, at which point the
- // loading may start failing depending on details of the test data. We
- // should prepare the data by some different method then.
source_client_.load(zone, string(TEST_DATA_DIR) + "/" + filename);
}
private:
@@ -461,18 +540,6 @@ TEST_F(ZoneLoaderTest, loadCheck) {
EXPECT_FALSE(destination_client_.commit_called_);
}
-// The same test, but for copying from other data source
-// Disabled by #2499. See the comment in prepareSource().
-TEST_F(ZoneLoaderTest, DISABLED_copyCheck) {
- prepareSource(Name("example.org"), "novalidate.zone");
- ZoneLoader loader(destination_client_, Name("example.org"),
- source_client_);
-
- EXPECT_THROW(loader.loadIncremental(10), ZoneContentError);
- // The messages go to the log. We don't have an easy way to examine them.
- EXPECT_FALSE(destination_client_.commit_called_);
-}
-
// Check a warning doesn't disrupt the loading of the zone
TEST_F(ZoneLoaderTest, loadCheckWarn) {
ZoneLoader loader(destination_client_, Name("example.org"),
@@ -496,4 +563,20 @@ TEST_F(ZoneLoaderTest, copyCheckWarn) {
}
+// Test there's validation of the data in the zone loader when copying
+// from another data source. Currently, this test doesn't require
+// creating a fixture as it uses almost nothing in existing fixtures.
+TEST(ZoneLoaderMockSourceTest, copyCheck) {
+ // In this test, source_client provides a zone that does not
+ // validate (no NS).
+ MockClient source_client;
+ MockClient destination_client;
+ ZoneLoader loader(destination_client, Name("example.org"),
+ source_client);
+
+ EXPECT_THROW(loader.loadIncremental(10), ZoneContentError);
+ // The messages go to the log. We don't have an easy way to examine them.
+ EXPECT_FALSE(destination_client.commit_called_);
+}
+
}
More information about the bind10-changes
mailing list