]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2435] Handle find() with RRClass that may not be found
authorMukund Sivaraman <muks@isc.org>
Wed, 9 Jan 2013 05:34:40 +0000 (11:04 +0530)
committerMukund Sivaraman <muks@isc.org>
Wed, 9 Jan 2013 05:42:47 +0000 (11:12 +0530)
src/lib/datasrc/rrset_collection.cc
src/lib/datasrc/rrset_collection.h
src/lib/datasrc/tests/database_unittest.cc

index 51fa97c5a78467c9adc9f17320cd877733db85ac..e4cfd8801556be734a2f31344aae5a5750b50e28 100644 (file)
@@ -23,11 +23,16 @@ namespace datasrc {
 
 ConstRRsetPtr
 RRsetCollection::find(const isc::dns::Name& name,
-                      const isc::dns::RRClass&,
+                      const isc::dns::RRClass& rrclass,
                       const isc::dns::RRType& rrtype) const
 {
-    // TODO: RRClass needs to be checked here to see if it is as
-    // expected.
+    if (rrclass != rrclass_) {
+        // We could throw an exception here, but RRsetCollection is
+        // expected to support an arbitrary collection of RRsets, and it
+        // can be queried just as arbitrarily. So we just return nothing
+        // here.
+        return (ConstRRsetPtr());
+    }
 
     ZoneFinder& finder = updater_->getFinder();
     ZoneFinderContextPtr result =
index 6ad494a36dea6f2c0f6b475a03da9471d7532fd8..afe11992db313cde0b31d1ca77248825c0fad380 100644 (file)
@@ -33,8 +33,10 @@ public:
     /// destroyed by the client.
     ///
     /// \param updater The ZoneUpdater to wrap around.
-    RRsetCollection(ZoneUpdaterPtr updater) :
-        updater_(updater)
+    /// \param rrclass The RRClass of the records in the zone.
+    RRsetCollection(ZoneUpdaterPtr updater, const isc::dns::RRClass& rrclass) :
+        updater_(updater),
+        rrclass_(rrclass)
     {}
 
     /// \brief Destructor
@@ -56,6 +58,7 @@ public:
 
 private:
     ZoneUpdaterPtr updater_;
+    isc::dns::RRClass rrclass_;
 
 protected:
     // TODO: RRsetCollectionBase::Iter is not implemented and the
index 3df02cf60a0b4e359a48db6213680730c934b38a..39729f8d27d967b93a28597253fc85a066d4f03a 100644 (file)
@@ -4162,7 +4162,8 @@ class RRsetCollectionTest : public DatabaseClientTest<ACCESSOR_TYPE> {
 public:
     RRsetCollectionTest() :
         DatabaseClientTest<ACCESSOR_TYPE>(),
-        collection(this->client_->getUpdater(this->zname_, false))
+        collection(this->client_->getUpdater(this->zname_, false),
+                   this->qclass_)
     {}
 
     RRsetCollection collection;
@@ -4192,6 +4193,11 @@ TYPED_TEST(RRsetCollectionTest, find) {
     rrset = this->collection.find(Name("www.example.org"), this->qclass_,
                                   RRType::AAAA());
     EXPECT_TRUE(rrset);
+
+    // www.example.org with AAAA does not exist in RRClass::CH()
+    rrset = this->collection.find(Name("www.example.org"), RRClass::CH(),
+                                  RRType::AAAA());
+    EXPECT_FALSE(rrset);
 }
 
 TYPED_TEST(RRsetCollectionTest, iteratorTest) {