summaryrefslogtreecommitdiff
path: root/test/ares-test-parse-a.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/ares-test-parse-a.cc')
-rw-r--r--test/ares-test-parse-a.cc26
1 files changed, 5 insertions, 21 deletions
diff --git a/test/ares-test-parse-a.cc b/test/ares-test-parse-a.cc
index 7f6a987..77d9591 100644
--- a/test/ares-test-parse-a.cc
+++ b/test/ares-test-parse-a.cc
@@ -11,14 +11,13 @@ TEST_F(LibraryTest, ParseAReplyOK) {
DNSPacket pkt;
pkt.set_qid(0x1234).set_response().set_aa()
.add_question(new DNSQuestion("example.com", ns_t_a))
- .add_answer(new DNSARR("example.com", 0x01020304, {2,3,4,5}))
- .add_answer(new DNSAaaaRR("example.com", 0x01020304, {0,0,0,0,0,0,0,0,0,0,0,0,2,3,4,5}));
+ .add_answer(new DNSARR("example.com", 0x01020304, {2,3,4,5}));
std::vector<byte> data = {
0x12, 0x34, // qid
0x84, // response + query + AA + not-TC + not-RD
0x00, // not-RA + not-Z + not-AD + not-CD + rc=NoError
0x00, 0x01, // num questions
- 0x00, 0x02, // num answer RRs
+ 0x00, 0x01, // num answer RRs
0x00, 0x00, // num authority RRs
0x00, 0x00, // num additional RRs
// Question
@@ -36,15 +35,6 @@ TEST_F(LibraryTest, ParseAReplyOK) {
0x01, 0x02, 0x03, 0x04, // TTL
0x00, 0x04, // rdata length
0x02, 0x03, 0x04, 0x05,
- // Answer 2
- 0x07, 'e', 'x', 'a', 'm', 'p', 'l', 'e',
- 0x03, 'c', 'o', 'm',
- 0x00,
- 0x00, 0x1c, // RR type
- 0x00, 0x01, // class IN
- 0x01, 0x02, 0x03, 0x04, // TTL
- 0x00, 0x10, // rdata length
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x04, 0x05,
};
EXPECT_EQ(data, pkt.data());
struct hostent *host = nullptr;
@@ -78,7 +68,7 @@ TEST_F(LibraryTest, ParseMalformedAReply) {
0x84, // [2] response + query + AA + not-TC + not-RD
0x00, // [3] not-RA + not-Z + not-AD + not-CD + rc=NoError
0x00, 0x01, // [4:6) num questions
- 0x00, 0x02, // [6:8) num answer RRs
+ 0x00, 0x01, // [6:8) num answer RRs
0x00, 0x00, // [8:10) num authority RRs
0x00, 0x00, // [10:12) num additional RRs
// Question
@@ -131,16 +121,10 @@ TEST_F(LibraryTest, ParseAReplyNoData) {
// Again but with a CNAME.
pkt.add_answer(new DNSCnameRR("example.com", 200, "c.example.com"));
- data = pkt.data();
- // Expect success as per https://github.com/c-ares/c-ares/commit/2c63440127feed70ccefb148b8f938a2df6c15f8
- EXPECT_EQ(ARES_SUCCESS, ares_parse_a_reply(data.data(), data.size(),
+ EXPECT_EQ(ARES_ENODATA, ares_parse_a_reply(data.data(), data.size(),
&host, info, &count));
EXPECT_EQ(0, count);
- EXPECT_NE(nullptr, host);
- std::stringstream ss;
- ss << HostEnt(host);
- EXPECT_EQ("{'c.example.com' aliases=[example.com] addrs=[]}", ss.str());
- ares_free_hostent(host);
+ EXPECT_EQ(nullptr, host);
}
TEST_F(LibraryTest, ParseAReplyVariantA) {