public:
MockClient() :
commit_called_(false),
- missing_zone_(false)
+ missing_zone_(false),
+ rrclass_(RRClass::IN())
{}
virtual FindResult findZone(const Name&) const {
isc_throw(isc::NotImplemented, "Method not used in tests");
bool commit_called_;
// If set to true, getUpdater returns NULL
bool missing_zone_;
+ // The pretended class of the client. Usualy IN, but can be overriden.
+ RRClass rrclass_;
};
// The updater isn't really correct according to the API. For example,
class Updater : public ZoneUpdater {
public:
Updater(MockClient* client) :
- client_(client)
+ client_(client),
+ finder_(client_->rrclass_)
{}
virtual ZoneFinder& getFinder() {
- isc_throw(isc::NotImplemented, "Method not used in tests");
+ return (finder_);
}
virtual void addRRset(const isc::dns::AbstractRRset& rrset) {
if (client_->commit_called_) {
}
private:
MockClient* client_;
+ class Finder : public ZoneFinder {
+ public:
+ Finder(const RRClass& rrclass) :
+ class_(rrclass)
+ {}
+ virtual RRClass getClass() const {
+ return (class_);
+ }
+ virtual Name getOrigin() const {
+ isc_throw(isc::NotImplemented, "Method not used in tests");
+ }
+ virtual shared_ptr<Context> find(const Name&, const RRType&,
+ const FindOptions)
+ {
+ isc_throw(isc::NotImplemented, "Method not used in tests");
+ }
+ virtual shared_ptr<Context> findAll(const Name&,
+ vector<ConstRRsetPtr>&,
+ const FindOptions)
+ {
+ isc_throw(isc::NotImplemented, "Method not used in tests");
+ }
+ virtual FindNSEC3Result findNSEC3(const Name&, bool) {
+ isc_throw(isc::NotImplemented, "Method not used in tests");
+ }
+ private:
+ const RRClass class_;
+ } finder_;
};
ZoneUpdaterPtr
source_client_), DataSourceError);
}
+// The class of the source and destination are different
+TEST_F(ZoneLoaderTest, classMismatch) {
+ destination_client_.rrclass_ = RRClass::CH();
+ prepareSource(Name::ROOT_NAME(), "root.zone");
+ EXPECT_THROW(ZoneLoader(destination_client_, Name::ROOT_NAME(),
+ source_client_), isc::InvalidParameter);
+}
+
// Load an unsigned zone, all at once
TEST_F(ZoneLoaderTest, loadUnsigned) {
ZoneLoader loader(destination_client_, Name::ROOT_NAME(),
isc_throw(DataSourceError, "Zone " << zone_name << " not found in "
"destination data source, can't fill it with data");
}
+ // The dereference of zone_finder is safe, if we can get iterator, we can
+ // get a finder.
+ //
+ // TODO: We probably need a getClass on the data source itself.
+ if (source.findZone(zone_name).zone_finder->getClass() !=
+ updater_->getFinder().getClass()) {
+ isc_throw(isc::InvalidParameter,
+ "Source and destination class mismatch");
+ }
+}
+
}
namespace {