]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
test(auth): add empty backupselector test case
authorXabier Napal <xabier.napal@dvzr.io>
Tue, 21 Oct 2025 06:51:25 +0000 (08:51 +0200)
committerXabier Napal <xabier.napal@dvzr.io>
Thu, 18 Dec 2025 10:54:04 +0000 (11:54 +0100)
Signed-off-by: Xabier Napal <xabier.napal@dvzr.io>
regression-tests.auth-py/test_LuaRecords.py

index b0131e1f5d6d00c87d853bc3d3e0fd0fad334a10..887368533036b58feea8e240785769edb96791e0 100644 (file)
@@ -65,6 +65,7 @@ some.ifportup                3600 IN LUA  A     "ifportup(8080, {{'192.168.42.21
 multi.ifportup               3600 IN LUA  A     "ifportup(8080, {{ {{'192.168.42.23'}}, {{'192.168.42.21', '{prefix}.102'}}, {{'{prefix}.101'}} }})"
 none.ifportup                3600 IN LUA  A     "ifportup(8080, {{'192.168.42.21', '192.168.21.42'}})"
 all.noneup.ifportup          3600 IN LUA  A     "ifportup(8080, {{'192.168.42.21', '192.168.21.42'}}, {{ backupSelector='all' }})"
+empty.ifportup               3600 IN LUA  A     "ifportup(8080, {{'192.168.42.21', '192.168.21.42'}}, {{ backupSelector='empty' }})"
 
 hashed.example.org.          3600 IN LUA  A     "pickhashed({{ '1.2.3.4', '4.3.2.1' }})"
 hashed-v6.example.org.       3600 IN LUA  AAAA  "pickhashed({{ '2001:db8:a0b:12f0::1', 'fe80::2a1:9bff:fe9b:f268' }})"
@@ -443,6 +444,19 @@ class TestLuaRecords(BaseLuaTest):
         self.assertRcodeEqual(res, dns.rcode.NOERROR)
         self.assertEqual(res.answer, expected)
 
+    def testIfportupWithAllDownAndEmptyBackupSelector(self):
+        """
+        Basic ifportup() test with all ports DOWN, fallback to 'empty' backup selector
+        """
+        name = 'empty.ifportup.example.org.'
+        query = dns.message.make_query(name, dns.rdatatype.A)
+
+        # With backupSelector='empty', we always return NODATA when no healthy targets,
+        # even before health checks have run (fail-close behavior).
+        res = self.sendUDPQuery(query)
+        self.assertRcodeEqual(res, dns.rcode.NOERROR)
+        self.assertEqual(res.answer, [])
+
     def testIfurlup(self):
         """
         Basic ifurlup() test