Browse Source

[trac813] anoter Message::toText() test: testing a message with EDNS
(not related to TSIG)

JINMEI Tatuya 14 years ago
parent
commit
9e8b5ec423

+ 12 - 0
src/lib/dns/tests/message_unittest.cc

@@ -681,10 +681,22 @@ TEST_F(MessageTest, toWireWithoutRcode) {
 }
 
 TEST_F(MessageTest, toText) {
+    // Check toText() output for a typical DNS response with records in
+    // all sections
     ifstream ifs;
     unittests::openTestData("message_toText1.txt", ifs);
     factoryFromFile(message_parse, "message_toText1.wire");
     unittests::matchTextData(ifs, message_parse.toText());
+
+    // Another example with EDNS.  The expected data was slightly modified
+    // from the dig output (other than replacing tabs with a space): adding
+    // a newline after the "OPT PSEUDOSECTION".  This is an intentional change
+    // in our version for better readability.
+    ifs.close();
+    message_parse.clear(Message::PARSE);
+    unittests::openTestData("message_toText2.txt", ifs);
+    factoryFromFile(message_parse, "message_toText2.wire");
+    unittests::matchTextData(ifs, message_parse.toText());
 }
 
 TEST_F(MessageTest, toTextWithoutOpcode) {

+ 2 - 1
src/lib/dns/tests/testdata/Makefile.am

@@ -7,7 +7,7 @@ BUILT_SOURCES += message_fromWire12.wire message_fromWire13.wire
 BUILT_SOURCES += message_fromWire14.wire message_fromWire15.wire
 BUILT_SOURCES += message_fromWire16.wire
 BUILT_SOURCES += message_toWire2.wire message_toWire3.wire
-BUILT_SOURCES += message_toText1.wire
+BUILT_SOURCES += message_toText1.wire message_toText2.wire
 BUILT_SOURCES += name_toWire5.wire name_toWire6.wire
 BUILT_SOURCES += rdatafields1.wire rdatafields2.wire rdatafields3.wire
 BUILT_SOURCES += rdatafields4.wire rdatafields5.wire rdatafields6.wire
@@ -56,6 +56,7 @@ EXTRA_DIST += message_fromWire13.spec message_fromWire14.spec
 EXTRA_DIST += message_fromWire15.spec message_fromWire16.spec
 EXTRA_DIST += message_toWire1 message_toWire2.spec message_toWire3.spec
 EXTRA_DIST += message_toText1.txt message_toText1.spec
+EXTRA_DIST += message_toText2.txt message_toText2.spec
 EXTRA_DIST += name_fromWire1 name_fromWire2 name_fromWire3_1 name_fromWire3_2
 EXTRA_DIST += name_fromWire4 name_fromWire6 name_fromWire7 name_fromWire8
 EXTRA_DIST += name_fromWire9 name_fromWire10 name_fromWire11 name_fromWire12

+ 14 - 0
src/lib/dns/tests/testdata/message_toText2.spec

@@ -0,0 +1,14 @@
+#
+# A standard DNS message with EDNS (taken from an invokation of dig)
+#
+
+[custom]
+sections: header:question:edns
+[header]
+id: 45981
+qr: 1
+rcode: refused
+arcount: 1
+[question]
+[edns]
+do: 1