Add commonly used zone-related data (config snippet and zone file
snippets) as templates which can be reused by filling in different data.
Adjust the isctest.template.Zone to use filepath argument rather than
filename for clarity.
(cherry picked from commit
317cd1277910a2c680a043434ac7f9fa6d8df131)
--- /dev/null
+zone "." {
+ type hint;
+ file "../../_common/root.hint";
+};
--- /dev/null
+{% if zones is defined and zones %}
+{% for zone in zones.values() %}
+{% if zone.ns.name == ns.name %}
+zone "@zone.name@" {
+ type @zone.type@;
+ file "@zone.filepath@";
+};
+{% endif %}
+{% endfor %}
+{% endif %}
--- /dev/null
+{% if delegations is defined and delegations %}
+{% for zone in delegations %}
+{% include '_common/zones/ns.partial.db.j2' %}
+{% endfor %}
+{% endif %}
--- /dev/null
+@zone.name@. NS @zone.ns.name@.@zone.name@.
+@zone.ns.name@.@zone.name@. A @zone.ns.ip@
--- /dev/null
+$TTL 300
+. IN SOA . a.root.servers.nil. (
+ 2000042100 ; serial
+ 600 ; refresh
+ 600 ; retry
+ 1200 ; expire
+ 600 ; minimum
+)
+
+. NS a.root-servers.nil.
+a.root-servers.nil. A 10.53.0.1
+
+{% include '_common/zones/delegations.partial.db.j2' %}
--- /dev/null
+$ORIGIN @zone.name@.
+$TTL 300
+{% raw %}@{% endraw %} IN SOA @zone.ns.name@.@zone.name@. . (
+ 1 ; serial
+ 20 ; refresh (20 seconds)
+ 20 ; retry (20 seconds)
+ 1814400 ; expire (3 weeks)
+ 3600 ; minimum (1 hour)
+)
--- /dev/null
+{% include '_common/zones/soa.partial.db.j2' %}
+{% include '_common/zones/ns.partial.db.j2' %}
+{% include '_common/zones/delegations.partial.db.j2' %}
+
+a A 10.0.0.1
+b A 10.0.0.2
+c A 10.0.0.3
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from pathlib import Path
from re import compile as Re
from typing import Any
name: str
ns: Nameserver
type: str = "primary"
- filename: str | None = None
+ filepath: Path | None = field(default=None)
- def __post_init__(self):
- if self.filename is None:
- self.filename = f"{self.name}.db"
+ def __post_init__(self) -> None:
+ if self.filepath is None:
+ base = "root" if self.name == "." else self.name
+ self.filepath = Path(f"zones/{base}.db")
@dataclass
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
+from pathlib import Path
+
import shutil
from isctest.kasp import private_type_record
templates.render(f"ns2/{outfile}", tdata, template=f"ns2/{template}")
signer(f"-P -x -O full -o {zonename} -f {outfile}.signed {outfile}", cwd="ns2")
- return Zone(zonename, NS2, filename=f"{outfile}.signed")
+ return Zone(zonename, NS2, filepath=Path(f"{outfile}.signed"))
def configure_root(delegations: list[Zone]) -> TrustAnchor:
render_and_sign_zone(zonename, [csk_name], extra_options="-z")
zonename = f"going-straight-to-none-dynamic.{tld}"
- zones.append(Zone(zonename, NS3, filename=f"{zonename}.db.signed"))
+ zones.append(Zone(zonename, NS3, filepath=Path(f"{zonename}.db.signed")))
isctest.log.info(f"setup {zonename}")
# Key generation.
csk_name = keygen(f"-f KSK {keytimes} {zonename}", cwd="ns3").out.strip()