Commit 1d849415 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2033] removed ZoneFinder::findPreviousName.

Except in the database, which was changed to private.  It was not meant
to be public and hasn't actually been used except for tests and internally
in the database version.
parent 4c6ec1df
......@@ -1264,11 +1264,6 @@ public:
return (real_zone_finder_->findNSEC3(name, recursive));
}
virtual isc::dns::Name
findPreviousName(const isc::dns::Name& query) const {
return (real_zone_finder_->findPreviousName(query));
}
private:
isc::datasrc::ZoneFinderPtr real_zone_finder_;
ThrowWhen throw_when_;
......
......@@ -425,10 +425,6 @@ public:
// answers when DNSSEC is required.
void setNSEC3Flag(bool on) { use_nsec3_ = on; }
virtual Name findPreviousName(const Name&) const {
isc_throw(isc::NotImplemented, "Mock doesn't support previous name");
}
// This method allows tests to insert new record in the middle of the test.
//
// \param record_txt textual RR representation of RR (such as soa_txt, etc)
......
......@@ -1126,9 +1126,9 @@ DatabaseClient::Finder::findPreviousName(const Name& name) const {
name.reverse().toText()));
try {
return (Name(str));
}
catch (const isc::dns::NameParserException&) {
isc_throw(DataSourceError, "Bad name " + str + " from findPreviousName");
} catch (const isc::dns::NameParserException&) {
isc_throw(DataSourceError, "Bad name " + str +
" from findPreviousName");
}
}
......
......@@ -743,8 +743,9 @@ public:
/// \brief It returns the previous name in DNSSEC order.
///
/// This is used in DatabaseClient::findPreviousName and does more
/// or less the real work, except for working on strings.
/// Gets the previous name in the DNSSEC order. This can be used
/// to find the correct NSEC records for proving nonexistence
/// of domains.
///
/// \param rname The name to ask for previous of, in reversed form.
/// We use the reversed form (see isc::dns::Name::reverse),
......@@ -904,10 +905,6 @@ public:
std::vector<isc::dns::ConstRRsetPtr>& target,
const FindOptions options = FIND_DEFAULT);
/// \brief Implementation of ZoneFinder::findPreviousName method.
virtual isc::dns::Name findPreviousName(const isc::dns::Name& query)
const;
/// Look for NSEC3 for proving (non)existence of given name.
///
/// See documentation in \c Zone.
......@@ -1108,6 +1105,10 @@ public:
bool probed_;
};
/// \brief A simple wrapper for identifying the previous name
/// of the given name in the underlying database.
isc::dns::Name findPreviousName(const isc::dns::Name& name) const;
/// \brief Search result of \c findDelegationPoint().
///
/// This is a tuple combining the result of the search - a status code
......
......@@ -1774,12 +1774,6 @@ InMemoryZoneFinder::getFileName() const {
return (impl_->file_name_);
}
isc::dns::Name
InMemoryZoneFinder::findPreviousName(const isc::dns::Name&) const {
isc_throw(NotImplemented, "InMemory data source doesn't support DNSSEC "
"yet, can't find previous name");
}
/// Implementation details for \c InMemoryClient hidden from the public
/// interface.
///
......
......@@ -87,12 +87,6 @@ public:
virtual FindNSEC3Result
findNSEC3(const isc::dns::Name& name, bool recursive);
/// \brief Imelementation of the ZoneFinder::findPreviousName method
///
/// This one throws NotImplemented exception, as InMemory doesn't
/// support DNSSEC currently.
virtual isc::dns::Name findPreviousName(const isc::dns::Name& query) const;
/// \brief Inserts an rrset into the zone.
///
/// It puts another RRset into the zone.
......
......@@ -57,9 +57,6 @@ public:
FindNSEC3Result findNSEC3(const Name&, bool) {
isc_throw(isc::NotImplemented, "Not implemented");
}
Name findPreviousName(const Name&) const {
isc_throw(isc::NotImplemented, "Not implemented");
}
private:
Name origin_;
};
......
......@@ -3622,33 +3622,6 @@ TYPED_TEST(DatabaseClientTest, compoundUpdate) {
this->empty_rdatas_);
}
TYPED_TEST(DatabaseClientTest, previous) {
boost::shared_ptr<DatabaseClient::Finder> finder(this->getFinder());
EXPECT_EQ(Name("www.example.org."),
finder->findPreviousName(Name("www2.example.org.")));
// Check a name that doesn't exist there
EXPECT_EQ(Name("www.example.org."),
finder->findPreviousName(Name("www1.example.org.")));
if (this->is_mock_) { // We can't really force the DB to throw
// Check it doesn't crash or anything if the underlying DB throws
DataSourceClient::FindResult
zone(this->client_->findZone(Name("bad.example.org")));
finder =
dynamic_pointer_cast<DatabaseClient::Finder>(zone.zone_finder);
EXPECT_THROW(finder->findPreviousName(Name("bad.example.org")),
isc::NotImplemented);
} else {
// No need to test this on mock one, because we test only that
// the exception gets through
// A name before the origin
EXPECT_THROW(finder->findPreviousName(Name("example.com")),
isc::NotImplemented);
}
}
TYPED_TEST(DatabaseClientTest, invalidRdata) {
boost::shared_ptr<DatabaseClient::Finder> finder(this->getFinder());
......@@ -3676,13 +3649,6 @@ TEST_F(MockDatabaseClientTest, missingNSEC) {
this->expected_rdatas_, this->expected_sig_rdatas_);
}
TEST_F(MockDatabaseClientTest, badName) {
boost::shared_ptr<DatabaseClient::Finder> finder(this->getFinder());
EXPECT_THROW(finder->findPreviousName(Name("brokenname.example.org.")),
DataSourceError);
}
/*
* Test correct use of the updater with a journal.
*/
......
......@@ -682,14 +682,6 @@ public:
}
};
/**
* \brief Check that findPreviousName throws as it should now.
*/
TEST_F(InMemoryZoneFinderTest, findPreviousName) {
EXPECT_THROW(zone_finder_.findPreviousName(Name("www.example.org")),
isc::NotImplemented);
}
/**
* \brief Test InMemoryZoneFinder::InMemoryZoneFinder constructor.
*
......
......@@ -617,31 +617,6 @@ public:
/// a matching NSEC3, in the form of \c FindNSEC3Result object.
virtual FindNSEC3Result
findNSEC3(const isc::dns::Name& name, bool recursive) = 0;
/// \brief Get previous name in the zone
///
/// Gets the previous name in the DNSSEC order. This can be used
/// to find the correct NSEC records for proving nonexistence
/// of domains.
///
/// The concrete implementation might throw anything it thinks appropriate,
/// however it is recommended to stick to the ones listed here. The user
/// of this method should be able to handle any exceptions.
///
/// This method does not include under-zone-cut data (glue data).
///
/// \param query The name for which one we look for a previous one. The
/// queried name doesn't have to exist in the zone.
/// \return The preceding name
///
/// \throw NotImplemented in case the data source backend doesn't support
/// DNSSEC or there is no previous in the zone (NSEC records might be
/// missing in the DB, the queried name is less or equal to the apex).
/// \throw DataSourceError for low-level or internal datasource errors
/// (like broken connection to database, wrong data living there).
/// \throw std::bad_alloc For allocation errors.
virtual isc::dns::Name findPreviousName(const isc::dns::Name& query)
const = 0;
//@}
};
......
......@@ -225,22 +225,4 @@ In the second element a single RRset is returned for cases where the\n\
result is some kind of delegation, CNAME or similar; in other cases\n\
a list of RRsets is returned, containing all the results.\n\
";
const char* const ZoneFinder_find_previous_name_doc = "\
find_previous_name(isc.dns.Name) -> isc.dns.Name\n\
\n\
Gets the previous name in the DNSSEC order. This can be used\n\
to find the correct NSEC records for proving nonexistence\n\
of domains.\n\
\n\
This method does not include under-zone-cut data (glue data).\n\
\n\
Raises isc.datasrc.NotImplemented in case the data source backend\n\
doesn't support DNSSEC or there is no previous in the zone (NSEC\n\
records might be missing in the DB, the queried name is less or\n\
equal to the apex).\n\
\n\
Raises isc.datasrc.Error for low-level or internal datasource errors\n\
(like broken connection to database, wrong data living there).\n\
";
} // unnamed namespace
......@@ -254,31 +254,6 @@ ZoneFinder_find_all(PyObject* po_self, PyObject* args) {
args));
}
PyObject*
ZoneFinder_findPreviousName(PyObject* po_self, PyObject* args) {
s_ZoneFinder* const self = static_cast<s_ZoneFinder*>(po_self);
PyObject* name_obj;
if (PyArg_ParseTuple(args, "O!", &name_type, &name_obj)) {
try {
return (createNameObject(
self->cppobj->findPreviousName(PyName_ToName(name_obj))));
} catch (const isc::NotImplemented& nie) {
PyErr_SetString(getDataSourceException("NotImplemented"),
nie.what());
return (NULL);
} catch (const std::exception& exc) {
PyErr_SetString(getDataSourceException("Error"), exc.what());
return (NULL);
} catch (...) {
PyErr_SetString(getDataSourceException("Error"),
"Unexpected exception");
return (NULL);
}
} else {
return (NULL);
}
}
// This list contains the actual set of functions we have in
// python. Each entry has
// 1. Python method name
......@@ -291,8 +266,6 @@ PyMethodDef ZoneFinder_methods[] = {
{ "get_class", ZoneFinder_getClass, METH_NOARGS, ZoneFinder_getClass_doc },
{ "find", ZoneFinder_find, METH_VARARGS, ZoneFinder_find_doc },
{ "find_all", ZoneFinder_find_all, METH_VARARGS, ZoneFinder_findAll_doc },
{ "find_previous_name", ZoneFinder_findPreviousName, METH_VARARGS,
ZoneFinder_find_previous_name_doc },
{ NULL, NULL, 0, NULL }
};
......
......@@ -426,25 +426,6 @@ class DataSrcClient(unittest.TestCase):
isc.dns.RRType.A(),
"foo")
def test_find_previous(self):
dsc = isc.datasrc.DataSourceClient("sqlite3", READ_ZONE_DB_CONFIG)
result, finder = dsc.find_zone(isc.dns.Name("example.com"))
self.assertEqual(finder.SUCCESS, result)
prev = finder.find_previous_name(isc.dns.Name("bbb.example.com"))
self.assertEqual("example.com.", prev.to_text())
prev = finder.find_previous_name(isc.dns.Name("zzz.example.com"))
self.assertEqual("www.example.com.", prev.to_text())
prev = finder.find_previous_name(prev)
self.assertEqual("*.wild.example.com.", prev.to_text())
self.assertRaises(isc.datasrc.NotImplemented,
finder.find_previous_name,
isc.dns.Name("com"))
class DataSrcUpdater(unittest.TestCase):
def setUp(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment