]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Basic test for negcache.
authorOtto <otto.moerbeek@open-xchange.com>
Mon, 25 Jan 2021 15:11:21 +0000 (16:11 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Mon, 25 Jan 2021 15:11:21 +0000 (16:11 +0100)
This one seems to be safe from code inspection. All timestamps are time_t.

pdns/recursordist/test-negcache_cc.cc

index 8c3b38b625382e09d7fcd00cf36a94e46bf6472c..5ea1ad79ba3c675e44561d45c24cd6f0c92b1de6 100644 (file)
@@ -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