Browse Source

Improve the test

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac458@4072 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner 14 years ago
parent
commit
cabe7cdd3b
1 changed files with 18 additions and 0 deletions
  1. 18 0
      src/bin/auth/tests/query_unittest.cc

+ 18 - 0
src/bin/auth/tests/query_unittest.cc

@@ -49,6 +49,8 @@ public:
     {
         mx_rrset_->addRdata(isc::dns::rdata::generic::MX(10,
             Name("www.example.com")));
+        mx_rrset_->addRdata(isc::dns::rdata::generic::MX(20,
+            Name("mailer.example.org")));
     }
     virtual const isc::dns::Name& getOrigin() const;
     virtual const isc::dns::RRClass& getClass() const;
@@ -147,6 +149,12 @@ TEST_F(QueryTest, noMatchZone) {
     EXPECT_EQ(Rcode::REFUSED(), response.getRcode());
 }
 
+/*
+ * Test MX additional processing.
+ *
+ * The MX RRset has two RRs, one pointing to a known domain with
+ * A record, other to unknown out of zone one.
+ */
 TEST_F(QueryTest, MX) {
     memory_datasrc.addZone(ZonePtr(new MockZone()));
     Name qname("mx.example.com");
@@ -157,6 +165,16 @@ TEST_F(QueryTest, MX) {
         Name("mx.example.com"), RRClass::IN(), RRType::MX()));
     EXPECT_TRUE(response.hasRRset(Message::SECTION_ADDITIONAL,
         Name("www.example.com"), RRClass::IN(), RRType::A()));
+    // In fact, the MX RRset mentions two names, but we don't know anything
+    // about the other, so we have just 1 additional rrset
+    size_t additional_count(0);
+    for (SectionIterator<RRsetPtr> ai(response.beginSection(
+        Message::SECTION_ANSWER)); ai != response.endSection(
+        Message::SECTION_ANSWER); ++ ai)
+    {
+        additional_count ++;
+    }
+    EXPECT_EQ(1, additional_count);
 }
 
 }