From: Nicki Křížek Date: Fri, 5 Dec 2025 16:39:23 +0000 (+0100) Subject: Use jinja2 templates in views test X-Git-Tag: v9.21.17~46^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2592f0d9610f07c32d53eaaa81648ffb48ac5a24;p=thirdparty%2Fbind9.git Use jinja2 templates in views test - Rename named.conf.j2 to named3.conf.j2 and adjust the python test to render this template. - Handle the n2 and ns3 multiple configs as in other similar cases (ns2/named1.conf.in was moved to ns2/named.conf.j2). --- diff --git a/bin/tests/system/views/ns1/named.conf.in b/bin/tests/system/views/ns1/named.conf.j2 similarity index 100% rename from bin/tests/system/views/ns1/named.conf.in rename to bin/tests/system/views/ns1/named.conf.j2 diff --git a/bin/tests/system/views/ns2/named.conf.j2 b/bin/tests/system/views/ns2/named.conf.j2 index d9d852f82f5..72e4ab4ff1d 100644 --- a/bin/tests/system/views/ns2/named.conf.j2 +++ b/bin/tests/system/views/ns2/named.conf.j2 @@ -10,7 +10,6 @@ * See the COPYRIGHT file distributed with this work for additional * information regarding copyright ownership. */ -{% set zone_names = zone_names | default([]) %} options { query-source address 10.53.0.2; @@ -21,9 +20,9 @@ options { listen-on { 10.53.0.2; }; listen-on-v6 { none; }; allow-transfer { any; }; - recursion no; + recursion yes; dnssec-validation no; - notify no; + notify yes; }; key rndc_key { @@ -35,11 +34,28 @@ controls { inet 10.53.0.2 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; }; -{% for name in zone_names %} -zone "@name@" { - type primary; - file "@name@.db"; - dnssec-policy default; - inline-signing yes; +dnssec-policy "views" { + keys { + ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@; + zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@; + }; +}; + +zone "." { + type hint; + file "../../_common/root.hint"; +}; + +zone "example" { + type primary; + file "example.db"; + allow-update { any; }; +}; + +zone "inline" { + type primary; + file "external/inline.db"; + key-directory "external"; + dnssec-policy views; + inline-signing yes; }; -{% endfor %} diff --git a/bin/tests/system/views/ns2/named2.conf.in b/bin/tests/system/views/ns2/named2.conf.j2 similarity index 100% rename from bin/tests/system/views/ns2/named2.conf.in rename to bin/tests/system/views/ns2/named2.conf.j2 diff --git a/bin/tests/system/views/ns2/named1.conf.in b/bin/tests/system/views/ns2/named3.conf.j2 similarity index 63% rename from bin/tests/system/views/ns2/named1.conf.in rename to bin/tests/system/views/ns2/named3.conf.j2 index 72e4ab4ff1d..d9d852f82f5 100644 --- a/bin/tests/system/views/ns2/named1.conf.in +++ b/bin/tests/system/views/ns2/named3.conf.j2 @@ -10,6 +10,7 @@ * See the COPYRIGHT file distributed with this work for additional * information regarding copyright ownership. */ +{% set zone_names = zone_names | default([]) %} options { query-source address 10.53.0.2; @@ -20,9 +21,9 @@ options { listen-on { 10.53.0.2; }; listen-on-v6 { none; }; allow-transfer { any; }; - recursion yes; + recursion no; dnssec-validation no; - notify yes; + notify no; }; key rndc_key { @@ -34,28 +35,11 @@ controls { inet 10.53.0.2 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; }; -dnssec-policy "views" { - keys { - ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@; - zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@; - }; -}; - -zone "." { - type hint; - file "../../_common/root.hint"; -}; - -zone "example" { - type primary; - file "example.db"; - allow-update { any; }; -}; - -zone "inline" { - type primary; - file "external/inline.db"; - key-directory "external"; - dnssec-policy views; - inline-signing yes; +{% for name in zone_names %} +zone "@name@" { + type primary; + file "@name@.db"; + dnssec-policy default; + inline-signing yes; }; +{% endfor %} diff --git a/bin/tests/system/views/ns3/named1.conf.in b/bin/tests/system/views/ns3/named.conf.j2 similarity index 100% rename from bin/tests/system/views/ns3/named1.conf.in rename to bin/tests/system/views/ns3/named.conf.j2 diff --git a/bin/tests/system/views/ns3/named2.conf.in b/bin/tests/system/views/ns3/named2.conf.j2 similarity index 100% rename from bin/tests/system/views/ns3/named2.conf.in rename to bin/tests/system/views/ns3/named2.conf.j2 diff --git a/bin/tests/system/views/ns5/named.conf.in b/bin/tests/system/views/ns5/named.conf.j2 similarity index 100% rename from bin/tests/system/views/ns5/named.conf.in rename to bin/tests/system/views/ns5/named.conf.j2 diff --git a/bin/tests/system/views/setup.sh b/bin/tests/system/views/setup.sh index 9ccf5d01971..b8c7a1559ff 100644 --- a/bin/tests/system/views/setup.sh +++ b/bin/tests/system/views/setup.sh @@ -17,12 +17,6 @@ set -e . ../conf.sh cp -f ns2/example1.db ns2/example.db - -copy_setports ns1/named.conf.in ns1/named.conf -copy_setports ns2/named1.conf.in ns2/named.conf -copy_setports ns3/named1.conf.in ns3/named.conf -copy_setports ns5/named.conf.in ns5/named.conf - # # We remove k1 and k2 as KEYGEN is deterministic when given the # same source of "random" data and we want different keys for diff --git a/bin/tests/system/views/tests.sh b/bin/tests/system/views/tests.sh index d7a20aa12d7..90e4e10d04a 100644 --- a/bin/tests/system/views/tests.sh +++ b/bin/tests/system/views/tests.sh @@ -37,8 +37,8 @@ dig_with_opts a.example. @10.53.0.3 any >dig.out.ns3.1 || status=1 echo_i "copying in new configurations for ns2 and ns3" rm -f ns2/named.conf ns3/named.conf ns2/example.db cp -f ns2/example2.db ns2/example.db -copy_setports ns2/named2.conf.in ns2/named.conf -copy_setports ns3/named2.conf.in ns3/named.conf +cp ns2/named2.conf ns2/named.conf +cp ns3/named2.conf ns3/named.conf echo_i "reloading ns2 and ns3 with rndc" nextpart ns2/named.run >/dev/null diff --git a/bin/tests/system/views/tests_views_addzones.py b/bin/tests/system/views/tests_views_addzones.py index 2baf745fdf6..57c99ac4982 100644 --- a/bin/tests/system/views/tests_views_addzones.py +++ b/bin/tests/system/views/tests_views_addzones.py @@ -17,7 +17,9 @@ def test_views_add_zones(ns2, templates): for i in range(50): name = f"example{i:03}.com" zone_names.append(name) - templates.render("ns2/named.conf", {"zone_names": zone_names}) + templates.render( + "ns2/named.conf", {"zone_names": zone_names}, template="ns2/named3.conf.j2" + ) shutil.copyfile("ns2/zone.db.in", f"ns2/{name}.db") with ns2.watch_log_from_here() as watcher: ns2.rndc("reconfig")