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).
This commit is contained in:
Nicki Křížek 2025-12-05 17:39:23 +01:00
parent 1da733a015
commit 2592f0d961
10 changed files with 41 additions and 45 deletions

View 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 %}

View 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 %}

View 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

View 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

View 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")