]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Fix Ueberbackend unit tests when caching is actually enabled (#1) 10543/head
authorRemi Gacogne <github@coredump.fr>
Wed, 30 Jun 2021 10:43:09 +0000 (12:43 +0200)
committerGitHub <noreply@github.com>
Wed, 30 Jun 2021 10:43:09 +0000 (12:43 +0200)
pdns/test-ueberbackend_cc.cc

index 32df312240a5c1e60b0261aab24a69ff67afa478..a5c143e22e105fd3e70bbe03fa4be572790cad84 100644 (file)
@@ -137,8 +137,13 @@ public:
     findZone(qdomain, zoneId, d_records, d_currentZone);
 
     if (d_records) {
-      if (qdomain == DNSName("geo.powerdns.com.") && pkt_p != nullptr && pkt_p->getRealRemote() == Netmask("192.0.2.1")) {
-        d_currentScopeMask = 32;
+      if (qdomain == DNSName("geo.powerdns.com.") && pkt_p != nullptr) {
+        if (pkt_p->getRealRemote() == Netmask("192.0.2.1")) {
+          d_currentScopeMask = 32;
+        }
+        else if (pkt_p->getRealRemote() == Netmask("198.51.100.1")) {
+          d_currentScopeMask = 24;
+        }
       }
 
       auto& idx = d_records->get<OrderedNameTypeTag>();
@@ -337,7 +342,7 @@ struct UeberBackendSetupArgFixture {
     ::arg().set("query-cache-ttl")="0";
     ::arg().set("negquery-cache-ttl")="0";
     ::arg().set("consistent-backends")="no";
-    QC.cleanup();
+    QC.purge();
     ::arg().set("zone-cache-refresh-interval")="0";
     g_zoneCache.clear();
     BackendMakers().clear();
@@ -354,7 +359,7 @@ static void testWithoutThenWithAuthCache(std::function<void(UeberBackend& ub)> f
     /* disable the cache */
     ::arg().set("query-cache-ttl")="0";
     ::arg().set("negquery-cache-ttl")="0";
-    QC.cleanup();
+    QC.purge();
     QC.setMaxEntries(0);
     /* keep zone cache disabled */
     ::arg().set("zone-cache-refresh-interval")="0";
@@ -368,7 +373,7 @@ static void testWithoutThenWithAuthCache(std::function<void(UeberBackend& ub)> f
     /* enable the cache */
     ::arg().set("query-cache-ttl")="20";
     ::arg().set("negquery-cache-ttl")="60";
-    QC.cleanup();
+    QC.purge();
     QC.setMaxEntries(100000);
     /* keep zone cache disabled */
     ::arg().set("zone-cache-refresh-interval")="0";
@@ -393,7 +398,7 @@ static void testWithoutThenWithZoneCache(std::function<void(UeberBackend& ub)> f
     /* keep auth caches disabled */
     ::arg().set("query-cache-ttl")="0";
     ::arg().set("negquery-cache-ttl")="0";
-    QC.cleanup();
+    QC.purge();
     QC.setMaxEntries(0);
 
     UeberBackend ub;
@@ -407,7 +412,7 @@ static void testWithoutThenWithZoneCache(std::function<void(UeberBackend& ub)> f
     /* keep auth caches disabled */
     ::arg().set("query-cache-ttl")="0";
     ::arg().set("negquery-cache-ttl")="0";
-    QC.cleanup();
+    QC.purge();
     QC.setMaxEntries(0);
 
     UeberBackend ub;
@@ -530,11 +535,11 @@ BOOST_AUTO_TEST_CASE(test_simple) {
       BOOST_REQUIRE_EQUAL(records.size(), 1U);
       checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 32, true);
       // and that we don't get the same result for a different client
-      remote = ComboAddress("192.0.2.2");
+      remote = ComboAddress("198.51.100.1");
       pkt.setRemote(&remote);
       records = getRecords(ub, DNSName("geo.powerdns.com."), QType::ANY, 1, &pkt);
       BOOST_REQUIRE_EQUAL(records.size(), 1U);
-      checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 0, true);
+      checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 24, true);
     }
 
     };
@@ -677,11 +682,11 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_separate_zones) {
       BOOST_REQUIRE_EQUAL(records.size(), 1U);
       checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 32, true);
       // and that we don't get the same result for a different client
-      remote = ComboAddress("192.0.2.2");
+      remote = ComboAddress("198.51.100.1");
       pkt.setRemote(&remote);
       records = getRecords(ub, DNSName("geo.powerdns.com."), QType::ANY, 1, &pkt);
       BOOST_REQUIRE_EQUAL(records.size(), 1U);
-      checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 0, true);
+      checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 24, true);
     }
 
     };
@@ -803,11 +808,11 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_overlay) {
       BOOST_REQUIRE_EQUAL(records.size(), 1U);
       checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 32, true);
       // and that we don't get the same result for a different client
-      remote = ComboAddress("192.0.2.2");
+      remote = ComboAddress("198.51.100.1");
       pkt.setRemote(&remote);
       records = getRecords(ub, DNSName("geo.powerdns.com."), QType::ANY, 1, &pkt);
       BOOST_REQUIRE_EQUAL(records.size(), 1U);
-      checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 0, true);
+      checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 24, true);
     }
 
     };
@@ -926,11 +931,11 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_overlay_name) {
       BOOST_REQUIRE_EQUAL(records.size(), 1U);
       checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 32, true);
       // and that we don't get the same result for a different client
-      remote = ComboAddress("192.0.2.2");
+      remote = ComboAddress("198.51.100.1");
       pkt.setRemote(&remote);
       records = getRecords(ub, DNSName("geo.powerdns.com."), QType::ANY, 1, &pkt);
       BOOST_REQUIRE_EQUAL(records.size(), 1U);
-      checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 0, true);
+      checkRecordExists(records, DNSName("geo.powerdns.com."), QType::A, 1, 24, true);
     }
 
     };
@@ -1059,8 +1064,9 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_best_soa) {
       BOOST_REQUIRE(ub.getAuth(DNSName("2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa."), QType::PTR, &sd));
       BOOST_CHECK_EQUAL(sd.qname.toString(), "d.0.1.0.0.2.ip6.arpa.");
       BOOST_CHECK_EQUAL(sd.domain_id, 1);
-      // check that only one auth lookup occurred to this backend
-      BOOST_CHECK_EQUAL(sbba->d_authLookupCount, 1U);
+
+      // check that at most one auth lookup occurred to this backend (O with caching enabled)
+      BOOST_CHECK_LE(sbba->d_authLookupCount, 1U);
     }
 
     };