1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-27 04:11:35 +01:00

Fixed bug in DNS triggered when adding two records for the same domain name.

This commit is contained in:
Matias Fontanini
2012-11-20 16:10:24 -03:00
parent 5fd892c77e
commit d0048e3aef
3 changed files with 47 additions and 11 deletions

View File

@@ -221,4 +221,17 @@ TEST_F(DNSTest, Answers) {
}
}
TEST_F(DNSTest, AnswersWithSameName) {
DNS dns;
dns.add_answer("www.example.com", DNS::make_info(DNS::A, DNS::IN, 0x762), IPv4Address("127.0.0.1"));
dns.add_answer("www.example.com", DNS::make_info(DNS::A, DNS::IN, 0x762), IPv4Address("127.0.0.2"));
ASSERT_EQ(dns.answers_count(), 2);
DNS::resources_type resources = dns.answers();
for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) {
EXPECT_TRUE(it->data() == "127.0.0.1" || it->data() == "127.0.0.2");
EXPECT_EQ(it->dname(), "www.example.com");
EXPECT_EQ(it->type(), DNS::A);
EXPECT_EQ(it->ttl(), 0x762);
EXPECT_EQ(it->query_class(), DNS::IN);
}
}