Browse Source

[2108] Add tests for out of zone names

Mukund Sivaraman 12 years ago
parent
commit
5a70502ad2

+ 23 - 0
src/lib/datasrc/memory/tests/memory_client_unittest.cc

@@ -281,6 +281,15 @@ TEST_F(MemoryClientTest, loadMultipleNSEC3PARAMThrows) {
     // Teardown checks for memory segment leaks
 }
 
+TEST_F(MemoryClientTest, loadOutOfZoneThrows) {
+    // Out of zone names should throw.
+    EXPECT_THROW(client_->load(Name("example.org"),
+                               TEST_DATA_DIR
+                               "/example.org-out-of-zone.zone"),
+                 MasterLoadError);
+    // Teardown checks for memory segment leaks
+}
+
 TEST_F(MemoryClientTest, loadRRSIGFollowsNothing) {
     EXPECT_THROW(client_->load(Name("example.org"),
                                TEST_DATA_DIR
@@ -389,6 +398,20 @@ TEST_F(MemoryClientTest, addRRsetToNonExistentZoneThrows) {
     EXPECT_THROW(client_->add(Name("example.org"), rrset_a), DataSourceError);
 }
 
+TEST_F(MemoryClientTest, addOutOfZoneThrows) {
+    // Out of zone names should throw.
+    client_->load(Name("example.org"),
+                  TEST_DATA_DIR "/example.org-empty.zone");
+
+    RRsetPtr rrset_a(new RRset(Name("a.example.com"),
+                               RRClass::IN(), RRType::A(), RRTTL(300)));
+    rrset_a->addRdata(rdata::in::A("192.0.2.1"));
+
+    EXPECT_THROW(client_->add(Name("example.org"), rrset_a),
+                 OutOfZone);
+    // Teardown checks for memory segment leaks
+}
+
 TEST_F(MemoryClientTest, addNullRRsetThrows) {
     client_->load(Name("example.org"),
                   TEST_DATA_DIR "/example.org-rrsigs.zone");

+ 1 - 0
src/lib/datasrc/memory/tests/testdata/Makefile.am

@@ -17,3 +17,4 @@ EXTRA_DIST += example.org-multiple-nsec3.zone
 EXTRA_DIST += example.org-multiple-nsec3param.zone
 EXTRA_DIST += example.org-nsec3-signed.zone
 EXTRA_DIST += example.org-nsec3-signed-no-param.zone
+EXTRA_DIST += example.org-out-of-zone.zone

+ 5 - 0
src/lib/datasrc/memory/tests/testdata/example.org-out-of-zone.zone

@@ -0,0 +1,5 @@
+;; test zone file used for ZoneFinderContext tests.
+;; RRSIGs are (obviouslly) faked ones for testing.
+
+example.org. 3600 IN SOA	ns1.example.org. bugs.x.w.example.org. 75 3600 300 3600000 3600
+a.example.com.	  		      3600 IN A	 	192.168.0.1