Example #1
0
void DNSTest::test_equals(const DNS &dns1, const DNS &dns2) {
    EXPECT_EQ(dns1.id(), dns2.id());
    EXPECT_EQ(dns1.type(), dns2.type());
    EXPECT_EQ(dns1.opcode(), dns2.opcode());
    EXPECT_EQ(dns1.authoritative_answer(), dns2.authoritative_answer());
    EXPECT_EQ(dns1.truncated(), dns2.truncated());
    EXPECT_EQ(dns1.recursion_desired(), dns2.recursion_desired());
    EXPECT_EQ(dns1.recursion_available(), dns2.recursion_available());
    EXPECT_EQ(dns1.z(), dns2.z());
    EXPECT_EQ(dns1.authenticated_data(), dns2.authenticated_data());
    EXPECT_EQ(dns1.checking_disabled(), dns2.checking_disabled());
    EXPECT_EQ(dns1.rcode(), dns2.rcode());
    EXPECT_EQ(dns1.questions_count(), dns2.questions_count());
    EXPECT_EQ(dns1.answers_count(), dns2.answers_count());
    EXPECT_EQ(dns1.authority_count(), dns2.authority_count());
    EXPECT_EQ(dns1.additional_count(), dns2.additional_count());
    EXPECT_EQ(dns1.pdu_type(), dns2.pdu_type());
    EXPECT_EQ(dns1.header_size(), dns2.header_size());
    EXPECT_EQ(bool(dns1.inner_pdu()), bool(dns2.inner_pdu()));
}
Example #2
0
TEST_F(DNSTest, Authority) {
    DNS dns;
    
    const char *domain = "carlos.example.com";
    dns.add_authority(
        DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762)
    );
    dns.add_authority(
        DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762)
    );
    
    ASSERT_EQ(dns.authority_count(), 2);
    
    DNS::resources_type resources = dns.authority();
    EXPECT_EQ(2, resources.size());
    for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) {
        EXPECT_EQ("www.example.com", it->dname());
        EXPECT_EQ(it->type(), DNS::CNAME);
        EXPECT_EQ(it->ttl(), 0x762U);
        EXPECT_EQ(it->data(), domain);
        EXPECT_EQ(it->query_class(), DNS::IN);
    }
}