from authtests import AuthTest
import dns
+import os
+import subprocess
+class SVCBRecordsBase(AuthTest):
+ # Copied from AuthTest, without the bind-config and bind-dnssec fields.
+ _config_template_default = """
+module-dir={PDNS_MODULE_DIR}
+daemon=no
+socket-dir={confdir}
+cache-ttl=0
+negquery-cache-ttl=0
+query-cache-ttl=0
+log-dns-queries=yes
+log-dns-details=yes
+loglevel=9
+distributor-threads=1"""
-class TestSVCBRecords(AuthTest):
_config_template = """
-launch=bind
svc-autohints
"""
""",
}
- def testWithoutAlias(self):
+ def impl_testWithoutAlias(self):
query = dns.message.make_query('www.example.org', 'HTTPS')
res = self.sendUDPQuery(query)
expected_ans = dns.rrset.from_text(
self.assertRRsetInAnswer(res, expected_ans)
self.assertEqual(len(res.additional), 2)
- def testWithAlias(self):
+ def impl_testWithAlias(self):
"""
Ensure additional processing happens for HTTPS AliasMode
"""
self.assertRRsetInAdditional(res, expected_addl)
self.assertEqual(len(res.additional), 3)
- def testWithMissingA(self):
+ def impl_testWithMissingA(self):
"""
Ensure PowerDNS removes the ipv4hint if there's no A record
"""
self.assertRRsetInAnswer(res, expected_ans)
self.assertEqual(len(res.additional), 1)
- def testWithMissingAAAA(self):
+ def impl_testWithMissingAAAA(self):
"""
Ensure PowerDNS removes the ipv6hint if there's no AAAA record
"""
self.assertRRsetInAnswer(res, expected_ans)
self.assertEqual(len(res.additional), 1)
- def testNoAuto(self):
+ def impl_testNoAuto(self):
"""
Ensure we send the actual hints, not generated ones
"""
self.assertRRsetInAnswer(res, expected_ans)
self.assertEqual(len(res.additional), 2)
- def testAutoA(self):
+ def impl_testAutoA(self):
"""
Ensure we send a generated A hint, but keep the existing AAAA hint
"""
self.assertRRsetInAnswer(res, expected_ans)
self.assertEqual(len(res.additional), 2)
- def testAutoAAAA(self):
+ def impl_testAutoAAAA(self):
"""
Ensure we send a generated AAAA hint, but keep the existing A hint
"""
print(res)
self.assertRRsetInAnswer(res, expected_ans)
self.assertEqual(len(res.additional), 2)
+
+class TestSVCBRecordsBind(SVCBRecordsBase):
+ _config_template_default = (
+ SVCBRecordsBase._config_template_default
+ + """
+bind-config={confdir}/named.conf
+bind-dnssec-db={bind_dnssec_db}
+"""
+ )
+
+ _config_template = (
+ SVCBRecordsBase._config_template
+ + """
+launch=bind
+"""
+ )
+
+ def testWithoutAlias(self):
+ self.impl_testWithoutAlias()
+
+ def testWithAlias(self):
+ """
+ Ensure additional processing happens for HTTPS AliasMode
+ """
+ self.impl_testWithAlias()
+
+ def testWithMissingA(self):
+ """
+ Ensure PowerDNS removes the ipv4hint if there's no A record
+ """
+ self.impl_testWithMissingA()
+
+ def testWithMissingAAAA(self):
+ """
+ Ensure PowerDNS removes the ipv6hint if there's no AAAA record
+ """
+ self.impl_testWithMissingAAAA()
+
+ def testNoAuto(self):
+ """
+ Ensure we send the actual hints, not generated ones
+ """
+ self.impl_testNoAuto()
+
+ def testAutoA(self):
+ """
+ Ensure we send a generated A hint, but keep the existing AAAA hint
+ """
+ self.impl_testAutoA()
+
+ def testAutoAAAA(self):
+ """
+ Ensure we send a generated AAAA hint, but keep the existing A hint
+ """
+ self.impl_testAutoAAAA()
+
+class TestSVCBRecordsLMDB(SVCBRecordsBase):
+ _config_template = (
+ SVCBRecordsBase._config_template
+ + """
+launch=lmdb
+"""
+ )
+
+ @classmethod
+ def generateAllAuthConfig(cls, confdir):
+ # This is very similar to AuthTest.generateAllAuthConfig,
+ # but for lmdb backend, we ignore auth keys but need to load-zone
+ # into lmdb storage.
+ cls.generateAuthConfig(confdir)
+
+ for zonename, zonecontent in cls._zones.items():
+ cls.generateAuthZone(confdir,
+ zonename,
+ zonecontent)
+ pdnsutilCmd = [os.environ['PDNSUTIL'],
+ '--config-dir=%s' % confdir,
+ 'load-zone',
+ zonename,
+ os.path.join(confdir, '%s.zone' % zonename)]
+
+ print(' '.join(pdnsutilCmd))
+ try:
+ subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output))
+
+ def testWithoutAlias(self):
+ self.impl_testWithoutAlias()
+
+ def testWithAlias(self):
+ """
+ Ensure additional processing happens for HTTPS AliasMode
+ """
+ self.impl_testWithAlias()
+
+ def testWithMissingA(self):
+ """
+ Ensure PowerDNS removes the ipv4hint if there's no A record
+ """
+ self.impl_testWithMissingA()
+
+ def testWithMissingAAAA(self):
+ """
+ Ensure PowerDNS removes the ipv6hint if there's no AAAA record
+ """
+ self.impl_testWithMissingAAAA()
+
+ def testNoAuto(self):
+ """
+ Ensure we send the actual hints, not generated ones
+ """
+ self.impl_testNoAuto()
+
+ def testAutoA(self):
+ """
+ Ensure we send a generated A hint, but keep the existing AAAA hint
+ """
+ self.impl_testAutoA()
+
+ def testAutoAAAA(self):
+ """
+ Ensure we send a generated AAAA hint, but keep the existing A hint
+ """
+ self.impl_testAutoAAAA()