]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2438] Merge branch 'trac2438-0' into trac2438
authorJINMEI Tatuya <jinmei@isc.org>
Wed, 16 Jan 2013 20:40:17 +0000 (12:40 -0800)
committerJINMEI Tatuya <jinmei@isc.org>
Wed, 16 Jan 2013 20:40:17 +0000 (12:40 -0800)
resolved Conflicts:
src/lib/datasrc/Makefile.am
src/lib/datasrc/database.cc
src/lib/datasrc/tests/database_unittest.cc
src/lib/datasrc/tests/master_loader_callbacks_test.cc
src/lib/datasrc/tests/zone_loader_unittest.cc
src/lib/datasrc/zone.h
src/lib/dns/rrset_collection_base.h

1  2 
src/lib/datasrc/database.cc
src/lib/datasrc/tests/database_unittest.cc
src/lib/datasrc/zone.h
src/lib/dns/rrset_collection_base.h

Simple merge
index 94d90b5e3ba2e49a3a1f3f1dcb5bf8a69687bd9b,0c85aea6a7d8e3948b85179f4e5eb46df16b8429..12c4b570d9c8893848cf9a9f6c30dd05241562f0
@@@ -4172,13 -4167,13 +4173,22 @@@ public
      {}
  
      ZoneUpdaterPtr updater;
++<<<<<<< HEAD
 +    isc::datasrc::RRsetCollectionBase& collection;
++=======
+     RRsetCollectionPtr collection;
++>>>>>>> trac2438-0
  };
  
  TYPED_TEST(RRsetCollectionTest, find) {
      // Test the find() that returns ConstRRsetPtr
++<<<<<<< HEAD
 +    ConstRRsetPtr rrset = this->collection.find(Name("www.example.org."),
 +                                                RRClass::IN(), RRType::A());
++=======
+     ConstRRsetPtr rrset = this->collection->find(Name("www.example.org."),
+                                                  RRClass::IN(), RRType::A());
++>>>>>>> trac2438-0
      ASSERT_TRUE(rrset);
      EXPECT_EQ(RRType::A(), rrset->getType());
      EXPECT_EQ(RRTTL(3600), rrset->getTTL());
      EXPECT_EQ(Name("www.example.org"), rrset->getName());
  
      // foo.example.org doesn't exist
++<<<<<<< HEAD
 +    rrset = this->collection.find(Name("foo.example.org"), this->qclass_,
 +                                  RRType::A());
 +    EXPECT_FALSE(rrset);
 +
 +    // www.example.org exists, but not with MX
 +    rrset = this->collection.find(Name("www.example.org"), this->qclass_,
 +                                  RRType::MX());
 +    EXPECT_FALSE(rrset);
 +
 +    // www.example.org exists, with AAAA
 +    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);
 +
 +    // Out-of-zone find()s must not throw.
 +    rrset = this->collection.find(Name("www.example.com"), this->qclass_,
 +                                  RRType::A());
 +    EXPECT_FALSE(rrset);
 +
 +    // "cname.example.org." with type CNAME should return the CNAME RRset
 +    rrset = this->collection.find(Name("cname.example.org"), this->qclass_,
 +                                  RRType::CNAME());
 +    ASSERT_TRUE(rrset);
 +    EXPECT_EQ(RRType::CNAME(), rrset->getType());
 +    EXPECT_EQ(Name("cname.example.org"), rrset->getName());
 +
 +    // "cname.example.org." with type A should return nothing
 +    rrset = this->collection.find(Name("cname.example.org"), this->qclass_,
 +                                  RRType::A());
 +    EXPECT_FALSE(rrset);
 +
 +    // "dname.example.org." with type DNAME should return the DNAME RRset
 +    rrset = this->collection.find(Name("dname.example.org"), this->qclass_,
 +                                  RRType::DNAME());
 +    ASSERT_TRUE(rrset);
 +    EXPECT_EQ(RRType::DNAME(), rrset->getType());
 +    EXPECT_EQ(Name("dname.example.org"), rrset->getName());
 +
 +    // "below.dname.example.org." with type AAAA should return nothing
 +    rrset = this->collection.find(Name("below.dname.example.org"),
 +                                  this->qclass_, RRType::AAAA());
 +    EXPECT_FALSE(rrset);
 +
 +    // "below.dname.example.org." with type A does not return the record
 +    // (see top of file). See \c isc::datasrc::RRsetCollectionBase::find()
 +    // documentation for details.
 +    rrset = this->collection.find(Name("below.dname.example.org"),
 +                                  this->qclass_, RRType::A());
 +    EXPECT_FALSE(rrset);
 +
 +    // With the FIND_GLUE_OK option passed to ZoneFinder's find(),
 +    // searching for "delegation.example.org." with type NS should
 +    // return the NS record. Without FIND_GLUE_OK, ZoneFinder's find()
 +    // would return DELEGATION and the find() below would return
 +    // nothing.
 +    rrset = this->collection.find(Name("delegation.example.org"),
 +                                  this->qclass_, RRType::NS());
 +    ASSERT_TRUE(rrset);
 +    EXPECT_EQ(RRType::NS(), rrset->getType());
 +    EXPECT_EQ(Name("delegation.example.org"), rrset->getName());
 +
 +    // With the NO_WILDCARD option passed to ZoneFinder's find(),
 +    // searching for some "foo.wildcard.example.org." would make
 +    // ZoneFinder's find() return NXDOMAIN, and the find() below should
 +    // return nothing.
 +    rrset = this->collection.find(Name("foo.wild.example.org"),
 +                                  this->qclass_, RRType::A());
 +    EXPECT_FALSE(rrset);
 +
 +    // Searching directly for "*.wild.example.org." should return the
 +    // record.
 +    rrset = this->collection.find(Name("*.wild.example.org"),
 +                                  this->qclass_, RRType::A());
 +    ASSERT_TRUE(rrset);
 +    EXPECT_EQ(RRType::A(), rrset->getType());
 +    EXPECT_EQ(Name("*.wild.example.org"), rrset->getName());
++=======
+     rrset = this->collection->find(Name("foo.example.org"), this->qclass_,
+                                    RRType::A());
+     EXPECT_FALSE(rrset);
+     // www.example.org exists, but not with MX
+     rrset = this->collection->find(Name("www.example.org"), this->qclass_,
+                                    RRType::MX());
+     EXPECT_FALSE(rrset);
+     // www.example.org exists, with AAAA
+     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);
+     // Out of zone find()s must not throw.
+     rrset = this->collection->find(Name("www.example.com"), this->qclass_,
+                                    RRType::A());
+     EXPECT_FALSE(rrset);
++>>>>>>> trac2438-0
  }
  
  TYPED_TEST(RRsetCollectionTest, iteratorTest) {
      // Iterators are currently not implemented.
++<<<<<<< HEAD
 +    EXPECT_THROW(this->collection.begin(), isc::NotImplemented);
 +    EXPECT_THROW(this->collection.end(), isc::NotImplemented);
 +}
 +
 +typedef RRsetCollectionTest<MockAccessor> MockRRsetCollectionTest;
++=======
+     EXPECT_THROW(this->collection->begin(), isc::NotImplemented);
+     EXPECT_THROW(this->collection->end(), isc::NotImplemented);
+ }
+ class MockRRsetCollectionTest : public DatabaseClientTest<MockAccessor> {
+ public:
+     MockRRsetCollectionTest() :
+         DatabaseClientTest<MockAccessor>(),
+         updater(this->client_->getUpdater(this->zname_, false)),
+         collection(updater->getRRsetCollection())
+     {}
+     ZoneUpdaterPtr updater;
+     RRsetCollectionPtr collection;
+ };
++>>>>>>> trac2438-0
  
  TEST_F(MockRRsetCollectionTest, findError) {
      // A test using the MockAccessor for checking that FindError is
      // The "dsexception.example.org." name is rigged by the MockAccessor
      // to throw a DataSourceError.
      EXPECT_THROW({
++<<<<<<< HEAD
 +        this->collection.find(Name("dsexception.example.org"), this->qclass_,
 +                              RRType::A());
 +    }, RRsetCollectionError);
 +}
 +
 +TYPED_TEST_CASE(RRsetCollectionAndUpdaterTest, TestAccessorTypes);
 +
 +// This test fixture is templated so that we can share (most of) the test
 +// cases with different types of data sources.  Note that in test cases
 +// we need to use 'this' to refer to member variables of the test class.
 +template <typename ACCESSOR_TYPE>
 +class RRsetCollectionAndUpdaterTest : public DatabaseClientTest<ACCESSOR_TYPE> {
 +public:
 +    RRsetCollectionAndUpdaterTest() :
 +        DatabaseClientTest<ACCESSOR_TYPE>(),
 +        updater_(this->client_->getUpdater(this->zname_, false))
 +    {}
 +
 +    ZoneUpdaterPtr updater_;
 +};
 +
 +// Test that using addRRset() or deleteRRset() on the ZoneUpdater throws
 +// after an RRsetCollection is created.
 +TYPED_TEST(RRsetCollectionAndUpdaterTest, updateThrows) {
 +    // 1. Addition test
 +
 +    // addRRset() must not throw.
 +    this->updater_->addRRset(*this->rrset_);
 +
 +    // Now setup a new updater and call getRRsetCollection() on it.
 +    this->updater_.reset();
 +    this->updater_ = this->client_->getUpdater(this->zname_, false);
 +    (void) this->updater_->getRRsetCollection();
 +
 +    // addRRset() must throw isc::InvalidOperation here.
 +    EXPECT_THROW(this->updater_->addRRset(*this->rrset_),
 +                 isc::InvalidOperation);
 +
 +    // 2. Deletion test
 +
 +    // deleteRRset() must not throw.
 +    this->updater_.reset();
 +    this->updater_ = this->client_->getUpdater(this->zname_, false);
 +    this->updater_->addRRset(*this->rrset_);
 +    this->updater_->deleteRRset(*this->rrset_);
 +
 +    // Now setup a new updater and call getRRsetCollection() on it.
 +    this->updater_.reset();
 +    this->updater_ = this->client_->getUpdater(this->zname_, false);
 +    this->updater_->addRRset(*this->rrset_);
 +    (void) this->updater_->getRRsetCollection();
 +
 +    // deleteRRset() must throw isc::InvalidOperation here.
 +    EXPECT_THROW(this->updater_->deleteRRset(*this->rrset_),
 +                 isc::InvalidOperation);
 +}
 +
 +// Test that using an RRsetCollection after calling commit() on the
 +// ZoneUpdater throws, as the RRsetCollection is disabled.
 +TYPED_TEST(RRsetCollectionAndUpdaterTest, useAfterCommitThrows) {
 +     isc::datasrc::RRsetCollectionBase& collection =
 +         this->updater_->getRRsetCollection();
 +
 +     // find() must not throw here.
 +     collection.find(Name("foo.wild.example.org"), this->qclass_, RRType::A());
 +
 +     this->updater_->commit();
 +
 +     // find() must throw RRsetCollectionError here, as the
 +     // RRsetCollection is disabled.
 +     EXPECT_THROW(collection.find(Name("foo.wild.example.org"),
 +                                  this->qclass_, RRType::A()),
 +                  RRsetCollectionError);
++=======
+         this->collection->find(Name("dsexception.example.org"), this->qclass_,
+                                RRType::A());
+     }, RRsetCollectionBase::FindError);
++>>>>>>> trac2438-0
  }
  
  }
Simple merge
Simple merge