mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
[1535] renamed OutOfZoneFind to OutOfZone
And remove the memory-datasrc specific one
This commit is contained in:
@@ -865,7 +865,7 @@ DatabaseClient::Finder::findInternal(const Name& name, const RRType& type,
|
|||||||
name.compare(getOrigin()).getRelation();
|
name.compare(getOrigin()).getRelation();
|
||||||
if (reln != NameComparisonResult::SUBDOMAIN &&
|
if (reln != NameComparisonResult::SUBDOMAIN &&
|
||||||
reln != NameComparisonResult::EQUAL) {
|
reln != NameComparisonResult::EQUAL) {
|
||||||
isc_throw(OutOfZoneFind, name.toText() << " not in " << getOrigin());
|
isc_throw(OutOfZone, name.toText() << " not in " << getOrigin());
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, go through all superdomains from the origin down, searching for
|
// First, go through all superdomains from the origin down, searching for
|
||||||
|
@@ -413,8 +413,8 @@ ZoneData::findNode(const Name& name, ZoneFinder::FindOptions options) const {
|
|||||||
} else {
|
} else {
|
||||||
// If the name is neither an exact or partial match, it is
|
// If the name is neither an exact or partial match, it is
|
||||||
// out of bailiwick, which is considered an error.
|
// out of bailiwick, which is considered an error.
|
||||||
isc_throw(OutOfZoneFind, name.toText() << " not in " <<
|
isc_throw(OutOfZone, name.toText() << " not in " <<
|
||||||
origin_data_->getName());
|
origin_data_->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
@@ -125,16 +125,6 @@ public:
|
|||||||
/// exists).
|
/// exists).
|
||||||
result::Result add(const isc::dns::ConstRRsetPtr& rrset);
|
result::Result add(const isc::dns::ConstRRsetPtr& rrset);
|
||||||
|
|
||||||
/// \brief RRSet out of zone exception.
|
|
||||||
///
|
|
||||||
/// This is thrown if addition of an RRset that doesn't belong under the
|
|
||||||
/// zone's origin is requested.
|
|
||||||
struct OutOfZone : public InvalidParameter {
|
|
||||||
OutOfZone(const char* file, size_t line, const char* what) :
|
|
||||||
InvalidParameter(file, line, what)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// \brief RRset is NULL exception.
|
/// \brief RRset is NULL exception.
|
||||||
///
|
///
|
||||||
/// This is thrown if the provided RRset parameter is NULL.
|
/// This is thrown if the provided RRset parameter is NULL.
|
||||||
|
@@ -1877,29 +1877,28 @@ TYPED_TEST(DatabaseClientTest, findOutOfZone) {
|
|||||||
vector<ConstRRsetPtr> target;
|
vector<ConstRRsetPtr> target;
|
||||||
|
|
||||||
// Superdomain
|
// Superdomain
|
||||||
EXPECT_THROW(finder->find(Name("org"), this->qtype_), OutOfZoneFind);
|
EXPECT_THROW(finder->find(Name("org"), this->qtype_), OutOfZone);
|
||||||
EXPECT_THROW(finder->findAll(Name("org"), target), OutOfZoneFind);
|
EXPECT_THROW(finder->findAll(Name("org"), target), OutOfZone);
|
||||||
|
|
||||||
// sharing a common ancestor
|
// sharing a common ancestor
|
||||||
EXPECT_THROW(finder->find(Name("noexample.org"), this->qtype_),
|
EXPECT_THROW(finder->find(Name("noexample.org"), this->qtype_),
|
||||||
OutOfZoneFind);
|
OutOfZone);
|
||||||
EXPECT_THROW(finder->findAll(Name("noexample.org"), target),
|
EXPECT_THROW(finder->findAll(Name("noexample.org"), target),
|
||||||
OutOfZoneFind);
|
OutOfZone);
|
||||||
|
|
||||||
// totally unrelated domain, smaller number of labels
|
// totally unrelated domain, smaller number of labels
|
||||||
EXPECT_THROW(finder->find(Name("com"), this->qtype_), OutOfZoneFind);
|
EXPECT_THROW(finder->find(Name("com"), this->qtype_), OutOfZone);
|
||||||
EXPECT_THROW(finder->findAll(Name("com"), target), OutOfZoneFind);
|
EXPECT_THROW(finder->findAll(Name("com"), target), OutOfZone);
|
||||||
|
|
||||||
// totally unrelated domain, same number of labels
|
// totally unrelated domain, same number of labels
|
||||||
EXPECT_THROW(finder->find(Name("example.com"), this->qtype_),
|
EXPECT_THROW(finder->find(Name("example.com"), this->qtype_), OutOfZone);
|
||||||
OutOfZoneFind);
|
EXPECT_THROW(finder->findAll(Name("example.com"), target), OutOfZone);
|
||||||
EXPECT_THROW(finder->findAll(Name("example.com"), target), OutOfZoneFind);
|
|
||||||
|
|
||||||
// totally unrelated domain, larger number of labels
|
// totally unrelated domain, larger number of labels
|
||||||
EXPECT_THROW(finder->find(Name("more.example.com"), this->qtype_),
|
EXPECT_THROW(finder->find(Name("more.example.com"), this->qtype_),
|
||||||
OutOfZoneFind);
|
OutOfZone);
|
||||||
EXPECT_THROW(finder->findAll(Name("more.example.com"), target),
|
EXPECT_THROW(finder->findAll(Name("more.example.com"), target),
|
||||||
OutOfZoneFind);
|
OutOfZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(DatabaseClientTest, findDelegation) {
|
TYPED_TEST(DatabaseClientTest, findDelegation) {
|
||||||
@@ -2833,7 +2832,7 @@ TYPED_TEST(DatabaseClientTest, addDeviantRR) {
|
|||||||
SCOPED_TRACE("add out-of-zone RR");
|
SCOPED_TRACE("add out-of-zone RR");
|
||||||
EXPECT_THROW(this->updater_->getFinder().find(Name("example.com"),
|
EXPECT_THROW(this->updater_->getFinder().find(Name("example.com"),
|
||||||
this->qtype_),
|
this->qtype_),
|
||||||
OutOfZoneFind);
|
OutOfZone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -672,7 +672,7 @@ TEST_F(InMemoryZoneFinderTest, constructor) {
|
|||||||
*/
|
*/
|
||||||
TEST_F(InMemoryZoneFinderTest, add) {
|
TEST_F(InMemoryZoneFinderTest, add) {
|
||||||
// This one does not belong to this zone
|
// This one does not belong to this zone
|
||||||
EXPECT_THROW(zone_finder_.add(rr_out_), InMemoryZoneFinder::OutOfZone);
|
EXPECT_THROW(zone_finder_.add(rr_out_), OutOfZone);
|
||||||
// Test null pointer
|
// Test null pointer
|
||||||
EXPECT_THROW(zone_finder_.add(ConstRRsetPtr()),
|
EXPECT_THROW(zone_finder_.add(ConstRRsetPtr()),
|
||||||
InMemoryZoneFinder::NullRRset);
|
InMemoryZoneFinder::NullRRset);
|
||||||
@@ -901,7 +901,7 @@ TEST_F(InMemoryZoneFinderTest, findAny) {
|
|||||||
// out zone name
|
// out zone name
|
||||||
EXPECT_THROW(findAllTest(Name("example.com"), ZoneFinder::NXDOMAIN,
|
EXPECT_THROW(findAllTest(Name("example.com"), ZoneFinder::NXDOMAIN,
|
||||||
vector<ConstRRsetPtr>()),
|
vector<ConstRRsetPtr>()),
|
||||||
OutOfZoneFind);
|
OutOfZone);
|
||||||
|
|
||||||
expected_sets.clear();
|
expected_sets.clear();
|
||||||
expected_sets.push_back(rr_child_glue_);
|
expected_sets.push_back(rr_child_glue_);
|
||||||
@@ -999,7 +999,7 @@ InMemoryZoneFinderTest::findCheck(ZoneFinder::FindResultFlags expected_flags) {
|
|||||||
findTest(Name("nothere.example.org"), RRType::A(), ZoneFinder::NXDOMAIN,
|
findTest(Name("nothere.example.org"), RRType::A(), ZoneFinder::NXDOMAIN,
|
||||||
true, ConstRRsetPtr(), expected_flags);
|
true, ConstRRsetPtr(), expected_flags);
|
||||||
EXPECT_THROW(zone_finder_.find(Name("example.net"), RRType::A()),
|
EXPECT_THROW(zone_finder_.find(Name("example.net"), RRType::A()),
|
||||||
OutOfZoneFind);
|
OutOfZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InMemoryZoneFinderTest, find) {
|
TEST_F(InMemoryZoneFinderTest, find) {
|
||||||
@@ -1054,8 +1054,7 @@ InMemoryZoneFinderTest::emptyNodeCheck(
|
|||||||
// Note: basically we don't expect such a query to be performed (the common
|
// Note: basically we don't expect such a query to be performed (the common
|
||||||
// operation is to identify the best matching zone first then perform
|
// operation is to identify the best matching zone first then perform
|
||||||
// search it), but we shouldn't be confused even in the unexpected case.
|
// search it), but we shouldn't be confused even in the unexpected case.
|
||||||
EXPECT_THROW(zone_finder_.find(Name("org"), RRType::A()),
|
EXPECT_THROW(zone_finder_.find(Name("org"), RRType::A()), OutOfZone);
|
||||||
OutOfZoneFind);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InMemoryZoneFinderTest, emptyNode) {
|
TEST_F(InMemoryZoneFinderTest, emptyNode) {
|
||||||
@@ -1513,12 +1512,12 @@ TEST_F(InMemoryZoneFinderTest, swap) {
|
|||||||
EXPECT_EQ(RRClass::CH(), finder1.getClass());
|
EXPECT_EQ(RRClass::CH(), finder1.getClass());
|
||||||
EXPECT_EQ(RRClass::IN(), finder2.getClass());
|
EXPECT_EQ(RRClass::IN(), finder2.getClass());
|
||||||
// make sure the zone data is swapped, too
|
// make sure the zone data is swapped, too
|
||||||
EXPECT_THROW(finder1.find(origin_, RRType::NS()), OutOfZoneFind);
|
EXPECT_THROW(finder1.find(origin_, RRType::NS()), OutOfZone);
|
||||||
findTest(other_origin, RRType::TXT(), ZoneFinder::SUCCESS, false,
|
findTest(other_origin, RRType::TXT(), ZoneFinder::SUCCESS, false,
|
||||||
ConstRRsetPtr(), ZoneFinder::RESULT_DEFAULT, &finder1);
|
ConstRRsetPtr(), ZoneFinder::RESULT_DEFAULT, &finder1);
|
||||||
findTest(origin_, RRType::NS(), ZoneFinder::SUCCESS, false,
|
findTest(origin_, RRType::NS(), ZoneFinder::SUCCESS, false,
|
||||||
ConstRRsetPtr(), ZoneFinder::RESULT_DEFAULT, &finder2);
|
ConstRRsetPtr(), ZoneFinder::RESULT_DEFAULT, &finder2);
|
||||||
EXPECT_THROW(finder2.find(other_origin, RRType::TXT()), OutOfZoneFind);
|
EXPECT_THROW(finder2.find(other_origin, RRType::TXT()), OutOfZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InMemoryZoneFinderTest, getFileName) {
|
TEST_F(InMemoryZoneFinderTest, getFileName) {
|
||||||
|
@@ -27,11 +27,13 @@
|
|||||||
namespace isc {
|
namespace isc {
|
||||||
namespace datasrc {
|
namespace datasrc {
|
||||||
|
|
||||||
/// \brief Thrown when ZoneFinder::find() is called for out-of-zone data
|
/// \brief Out of zone exception
|
||||||
///
|
///
|
||||||
class OutOfZoneFind : public Exception {
|
/// This is thrown when a method is called for a name or RRset which
|
||||||
|
/// is not in or below the zone.
|
||||||
|
class OutOfZone : public Exception {
|
||||||
public:
|
public:
|
||||||
OutOfZoneFind(const char* file, size_t line, const char* what) :
|
OutOfZone(const char* file, size_t line, const char* what) :
|
||||||
isc::Exception(file, line, what) {}
|
isc::Exception(file, line, what) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -474,8 +476,8 @@ public:
|
|||||||
///
|
///
|
||||||
/// \exception std::bad_alloc Memory allocation such as for constructing
|
/// \exception std::bad_alloc Memory allocation such as for constructing
|
||||||
/// the resulting RRset fails
|
/// the resulting RRset fails
|
||||||
/// \throw OutOfZoneFind The Name \c name is outside of the origin
|
/// \throw OutOfZone The Name \c name is outside of the origin of the
|
||||||
/// of the zone of this ZoneFinder.
|
/// zone of this ZoneFinder.
|
||||||
/// \exception DataSourceError Derived class specific exception, e.g.
|
/// \exception DataSourceError Derived class specific exception, e.g.
|
||||||
/// when encountering a bad zone configuration or database connection
|
/// when encountering a bad zone configuration or database connection
|
||||||
/// failure. Although these are considered rare, exceptional events,
|
/// failure. Although these are considered rare, exceptional events,
|
||||||
|
@@ -233,7 +233,7 @@ initModulePart_ZoneJournalReader(PyObject* mod) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PyObject* po_DataSourceError;
|
PyObject* po_DataSourceError;
|
||||||
PyObject* po_OutOfZoneFind;
|
PyObject* po_OutOfZone;
|
||||||
PyObject* po_NotImplemented;
|
PyObject* po_NotImplemented;
|
||||||
|
|
||||||
PyModuleDef iscDataSrc = {
|
PyModuleDef iscDataSrc = {
|
||||||
@@ -288,10 +288,9 @@ PyInit_datasrc(void) {
|
|||||||
po_DataSourceError = PyErr_NewException("isc.datasrc.Error", NULL,
|
po_DataSourceError = PyErr_NewException("isc.datasrc.Error", NULL,
|
||||||
NULL);
|
NULL);
|
||||||
PyObjectContainer(po_DataSourceError).installToModule(mod, "Error");
|
PyObjectContainer(po_DataSourceError).installToModule(mod, "Error");
|
||||||
po_OutOfZoneFind = PyErr_NewException("isc.datasrc.OutOfZoneFind",
|
po_OutOfZone = PyErr_NewException("isc.datasrc.OutOfZone", NULL,
|
||||||
NULL, NULL);
|
NULL);
|
||||||
PyObjectContainer(po_OutOfZoneFind).installToModule(mod,
|
PyObjectContainer(po_OutOfZone).installToModule(mod, "OutOfZone");
|
||||||
"OutOfZoneFind");
|
|
||||||
po_NotImplemented = PyErr_NewException("isc.datasrc.NotImplemented",
|
po_NotImplemented = PyErr_NewException("isc.datasrc.NotImplemented",
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
PyObjectContainer(po_NotImplemented).installToModule(mod,
|
PyObjectContainer(po_NotImplemented).installToModule(mod,
|
||||||
|
@@ -97,9 +97,8 @@ PyObject* ZoneFinder_helper(ZoneFinder* finder, PyObject* args) {
|
|||||||
} else {
|
} else {
|
||||||
return (Py_BuildValue("IOI", r, Py_None, result_flags));
|
return (Py_BuildValue("IOI", r, Py_None, result_flags));
|
||||||
}
|
}
|
||||||
} catch (const OutOfZoneFind& oozf) {
|
} catch (const OutOfZone& ooz) {
|
||||||
PyErr_SetString(getDataSourceException("OutOfZoneFind"),
|
PyErr_SetString(getDataSourceException("OutOfZone"), ooz.what());
|
||||||
oozf.what());
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
} catch (const DataSourceError& dse) {
|
} catch (const DataSourceError& dse) {
|
||||||
PyErr_SetString(getDataSourceException("Error"), dse.what());
|
PyErr_SetString(getDataSourceException("Error"), dse.what());
|
||||||
|
@@ -380,7 +380,7 @@ class DataSrcClient(unittest.TestCase):
|
|||||||
self.assertEqual(None, rrset)
|
self.assertEqual(None, rrset)
|
||||||
|
|
||||||
|
|
||||||
self.assertRaises(isc.datasrc.OutOfZoneFind, finder.find,
|
self.assertRaises(isc.datasrc.OutOfZone, finder.find,
|
||||||
isc.dns.Name("www.some.other.domain"),
|
isc.dns.Name("www.some.other.domain"),
|
||||||
isc.dns.RRType.A())
|
isc.dns.RRType.A())
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user