]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Refactor auth-py tests so config templates can be used 7768/head
authorPieter Lexis <pieter.lexis@powerdns.com>
Thu, 2 May 2019 13:30:22 +0000 (15:30 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 13 May 2019 12:49:08 +0000 (14:49 +0200)
regression-tests.auth-py/authtests.py
regression-tests.auth-py/test_ALIAS.py
regression-tests.auth-py/test_LuaRecords.py

index d04eb3dc4a67ffd2d0fc5cac3fd14fadef346831..9737ef868034b88bc49eb929bbe51b8dc0aa386f 100644 (file)
@@ -23,6 +23,25 @@ class AuthTest(unittest.TestCase):
     _confdir = 'auth'
     _authPort = 5300
 
+    _config_params = []
+
+    _config_template_default = """
+module-dir=../regression-tests/modules
+daemon=no
+local-ipv6=
+bind-config={confdir}/named.conf
+bind-dnssec-db={bind_dnssec_db}
+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"""
+
+    _config_template = ""
+
     _root_DS = "63149 13 1 a59da3f5c1b97fcd5fa2b3b2b0ac91d38a60d33a"
 
     # The default SOA for zones in the authoritative servers
@@ -92,28 +111,13 @@ options {
     def generateAuthConfig(cls, confdir):
         bind_dnssec_db = os.path.join(confdir, 'bind-dnssec.sqlite3')
 
+        params = tuple([getattr(cls, param) for param in cls._config_params])
+
         with open(os.path.join(confdir, 'pdns.conf'), 'w') as pdnsconf:
-            pdnsconf.write("""
-module-dir=../regression-tests/modules
-launch=bind geoip
-daemon=no
-local-ipv6=
-bind-config={confdir}/named.conf
-bind-dnssec-db={bind_dnssec_db}
-socket-dir={confdir}
-cache-ttl=0
-negquery-cache-ttl=0
-query-cache-ttl=0
-log-dns-queries=yes
-log-dns-details=yes
-loglevel=9
-geoip-database-files=../modules/geoipbackend/regression-tests/GeoLiteCity.mmdb
-edns-subnet-processing=yes
-expand-alias=yes
-resolver={prefix}.1:5301
-any-to-tcp=no
-distributor-threads=1""".format(confdir=confdir, prefix=cls._PREFIX,
-                                bind_dnssec_db=bind_dnssec_db))
+            pdnsconf.write(cls._config_template_default.format(
+                confdir=confdir, prefix=cls._PREFIX,
+                bind_dnssec_db=bind_dnssec_db))
+            pdnsconf.write(cls._config_template % params)
 
         pdnsutilCmd = [os.environ['PDNSUTIL'],
                        '--config-dir=%s' % confdir,
index 1178534ee3c8e8fcd5cbf9135804a8fbc687a9e3..789b387473e914721288cc68c64cc65b9c8df489 100644 (file)
@@ -15,6 +15,15 @@ aliasUDPReactorRunning = False
 
 
 class TestALIAS(AuthTest):
+    _config_template = """
+expand-alias=yes
+resolver=%s.1:5301
+any-to-tcp=no
+launch=bind
+"""
+
+    _config_params = ['_PREFIX']
+
     _zones = {
         'example.org': """
 example.org.                 3600 IN SOA  {soa}
index ffe762af9798b7a191f4c2668808c2eb67c9d613..6ebf4427b361674252bf782b691712fc12eef87d 100644 (file)
@@ -30,6 +30,13 @@ class FakeHTTPServer(BaseHTTPRequestHandler):
         self._set_headers()
 
 class TestLuaRecords(AuthTest):
+    _config_template = """
+geoip-database-files=../modules/geoipbackend/regression-tests/GeoLiteCity.mmdb
+edns-subnet-processing=yes
+launch=bind geoip
+any-to-tcp=no
+"""
+
     _zones = {
         'example.org': """
 example.org.                 3600 IN SOA  {soa}