mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +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();
|
||||
if (reln != NameComparisonResult::SUBDOMAIN &&
|
||||
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
|
||||
|
@@ -413,8 +413,8 @@ ZoneData::findNode(const Name& name, ZoneFinder::FindOptions options) const {
|
||||
} else {
|
||||
// If the name is neither an exact or partial match, it is
|
||||
// out of bailiwick, which is considered an error.
|
||||
isc_throw(OutOfZoneFind, name.toText() << " not in " <<
|
||||
origin_data_->getName());
|
||||
isc_throw(OutOfZone, name.toText() << " not in " <<
|
||||
origin_data_->getName());
|
||||
}
|
||||
}
|
||||
} // unnamed namespace
|
||||
|
@@ -125,16 +125,6 @@ public:
|
||||
/// exists).
|
||||
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.
|
||||
///
|
||||
/// This is thrown if the provided RRset parameter is NULL.
|
||||
|
@@ -1877,29 +1877,28 @@ TYPED_TEST(DatabaseClientTest, findOutOfZone) {
|
||||
vector<ConstRRsetPtr> target;
|
||||
|
||||
// Superdomain
|
||||
EXPECT_THROW(finder->find(Name("org"), this->qtype_), OutOfZoneFind);
|
||||
EXPECT_THROW(finder->findAll(Name("org"), target), OutOfZoneFind);
|
||||
EXPECT_THROW(finder->find(Name("org"), this->qtype_), OutOfZone);
|
||||
EXPECT_THROW(finder->findAll(Name("org"), target), OutOfZone);
|
||||
|
||||
// sharing a common ancestor
|
||||
EXPECT_THROW(finder->find(Name("noexample.org"), this->qtype_),
|
||||
OutOfZoneFind);
|
||||
OutOfZone);
|
||||
EXPECT_THROW(finder->findAll(Name("noexample.org"), target),
|
||||
OutOfZoneFind);
|
||||
OutOfZone);
|
||||
|
||||
// totally unrelated domain, smaller number of labels
|
||||
EXPECT_THROW(finder->find(Name("com"), this->qtype_), OutOfZoneFind);
|
||||
EXPECT_THROW(finder->findAll(Name("com"), target), OutOfZoneFind);
|
||||
EXPECT_THROW(finder->find(Name("com"), this->qtype_), OutOfZone);
|
||||
EXPECT_THROW(finder->findAll(Name("com"), target), OutOfZone);
|
||||
|
||||
// totally unrelated domain, same number of labels
|
||||
EXPECT_THROW(finder->find(Name("example.com"), this->qtype_),
|
||||
OutOfZoneFind);
|
||||
EXPECT_THROW(finder->findAll(Name("example.com"), target), OutOfZoneFind);
|
||||
EXPECT_THROW(finder->find(Name("example.com"), this->qtype_), OutOfZone);
|
||||
EXPECT_THROW(finder->findAll(Name("example.com"), target), OutOfZone);
|
||||
|
||||
// totally unrelated domain, larger number of labels
|
||||
EXPECT_THROW(finder->find(Name("more.example.com"), this->qtype_),
|
||||
OutOfZoneFind);
|
||||
OutOfZone);
|
||||
EXPECT_THROW(finder->findAll(Name("more.example.com"), target),
|
||||
OutOfZoneFind);
|
||||
OutOfZone);
|
||||
}
|
||||
|
||||
TYPED_TEST(DatabaseClientTest, findDelegation) {
|
||||
@@ -2833,7 +2832,7 @@ TYPED_TEST(DatabaseClientTest, addDeviantRR) {
|
||||
SCOPED_TRACE("add out-of-zone RR");
|
||||
EXPECT_THROW(this->updater_->getFinder().find(Name("example.com"),
|
||||
this->qtype_),
|
||||
OutOfZoneFind);
|
||||
OutOfZone);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -672,7 +672,7 @@ TEST_F(InMemoryZoneFinderTest, constructor) {
|
||||
*/
|
||||
TEST_F(InMemoryZoneFinderTest, add) {
|
||||
// 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
|
||||
EXPECT_THROW(zone_finder_.add(ConstRRsetPtr()),
|
||||
InMemoryZoneFinder::NullRRset);
|
||||
@@ -901,7 +901,7 @@ TEST_F(InMemoryZoneFinderTest, findAny) {
|
||||
// out zone name
|
||||
EXPECT_THROW(findAllTest(Name("example.com"), ZoneFinder::NXDOMAIN,
|
||||
vector<ConstRRsetPtr>()),
|
||||
OutOfZoneFind);
|
||||
OutOfZone);
|
||||
|
||||
expected_sets.clear();
|
||||
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,
|
||||
true, ConstRRsetPtr(), expected_flags);
|
||||
EXPECT_THROW(zone_finder_.find(Name("example.net"), RRType::A()),
|
||||
OutOfZoneFind);
|
||||
OutOfZone);
|
||||
}
|
||||
|
||||
TEST_F(InMemoryZoneFinderTest, find) {
|
||||
@@ -1054,8 +1054,7 @@ InMemoryZoneFinderTest::emptyNodeCheck(
|
||||
// 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
|
||||
// search it), but we shouldn't be confused even in the unexpected case.
|
||||
EXPECT_THROW(zone_finder_.find(Name("org"), RRType::A()),
|
||||
OutOfZoneFind);
|
||||
EXPECT_THROW(zone_finder_.find(Name("org"), RRType::A()), OutOfZone);
|
||||
}
|
||||
|
||||
TEST_F(InMemoryZoneFinderTest, emptyNode) {
|
||||
@@ -1513,12 +1512,12 @@ TEST_F(InMemoryZoneFinderTest, swap) {
|
||||
EXPECT_EQ(RRClass::CH(), finder1.getClass());
|
||||
EXPECT_EQ(RRClass::IN(), finder2.getClass());
|
||||
// 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,
|
||||
ConstRRsetPtr(), ZoneFinder::RESULT_DEFAULT, &finder1);
|
||||
findTest(origin_, RRType::NS(), ZoneFinder::SUCCESS, false,
|
||||
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) {
|
||||
|
@@ -27,11 +27,13 @@
|
||||
namespace isc {
|
||||
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:
|
||||
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) {}
|
||||
};
|
||||
|
||||
@@ -474,8 +476,8 @@ public:
|
||||
///
|
||||
/// \exception std::bad_alloc Memory allocation such as for constructing
|
||||
/// the resulting RRset fails
|
||||
/// \throw OutOfZoneFind The Name \c name is outside of the origin
|
||||
/// of the zone of this ZoneFinder.
|
||||
/// \throw OutOfZone The Name \c name is outside of the origin of the
|
||||
/// zone of this ZoneFinder.
|
||||
/// \exception DataSourceError Derived class specific exception, e.g.
|
||||
/// when encountering a bad zone configuration or database connection
|
||||
/// failure. Although these are considered rare, exceptional events,
|
||||
|
@@ -233,7 +233,7 @@ initModulePart_ZoneJournalReader(PyObject* mod) {
|
||||
}
|
||||
|
||||
PyObject* po_DataSourceError;
|
||||
PyObject* po_OutOfZoneFind;
|
||||
PyObject* po_OutOfZone;
|
||||
PyObject* po_NotImplemented;
|
||||
|
||||
PyModuleDef iscDataSrc = {
|
||||
@@ -288,10 +288,9 @@ PyInit_datasrc(void) {
|
||||
po_DataSourceError = PyErr_NewException("isc.datasrc.Error", NULL,
|
||||
NULL);
|
||||
PyObjectContainer(po_DataSourceError).installToModule(mod, "Error");
|
||||
po_OutOfZoneFind = PyErr_NewException("isc.datasrc.OutOfZoneFind",
|
||||
NULL, NULL);
|
||||
PyObjectContainer(po_OutOfZoneFind).installToModule(mod,
|
||||
"OutOfZoneFind");
|
||||
po_OutOfZone = PyErr_NewException("isc.datasrc.OutOfZone", NULL,
|
||||
NULL);
|
||||
PyObjectContainer(po_OutOfZone).installToModule(mod, "OutOfZone");
|
||||
po_NotImplemented = PyErr_NewException("isc.datasrc.NotImplemented",
|
||||
NULL, NULL);
|
||||
PyObjectContainer(po_NotImplemented).installToModule(mod,
|
||||
|
@@ -97,9 +97,8 @@ PyObject* ZoneFinder_helper(ZoneFinder* finder, PyObject* args) {
|
||||
} else {
|
||||
return (Py_BuildValue("IOI", r, Py_None, result_flags));
|
||||
}
|
||||
} catch (const OutOfZoneFind& oozf) {
|
||||
PyErr_SetString(getDataSourceException("OutOfZoneFind"),
|
||||
oozf.what());
|
||||
} catch (const OutOfZone& ooz) {
|
||||
PyErr_SetString(getDataSourceException("OutOfZone"), ooz.what());
|
||||
return (NULL);
|
||||
} catch (const DataSourceError& dse) {
|
||||
PyErr_SetString(getDataSourceException("Error"), dse.what());
|
||||
|
@@ -380,7 +380,7 @@ class DataSrcClient(unittest.TestCase):
|
||||
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.RRType.A())
|
||||
|
||||
|
Reference in New Issue
Block a user