summaryrefslogtreecommitdiff
path: root/test/ares-test-parse-naptr.cc
diff options
context:
space:
mode:
authorYu Jiung <jiung.yu@samsung.com>2016-11-09 02:30:42 (GMT)
committerYu Jiung <jiung.yu@samsung.com>2016-11-09 02:30:42 (GMT)
commitf943ec081f7860198d407bfd1199058f841f34da (patch)
tree608dc46a27cd512a2e1fcbfe1f0e2757f3a61d53 /test/ares-test-parse-naptr.cc
parent04b1a8c051547b221a3bdd74d68ab02df3e3f752 (diff)
downloadc-ares-f943ec081f7860198d407bfd1199058f841f34da.zip
c-ares-f943ec081f7860198d407bfd1199058f841f34da.tar.gz
c-ares-f943ec081f7860198d407bfd1199058f841f34da.tar.bz2
Remove unused files and update spec file versionrefs/changes/28/96428/1
Change-Id: I55aba1ebcb3cf685b5f61f3608b0601c1f210290
Diffstat (limited to 'test/ares-test-parse-naptr.cc')
-rw-r--r--test/ares-test-parse-naptr.cc119
1 files changed, 0 insertions, 119 deletions
diff --git a/test/ares-test-parse-naptr.cc b/test/ares-test-parse-naptr.cc
deleted file mode 100644
index 40013cb..0000000
--- a/test/ares-test-parse-naptr.cc
+++ /dev/null
@@ -1,119 +0,0 @@
-#include "ares-test.h"
-#include "dns-proto.h"
-
-#include <sstream>
-#include <vector>
-
-namespace ares {
-namespace test {
-
-TEST_F(LibraryTest, ParseNaptrReplyOK) {
- DNSPacket pkt;
- pkt.set_qid(0x1234).set_response().set_aa()
- .add_question(new DNSQuestion("example.com", ns_t_naptr))
- .add_answer(new DNSNaptrRR("example.com", 100,
- 10, 20, "SP", "service", "regexp", "replace"))
- .add_answer(new DNSNaptrRR("example.com", 0x0010,
- 11, 21, "SP", "service2", "regexp2", "replace2"));
- std::vector<byte> data = pkt.data();
-
- struct ares_naptr_reply* naptr = nullptr;
- EXPECT_EQ(ARES_SUCCESS, ares_parse_naptr_reply(data.data(), data.size(), &naptr));
- ASSERT_NE(nullptr, naptr);
- EXPECT_EQ("SP", std::string((char*)naptr->flags));
- EXPECT_EQ("service", std::string((char*)naptr->service));
- EXPECT_EQ("regexp", std::string((char*)naptr->regexp));
- EXPECT_EQ("replace", std::string((char*)naptr->replacement));
- EXPECT_EQ(10, naptr->order);
- EXPECT_EQ(20, naptr->preference);
-
- struct ares_naptr_reply* naptr2 = naptr->next;
- ASSERT_NE(nullptr, naptr2);
- EXPECT_EQ("SP", std::string((char*)naptr2->flags));
- EXPECT_EQ("service2", std::string((char*)naptr2->service));
- EXPECT_EQ("regexp2", std::string((char*)naptr2->regexp));
- EXPECT_EQ("replace2", std::string((char*)naptr2->replacement));
- EXPECT_EQ(11, naptr2->order);
- EXPECT_EQ(21, naptr2->preference);
- EXPECT_EQ(nullptr, naptr2->next);
-
- ares_free_data(naptr);
-}
-
-TEST_F(LibraryTest, ParseNaptrReplyErrors) {
- DNSPacket pkt;
- pkt.set_qid(0x1234).set_response().set_aa()
- .add_question(new DNSQuestion("example.com", ns_t_naptr))
- .add_answer(new DNSNaptrRR("example.com", 100,
- 10, 20, "SP", "service", "regexp", "replace"));
- std::vector<byte> data;
- struct ares_naptr_reply* naptr = nullptr;
-
- // No question.
- pkt.questions_.clear();
- data = pkt.data();
- EXPECT_EQ(ARES_EBADRESP, ares_parse_naptr_reply(data.data(), data.size(), &naptr));
- pkt.add_question(new DNSQuestion("example.com", ns_t_naptr));
-
-#ifdef DISABLED
- // Question != answer
- pkt.questions_.clear();
- pkt.add_question(new DNSQuestion("Axample.com", ns_t_naptr));
- data = pkt.data();
- EXPECT_EQ(ARES_ENODATA, ares_parse_naptr_reply(data.data(), data.size(), &naptr));
- pkt.questions_.clear();
- pkt.add_question(new DNSQuestion("example.com", ns_t_naptr));
-#endif
-
- // Two questions
- pkt.add_question(new DNSQuestion("example.com", ns_t_naptr));
- data = pkt.data();
- EXPECT_EQ(ARES_EBADRESP, ares_parse_naptr_reply(data.data(), data.size(), &naptr));
- pkt.questions_.clear();
- pkt.add_question(new DNSQuestion("example.com", ns_t_naptr));
-
- // Wrong sort of answer.
- pkt.answers_.clear();
- pkt.add_answer(new DNSMxRR("example.com", 100, 100, "mx1.example.com"));
- data = pkt.data();
- EXPECT_EQ(ARES_SUCCESS, ares_parse_naptr_reply(data.data(), data.size(), &naptr));
- EXPECT_EQ(nullptr, naptr);
- pkt.answers_.clear();
- pkt.add_answer(new DNSNaptrRR("example.com", 100,
- 10, 20, "SP", "service", "regexp", "replace"));
-
- // No answer.
- pkt.answers_.clear();
- data = pkt.data();
- EXPECT_EQ(ARES_ENODATA, ares_parse_naptr_reply(data.data(), data.size(), &naptr));
- pkt.add_answer(new DNSNaptrRR("example.com", 100,
- 10, 20, "SP", "service", "regexp", "replace"));
-
- // Truncated packets.
- data = pkt.data();
- for (size_t len = 1; len < data.size(); len++) {
- int rc = ares_parse_naptr_reply(data.data(), len, &naptr);
- EXPECT_TRUE(rc == ARES_EBADRESP || rc == ARES_EBADNAME);
- }
-}
-
-TEST_F(LibraryTest, ParseNaptrReplyAllocFail) {
- DNSPacket pkt;
- pkt.set_qid(0x1234).set_response().set_aa()
- .add_question(new DNSQuestion("example.com", ns_t_naptr))
- .add_answer(new DNSNaptrRR("example.com", 100,
- 10, 20, "SP", "service", "regexp", "replace"))
- .add_answer(new DNSNaptrRR("example.com", 0x0010,
- 11, 21, "SP", "service2", "regexp2", "replace2"));
- std::vector<byte> data = pkt.data();
- struct ares_naptr_reply* naptr = nullptr;
-
- for (int ii = 1; ii <= 13; ii++) {
- ClearFails();
- SetAllocFail(ii);
- EXPECT_EQ(ARES_ENOMEM, ares_parse_naptr_reply(data.data(), data.size(), &naptr));
- }
-}
-
-} // namespace test
-} // namespace ares