]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use jinja2 templates in staticstub test
authorNicki Křížek <nicki@isc.org>
Fri, 5 Dec 2025 16:04:47 +0000 (17:04 +0100)
committerNicki Křížek <nicki@isc.org>
Tue, 9 Dec 2025 13:23:17 +0000 (14:23 +0100)
- Instead of strings to be replaced by sed, use proper jinja templates.
- ns3/named1.conf.j2 is basically a copy of the default config, because
  it needs to be restored later in the test.

bin/tests/system/staticstub/ns1/named.conf.j2 [moved from bin/tests/system/staticstub/ns1/named.conf.in with 100% similarity]
bin/tests/system/staticstub/ns2/named.conf.j2 [moved from bin/tests/system/staticstub/ns2/named.conf.in with 86% similarity]
bin/tests/system/staticstub/ns2/named2.conf.j2 [new file with mode: 0644]
bin/tests/system/staticstub/ns3/named.conf.j2 [moved from bin/tests/system/staticstub/ns3/named.conf.in with 87% similarity]
bin/tests/system/staticstub/ns3/named1.conf.j2 [new file with mode: 0644]
bin/tests/system/staticstub/ns3/named2.conf.j2 [new file with mode: 0644]
bin/tests/system/staticstub/ns4/named.conf.j2 [moved from bin/tests/system/staticstub/ns4/named.conf.in with 100% similarity]
bin/tests/system/staticstub/setup.sh
bin/tests/system/staticstub/tests.sh

similarity index 86%
rename from bin/tests/system/staticstub/ns2/named.conf.in
rename to bin/tests/system/staticstub/ns2/named.conf.j2
index 7ffe39f6b09243824ce5e5df7a35acdd953a02af..1f568da9081d5896870e6d8cc2e41b42584339d4 100644 (file)
@@ -11,6 +11,8 @@
  * information regarding copyright ownership.
  */
 
+{% set server_config_use_addr = server_config_use_addr | default(False) %}
+
 key rndc_key {
        secret "1234abcd8765";
        algorithm @DEFAULT_HMAC@;
@@ -49,7 +51,11 @@ zone "example" {
 
 zone "example.org" {
        type static-stub;
-       SERVER_CONFIG_PLACEHOLDER
+{% if server_config_use_addr %}
+       server-addresses { 10.53.0.4; };
+{% else %}
+       server-names { "ns.example.net"; };
+{% endif %}
 };
 
 zone "example.info" {
diff --git a/bin/tests/system/staticstub/ns2/named2.conf.j2 b/bin/tests/system/staticstub/ns2/named2.conf.j2
new file mode 100644 (file)
index 0000000..04b3364
--- /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 server_config_use_addr = True %}
+
+{% include "ns2/named.conf.j2" %}
similarity index 87%
rename from bin/tests/system/staticstub/ns3/named.conf.in
rename to bin/tests/system/staticstub/ns3/named.conf.j2
index d6ff10c97a0bf2709f82da3996242b0e0cc19fc4..690e7199ae6de22e3784d1f5922ba0248cbf08b6 100644 (file)
@@ -11,6 +11,8 @@
  * information regarding copyright ownership.
  */
 
+{% set example_zone = example_zone | default(True) %}
+
 key rndc_key {
        secret "1234abcd8765";
        algorithm @DEFAULT_HMAC@;
@@ -33,7 +35,12 @@ options {
        notify no;
 };
 
-EXAMPLE_ZONE_PLACEHOLDER
+{% if example_zone %}
+zone "example" {
+       type primary;
+       file "example.db.signed";
+};
+{% endif %}
 
 zone "example.org" {
        type primary;
diff --git a/bin/tests/system/staticstub/ns3/named1.conf.j2 b/bin/tests/system/staticstub/ns3/named1.conf.j2
new file mode 100644 (file)
index 0000000..d0f4cf0
--- /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 example_zone = True %}
+
+{% include "ns3/named.conf.j2" %}
diff --git a/bin/tests/system/staticstub/ns3/named2.conf.j2 b/bin/tests/system/staticstub/ns3/named2.conf.j2
new file mode 100644 (file)
index 0000000..b401bbb
--- /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 example_zone = False %}
+
+{% include "ns3/named.conf.j2" %}
index 38e2218363d98c671c10e8cb71c5cf9986b20a4b..119cd3d3f92da1c4932806a99d29bb0fc05f6a19 100755 (executable)
 
 . ../conf.sh
 
-copy_setports ns1/named.conf.in ns1/named.conf
-copy_setports ns2/named.conf.in tmp
-sed 's/SERVER_CONFIG_PLACEHOLDER/server-names { "ns.example.net"; };/' tmp >ns2/named.conf
-
-copy_setports ns3/named.conf.in tmp
-sed 's/EXAMPLE_ZONE_PLACEHOLDER/zone "example" { type primary; file "example.db.signed"; };/' tmp >ns3/named.conf
-
-copy_setports ns4/named.conf.in ns4/named.conf
-
 cd ns3 && $SHELL -e sign.sh
index 3d63aab29437ca9fc54fd03565465e4354f82341..a34df23cdc9576066fd9fd1bf627d518282bd3de 100755 (executable)
@@ -101,8 +101,7 @@ ret=0
 $DIG $DIGOPTS +tcp data1.sub.example. @10.53.0.2 txt >dig.out.ns2.test1.$n || ret=1
 grep "1st sub test data" dig.out.ns2.test1.$n >/dev/null || ret=1
 # temporarily disable the the parent zone
-copy_setports ns3/named.conf.in tmp
-sed 's/EXAMPLE_ZONE_PLACEHOLDER//' tmp >ns3/named.conf
+cp ns3/named2.conf ns3/named.conf
 rndc_reload ns3 10.53.0.3
 # query the child zone again.  this should directly go to the child and
 # succeed.
@@ -113,8 +112,7 @@ for i in 0 1 2 3 4 5 6 7 8 9; do
 done
 grep "2nd sub test data" dig.out.ns2.test2.$n >/dev/null || ret=1
 # re-enable the parent
-copy_setports ns3/named.conf.in tmp
-sed 's/EXAMPLE_ZONE_PLACEHOLDER/zone "example" { type primary; file "example.db.signed"; };/' tmp >ns3/named.conf
+cp ns3/named1.conf ns3/named.conf
 rndc_reload ns3 10.53.0.3
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
@@ -193,8 +191,7 @@ status=$((status + ret))
 n=$((n + 1))
 echo_i "checking server reload with a different static-stub config ($n)"
 ret=0
-copy_setports ns2/named.conf.in tmp
-sed 's/SERVER_CONFIG_PLACEHOLDER/server-addresses { 10.53.0.4; };/' tmp >ns2/named.conf
+cp ns2/named2.conf ns2/named.conf
 rndc_reload ns2 10.53.0.2
 $DIG $DIGOPTS +tcp data2.example.org. @10.53.0.2 txt >dig.out.ns2.test$n || ret=1
 grep "2nd example org data" dig.out.ns2.test$n >/dev/null || ret=1