]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use jinja2 templates in views test
authorNicki Křížek <nicki@isc.org>
Fri, 5 Dec 2025 16:39:23 +0000 (17:39 +0100)
committerNicki Křížek <nicki@isc.org>
Tue, 9 Dec 2025 13:23:17 +0000 (14:23 +0100)
- 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).

bin/tests/system/views/ns1/named.conf.j2 [moved from bin/tests/system/views/ns1/named.conf.in with 100% similarity]
bin/tests/system/views/ns2/named.conf.j2
bin/tests/system/views/ns2/named2.conf.j2 [moved from bin/tests/system/views/ns2/named2.conf.in with 100% similarity]
bin/tests/system/views/ns2/named3.conf.j2 [moved from bin/tests/system/views/ns2/named1.conf.in with 63% similarity]
bin/tests/system/views/ns3/named.conf.j2 [moved from bin/tests/system/views/ns3/named1.conf.in with 100% similarity]
bin/tests/system/views/ns3/named2.conf.j2 [moved from bin/tests/system/views/ns3/named2.conf.in with 100% similarity]
bin/tests/system/views/ns5/named.conf.j2 [moved from bin/tests/system/views/ns5/named.conf.in with 100% similarity]
bin/tests/system/views/setup.sh
bin/tests/system/views/tests.sh
bin/tests/system/views/tests_views_addzones.py

index d9d852f82f570efeeb04b4bf657cc8282d81c95d..72e4ab4ff1d27a27df44aede63272122b3ad944a 100644 (file)
@@ -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 %}
similarity index 63%
rename from bin/tests/system/views/ns2/named1.conf.in
rename to bin/tests/system/views/ns2/named3.conf.j2
index 72e4ab4ff1d27a27df44aede63272122b3ad944a..d9d852f82f570efeeb04b4bf657cc8282d81c95d 100644 (file)
@@ -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 %}
index 9ccf5d019715be7ca93dccb533f828401ccb0860..b8c7a1559ff184bcab7a2975ed8e9d267bbd39b0 100644 (file)
@@ -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
index d7a20aa12d708aa867140d840490d92a10fe7df9..90e4e10d04a230e7a8a18e4efd234224e91b321e 100644 (file)
@@ -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
index 2baf745fdf68933620681c31ca8f50fdf21c64f5..57c99ac498260060ac19079610df4caf442cddc7 100644 (file)
@@ -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")