diff options
author | Mukund Sivaraman <muks@isc.org> | 2012-08-12 22:43:02 +0200 |
---|---|---|
committer | Mukund Sivaraman <muks@isc.org> | 2012-08-12 22:43:19 +0200 |
commit | 8e4054a5fc964eeb9dc84a9ec2400a5c1eace19e (patch) | |
tree | d633f0f5b03cf24381e89f66394fe598b6303672 /src/lib/dns/tests | |
parent | [2164] Add another testcase when RRSIGs are removed (diff) | |
download | kea-8e4054a5fc964eeb9dc84a9ec2400a5c1eace19e.tar.xz kea-8e4054a5fc964eeb9dc84a9ec2400a5c1eace19e.zip |
[2164] Add toWire() test for Message class with RRSIG records
Diffstat (limited to 'src/lib/dns/tests')
-rw-r--r-- | src/lib/dns/tests/message_unittest.cc | 39 | ||||
-rw-r--r-- | src/lib/dns/tests/testdata/Makefile.am | 2 | ||||
-rw-r--r-- | src/lib/dns/tests/testdata/message_toWire6 | 48 |
3 files changed, 88 insertions, 1 deletions
diff --git a/src/lib/dns/tests/message_unittest.cc b/src/lib/dns/tests/message_unittest.cc index f30a2acf12..2291fd3e7c 100644 --- a/src/lib/dns/tests/message_unittest.cc +++ b/src/lib/dns/tests/message_unittest.cc @@ -743,6 +743,45 @@ TEST_F(MessageTest, toWire) { renderer.getLength(), &data[0], data.size()); } +TEST_F(MessageTest, toWireSigned) { + message_render.setQid(0x75c1); + message_render.setOpcode(Opcode::QUERY()); + message_render.setRcode(Rcode::NOERROR()); + message_render.setHeaderFlag(Message::HEADERFLAG_QR, true); + message_render.setHeaderFlag(Message::HEADERFLAG_RD, true); + message_render.setHeaderFlag(Message::HEADERFLAG_AA, true); + message_render.addQuestion(Question(Name("test.example.com"), RRClass::IN(), + RRType::A())); + + rrset_rrsig = RRsetPtr(new RRset(test_name, RRClass::IN(), + RRType::RRSIG(), RRTTL(3600))); + // one signature algorithm (5 = RSA/SHA-1) + rrset_rrsig->addRdata(generic::RRSIG("A 5 3 3600 " + "20000101000000 20000201000000 " + "12345 example.com. FAKEFAKEFAKE")); + // another signature algorithm (3 = DSA/SHA-1) + rrset_rrsig->addRdata(generic::RRSIG("A 3 3 3600 " + "20000101000000 20000201000000 " + "12345 example.com. FAKEFAKEFAKE")); + rrset_a->addRRsig(rrset_rrsig); + + const RRset* rr = dynamic_cast<const RRset*>(rrset_a.get()); + EXPECT_EQ(2, rr->getSIGRdataCount()); + + message_render.addRRset(Message::SECTION_ANSWER, rrset_a, true); + + EXPECT_EQ(1, message_render.getRRCount(Message::SECTION_QUESTION)); + EXPECT_EQ(4, message_render.getRRCount(Message::SECTION_ANSWER)); + EXPECT_EQ(0, message_render.getRRCount(Message::SECTION_AUTHORITY)); + EXPECT_EQ(0, message_render.getRRCount(Message::SECTION_ADDITIONAL)); + + message_render.toWire(renderer); + vector<unsigned char> data; + UnitTestUtil::readWireData("message_toWire6", data); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), &data[0], data.size()); +} + TEST_F(MessageTest, toWireInParseMode) { // toWire() isn't allowed in the parse mode. EXPECT_THROW(message_parse.toWire(renderer), InvalidMessageOperation); diff --git a/src/lib/dns/tests/testdata/Makefile.am b/src/lib/dns/tests/testdata/Makefile.am index 93528339a1..30fc3d7e54 100644 --- a/src/lib/dns/tests/testdata/Makefile.am +++ b/src/lib/dns/tests/testdata/Makefile.am @@ -86,7 +86,7 @@ EXTRA_DIST += message_fromWire17.spec message_fromWire18.spec EXTRA_DIST += message_fromWire19.spec message_fromWire20.spec EXTRA_DIST += message_fromWire21.spec message_fromWire22.spec EXTRA_DIST += message_toWire1 message_toWire2.spec message_toWire3.spec -EXTRA_DIST += message_toWire4.spec message_toWire5.spec +EXTRA_DIST += message_toWire6 EXTRA_DIST += message_toText1.txt message_toText1.spec EXTRA_DIST += message_toText2.txt message_toText2.spec EXTRA_DIST += message_toText3.txt message_toText3.spec diff --git a/src/lib/dns/tests/testdata/message_toWire6 b/src/lib/dns/tests/testdata/message_toWire6 new file mode 100644 index 0000000000..00185c9d38 --- /dev/null +++ b/src/lib/dns/tests/testdata/message_toWire6 @@ -0,0 +1,48 @@ +# +# A simple DNS query message (with a signed response) +# ID = 0x75c1 +# QR=1 (response), Opcode=0, AA=1, RD=1 (other fields are 0) +# QDCOUNT=1, ANCOUNT=2, other COUNTS=0 +# Question: test.example.com. IN A +# Answer: +# test.example.com. 3600 IN A 192.0.2.1 +# test.example.com. 7200 IN A 192.0.2.2 +# +75c1 8500 +0001 0004 0000 0000 +#(4) t e s t (7) e x a m p l e (3) c o m . + 04 74 65 73 74 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 +0001 0001 +# same name, fully compressed +c0 0c +# TTL=3600, A, IN, RDLENGTH=4, RDATA +0001 0001 00000e10 0004 c0 00 02 01 +# mostly same, with the slight difference in RDATA +c0 0c +0001 0001 00000e10 0004 c0 00 02 02 + +# signature 1 + +# same name +c0 0c +# RRSIG, IN, TTL=3600, RDLENGTH=0x28 TYPE_COV=A ALGO=5 (RSA/SHA-1) LABELS=3 ORIG_TTL=3600 +002e 0001 00000e10 0028 0001 05 03 00000e10 +# SIG_EXPIRY=20000101000000 SIG_INCEP=20000201000000 KEY_ID=12345 +386d4380 38962200 3039 +#(7) e x a m p l e (3) c o m . + 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 +# FAKEFAKEFAKE +14 02 84 14 02 84 14 02 84 + +# signature 2 + +# same name +c0 0c +# RRSIG, IN, TTL=3600, RDLENGTH=0x28 TYPE_COV=A ALGO=3 (DSA/SHA-1) LABELS=3 ORIG_TTL=3600 +002e 0001 00000e10 0028 0001 03 03 00000e10 +# SIG_EXPIRY=20000101000000 SIG_INCEP=20000201000000 KEY_ID=12345 +386d4380 38962200 3039 +#(7) e x a m p l e (3) c o m . + 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 +# FAKEFAKEFAKE +14 02 84 14 02 84 14 02 84 |