From: Otto Date: Mon, 25 Jan 2021 15:11:21 +0000 (+0100) Subject: Basic test for negcache. X-Git-Tag: dnsdist-1.6.0-alpha1~9^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=82b0db0db703dfc8a61fae2a2fe2a5d89f6d9801;p=thirdparty%2Fpdns.git Basic test for negcache. This one seems to be safe from code inspection. All timestamps are time_t. --- diff --git a/pdns/recursordist/test-negcache_cc.cc b/pdns/recursordist/test-negcache_cc.cc index 8c3b38b625..5ea1ad79ba 100644 --- a/pdns/recursordist/test-negcache_cc.cc +++ b/pdns/recursordist/test-negcache_cc.cc @@ -69,6 +69,30 @@ BOOST_AUTO_TEST_CASE(test_get_entry) BOOST_CHECK_EQUAL(ne.d_auth, auth); } +BOOST_AUTO_TEST_CASE(test_get_entry2038) +{ + /* Add a full name negative entry to the cache and attempt to get an entry for + * the A record. Should yield the full name does not exist entry + */ + DNSName qname("www2.powerdns.com"); + DNSName auth("powerdns.com"); + + struct timeval now{INT_MAX - 300, 0}; + + NegCache cache; + cache.add(genNegCacheEntry(qname, auth, now)); + + BOOST_CHECK_EQUAL(cache.size(), 1U); + + NegCache::NegCacheEntry ne; + bool ret = cache.get(qname, QType(1), now, ne); + + BOOST_CHECK(ret); + BOOST_CHECK_EQUAL(ne.d_name, qname); + BOOST_CHECK_EQUAL(ne.d_qtype.getName(), QType(0).getName()); + BOOST_CHECK_EQUAL(ne.d_auth, auth); +} + BOOST_AUTO_TEST_CASE(test_get_entry_exact_type) { /* Add a full name negative entry to the cache and attempt to get an entry for