test: add simple integration test for delegation feature

This commit is contained in:
Lennart Poettering
2025-05-09 10:28:53 +02:00
parent 89768b601b
commit 88d2cb3668
3 changed files with 44 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ server:
user: knot:knot
listen: 10.0.0.1@53
listen: fd00:dead:beef:cafe::1@53
listen: 192.168.77.78@53
log:
- target: syslog

View File

@@ -22,3 +22,5 @@ unsigned NS ns1.unsigned
svcb SVCB 1 . alpn=dot ipv4hint=10.0.0.1 ipv6hint=fd00:dead:beef:cafe::1
https HTTPS 1 . alpn="h2,h3"
delegation.excercise A 1.2.3.4

View File

@@ -1302,6 +1302,47 @@ testcase_15_wait_online_dns() {
journalctl -b -u "$unit" --grep="dns0: link is configured by networkd and online." > /dev/null
}
testcase_delegate() {
# Before we install the delegation file the DNS name should be directly resolveable via our DNS server
run resolvectl query delegation.excercise.test
grep -qF "1.2.3.4" "$RUN_OUT"
mkdir -p /run/systemd/dns-delegate.d/
cat >/run/systemd/dns-delegate.d/testcase.dns-delegate <<EOF
[Delegate]
DNS=192.168.77.78
Domains=excercise.test
EOF
systemctl reload systemd-resolved
resolvectl status
# Now that we installed the delegation the resolution should fail, because nothing is listening on that IP address
(! resolvectl query delegation.excercise.test)
# Now make that IP address connectible
ip link add delegate0 type dummy
ip addr add 192.168.77.78 dev delegate0
# This should work now
run resolvectl query delegation.excercise.test
grep -qF "1.2.3.4" "$RUN_OUT"
ip link del delegate0
# Let's restart here, as a way to ensure the rtnetlink delete is definitely processed.
systemctl restart systemd-resolved
# Should no longer work
(! resolvectl query delegation.excercise.test)
rm /run/systemd/dns-delegate.d/testcase.dns-delegate
systemctl reload systemd-resolved
# Should work again without delegation in the mix
run resolvectl query delegation.excercise.test
grep -qF "1.2.3.4" "$RUN_OUT"
}
# PRE-SETUP
systemctl unmask systemd-resolved.service
systemctl enable --now systemd-resolved.service