]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use jinja2 templates in rpz test
authorNicki Křížek <nicki@isc.org>
Fri, 5 Dec 2025 16:17:46 +0000 (17:17 +0100)
committerNicki Křížek <nicki@isc.org>
Tue, 9 Dec 2025 13:23:17 +0000 (14:23 +0100)
- The ns3/named.conf.j2 uses has a "#BAD" section that is only included
  after restart. Turn it into ns3/named2.conf.
- Since the original config is then restored, keep a copy of it as
  ns3/named1.conf using a symlink, causing it to be rendered twice.
- Use jinja2 templates for test* files to render the port number instead
  of calling copy_setports in load_db().

22 files changed:
bin/tests/system/rpz/ns1/named.conf.j2 [moved from bin/tests/system/rpz/ns1/named.conf.in with 100% similarity]
bin/tests/system/rpz/ns10/named.conf.j2 [moved from bin/tests/system/rpz/ns10/named.conf.in with 100% similarity]
bin/tests/system/rpz/ns2/named.conf.j2 [moved from bin/tests/system/rpz/ns2/named.conf.in with 100% similarity]
bin/tests/system/rpz/ns3/named.conf.j2 [moved from bin/tests/system/rpz/ns3/named.conf.in with 95% similarity]
bin/tests/system/rpz/ns3/named1.conf.j2 [new symlink]
bin/tests/system/rpz/ns3/named2.conf.j2 [new file with mode: 0644]
bin/tests/system/rpz/ns4/named.conf.j2 [moved from bin/tests/system/rpz/ns4/named.conf.in with 100% similarity]
bin/tests/system/rpz/ns5/named.conf.j2 [moved from bin/tests/system/rpz/ns5/named.conf.in with 100% similarity]
bin/tests/system/rpz/ns6/named.conf.j2 [moved from bin/tests/system/rpz/ns6/named.conf.in with 100% similarity]
bin/tests/system/rpz/ns7/named.conf.j2 [moved from bin/tests/system/rpz/ns7/named.conf.in with 100% similarity]
bin/tests/system/rpz/ns8/named.conf.j2 [moved from bin/tests/system/rpz/ns8/named.conf.in with 100% similarity]
bin/tests/system/rpz/ns9/named.conf.j2 [moved from bin/tests/system/rpz/ns9/named.conf.in with 100% similarity]
bin/tests/system/rpz/setup.sh
bin/tests/system/rpz/test1.j2 [moved from bin/tests/system/rpz/test1 with 100% similarity]
bin/tests/system/rpz/test2.j2 [moved from bin/tests/system/rpz/test2 with 100% similarity]
bin/tests/system/rpz/test3.j2 [moved from bin/tests/system/rpz/test3 with 100% similarity]
bin/tests/system/rpz/test4.j2 [moved from bin/tests/system/rpz/test4 with 100% similarity]
bin/tests/system/rpz/test4a.j2 [moved from bin/tests/system/rpz/test4a with 100% similarity]
bin/tests/system/rpz/test5.j2 [moved from bin/tests/system/rpz/test5 with 100% similarity]
bin/tests/system/rpz/test6.j2 [moved from bin/tests/system/rpz/test6 with 100% similarity]
bin/tests/system/rpz/tests.sh
bin/tests/system/rpz/tests_sh_rpz.py

similarity index 95%
rename from bin/tests/system/rpz/ns3/named.conf.in
rename to bin/tests/system/rpz/ns3/named.conf.j2
index 40fff061888ea156e6903fb94b3b22cfb3d108bf..cd2a29b75453e3f5fd74463fed578c8fabd2e431 100644 (file)
@@ -15,6 +15,8 @@
  * Main rpz test DNS server.
  */
 
+{% set bad_dlz = bad_dlz | default(False) %}
+
 options {
        query-source address 10.53.0.3;
        notify-source 10.53.0.3;
@@ -170,12 +172,12 @@ zone "wild-cname" {
        file "wild-cname.db";
 };
 
+{% if bad_dlz %}
 # A faulty dlz configuration to check if named with response policy zones
 # survives a certain class of failed configuration attempts (see GL #3880).
 # "dlz" is used because the dlz processing code is located in an ideal place in
 # the view configuration function for the test to cover the view reverting code.
-# The "BAD" comments below are necessary, because they will be removed using
-# 'sed' by tests.sh in order to activate the faulty configuration.
-#BAD   dlz "bad-dlz" {
-#BAD           database "dlopen bad-dlz.@DYLIB@ example.org";
-#BAD   };
+       dlz "bad-dlz" {
+               database "dlopen bad-dlz.@DYLIB@ example.org";
+       };
+{% endif %}
diff --git a/bin/tests/system/rpz/ns3/named1.conf.j2 b/bin/tests/system/rpz/ns3/named1.conf.j2
new file mode 120000 (symlink)
index 0000000..89af67c
--- /dev/null
@@ -0,0 +1 @@
+named.conf.j2
\ No newline at end of file
diff --git a/bin/tests/system/rpz/ns3/named2.conf.j2 b/bin/tests/system/rpz/ns3/named2.conf.j2
new file mode 100644 (file)
index 0000000..4f8a627
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+{% set bad_dlz = True %}
+
+{% include "ns3/named.conf.j2" %}
index 4daa6d325c2aafd2febb9ebf127716284965feea..56b2a5cda20f9e2b87cbdaca77630f9f93a45ee1 100644 (file)
@@ -20,17 +20,6 @@ for dir in ns*; do
   nextpart $dir/named.run >/dev/null
 done
 
-copy_setports ns1/named.conf.in ns1/named.conf
-copy_setports ns2/named.conf.in ns2/named.conf
-copy_setports ns3/named.conf.in ns3/named.conf
-copy_setports ns4/named.conf.in ns4/named.conf
-copy_setports ns5/named.conf.in ns5/named.conf
-copy_setports ns6/named.conf.in ns6/named.conf
-copy_setports ns7/named.conf.in ns7/named.conf
-copy_setports ns8/named.conf.in ns8/named.conf
-copy_setports ns9/named.conf.in ns9/named.conf
-copy_setports ns10/named.conf.in ns10/named.conf
-
 # set up test policy zones.
 #   bl is the main test zone
 #   bl-2 is used to check competing zones.
index 612e849d2804354d78ce674635aae0e7161c20ed..578ed9daf96360c97d65324ab11229ede2b928ee 100644 (file)
@@ -134,9 +134,7 @@ ck_soa() {
 # (re)load the response policy zones with the rules in the file $TEST_FILE
 load_db() {
   if test -n "$TEST_FILE"; then
-    copy_setports $TEST_FILE tmp
-
-    if $NSUPDATE -v tmp; then
+    if $NSUPDATE -v $TEST_FILE; then
       :
       $RNDCCMD $ns3 sync
     else
@@ -144,7 +142,6 @@ load_db() {
       $RNDCCMD $ns3 sync
       exit 1
     fi
-    rm -f tmp
   fi
 }
 
@@ -250,8 +247,7 @@ start_group() {
 end_group() {
   if test -n "$TEST_FILE"; then
     # remove the previous set of test rules
-    copy_setports $TEST_FILE tmp
-    sed -e 's/[         ]add[   ]/ delete /' tmp | $NSUPDATE
+    sed -e 's/[         ]add[   ]/ delete /' $TEST_FILE | $NSUPDATE
     rm -f tmp
     TEST_FILE=
   fi
@@ -678,12 +674,10 @@ restart 3 "rebuild-bl-rpz"
 
 t=$((t + 1))
 echo_i "checking if rpz survives a certain class of failed reconfiguration attempts (${t})"
-sed -e "s/^#BAD//" <ns3/named.conf.in >ns3/named.conf.tmp
-copy_setports ns3/named.conf.tmp ns3/named.conf
-rm ns3/named.conf.tmp
+cp ns3/named2.conf ns3/named.conf
 $RNDCCMD $ns3 reconfig >/dev/null 2>&1 && setret "failed"
 sleep 1
-copy_setports ns3/named.conf.in ns3/named.conf
+cp ns3/named1.conf ns3/named.conf
 $RNDCCMD $ns3 reconfig || setret "failed"
 
 t=$((t + 1))
index ad0548a0336b8a6355b2cba9c35bddf1b32edbc7..5f6a88a21b169341fbe1cb5bed16f556471c84e4 100644 (file)
@@ -18,6 +18,7 @@ pytestmark = pytest.mark.extra_artifacts(
         "dnsrps.conf",
         "dnsrps.zones",
         "proto.*",
+        "test*",
         "trusted.conf",
         "ns2/K*",
         "ns2/bl.tld2.db",