diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-24 09:54:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-24 09:54:44 +0000 |
commit | 836b47cb7e99a977c5a23b059ca1d0b5065d310e (patch) | |
tree | 1604da8f482d02effa033c94a84be42bc0c848c3 /fluent-bit/lib/c-ares-1.19.1/test/ares-test-parse-soa-any.cc | |
parent | Releasing debian version 1.44.3-2. (diff) | |
download | netdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.tar.xz netdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.zip |
Merging upstream version 1.46.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'fluent-bit/lib/c-ares-1.19.1/test/ares-test-parse-soa-any.cc')
-rw-r--r-- | fluent-bit/lib/c-ares-1.19.1/test/ares-test-parse-soa-any.cc | 111 |
1 files changed, 0 insertions, 111 deletions
diff --git a/fluent-bit/lib/c-ares-1.19.1/test/ares-test-parse-soa-any.cc b/fluent-bit/lib/c-ares-1.19.1/test/ares-test-parse-soa-any.cc deleted file mode 100644 index 700073c5c..000000000 --- a/fluent-bit/lib/c-ares-1.19.1/test/ares-test-parse-soa-any.cc +++ /dev/null @@ -1,111 +0,0 @@ -#include "ares-test.h" -#include "dns-proto.h" - -#include <sstream> -#include <vector> - -namespace ares { -namespace test { - -TEST_F(LibraryTest, ParseSoaAnyReplyOK) { - DNSPacket pkt; - pkt.set_qid(0x1234).set_response().set_aa() - .add_question(new DNSQuestion("example.com", T_ANY))\ - .add_answer(new DNSARR("example.com", 0x01020304, {2,3,4,5})) - .add_answer(new DNSMxRR("example.com", 100, 100, "mx1.example.com")) - .add_answer(new DNSMxRR("example.com", 100, 200, "mx2.example.com")) - .add_answer(new DNSSoaRR("example.com", 100, - "soa1.example.com", "fred.example.com", - 1, 2, 3, 4, 5)); - std::vector<byte> data = pkt.data(); - - struct ares_soa_reply* soa = nullptr; - EXPECT_EQ(ARES_SUCCESS, ares_parse_soa_reply(data.data(), data.size(), &soa)); - ASSERT_NE(nullptr, soa); - EXPECT_EQ("soa1.example.com", std::string(soa->nsname)); - EXPECT_EQ("fred.example.com", std::string(soa->hostmaster)); - EXPECT_EQ(1, soa->serial); - EXPECT_EQ(2, soa->refresh); - EXPECT_EQ(3, soa->retry); - EXPECT_EQ(4, soa->expire); - EXPECT_EQ(5, soa->minttl); - ares_free_data(soa); -} - -TEST_F(LibraryTest, ParseSoaAnyReplyErrors) { - DNSPacket pkt; - pkt.set_qid(0x1234).set_response().set_aa() - .add_question(new DNSQuestion("example.com", T_ANY)) - .add_answer(new DNSSoaRR("example.com", 100, - "soa1.example.com", "fred.example.com", - 1, 2, 3, 4, 5)); - std::vector<byte> data; - struct ares_soa_reply* soa = nullptr; - - // No question. - pkt.questions_.clear(); - data = pkt.data(); - EXPECT_EQ(ARES_EBADRESP, ares_parse_soa_reply(data.data(), data.size(), &soa)); - pkt.add_question(new DNSQuestion("example.com", T_ANY)); - -#ifdef DISABLED - // Question != answer - pkt.questions_.clear(); - pkt.add_question(new DNSQuestion("Axample.com", T_ANY)); - data = pkt.data(); - EXPECT_EQ(ARES_EBADRESP, ares_parse_soa_reply(data.data(), data.size(), &soa)); - pkt.questions_.clear(); - pkt.add_question(new DNSQuestion("example.com", T_ANY)); -#endif - - // Two questions - pkt.add_question(new DNSQuestion("example.com", T_ANY)); - data = pkt.data(); - EXPECT_EQ(ARES_EBADRESP, ares_parse_soa_reply(data.data(), data.size(), &soa)); - pkt.questions_.clear(); - pkt.add_question(new DNSQuestion("example.com", T_ANY)); - - // 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_EBADRESP, ares_parse_soa_reply(data.data(), data.size(), &soa)); - pkt.answers_.clear(); - pkt.add_answer(new DNSSoaRR("example.com", 100, - "soa1.example.com", "fred.example.com", - 1, 2, 3, 4, 5)); - - // No answer. - pkt.answers_.clear(); - data = pkt.data(); - EXPECT_EQ(ARES_EBADRESP, ares_parse_soa_reply(data.data(), data.size(), &soa)); - pkt.add_answer(new DNSSoaRR("example.com", 100, - "soa1.example.com", "fred.example.com", - 1, 2, 3, 4, 5)); - - // Truncated packets. - data = pkt.data(); - for (size_t len = 1; len < data.size(); len++) { - EXPECT_EQ(ARES_EBADRESP, ares_parse_soa_reply(data.data(), len, &soa)); - } -} - -TEST_F(LibraryTest, ParseSoaAnyReplyAllocFail) { - DNSPacket pkt; - pkt.set_qid(0x1234).set_response().set_aa() - .add_question(new DNSQuestion("example.com", T_ANY)) - .add_answer(new DNSSoaRR("example.com", 100, - "soa1.example.com", "fred.example.com", - 1, 2, 3, 4, 5)); - std::vector<byte> data = pkt.data(); - struct ares_soa_reply* soa = nullptr; - - for (int ii = 1; ii <= 5; ii++) { - ClearFails(); - SetAllocFail(ii); - EXPECT_EQ(ARES_ENOMEM, ares_parse_soa_reply(data.data(), data.size(), &soa)) << ii; - } -} - -} // namespace test -} // namespace ares |