]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add simple integration test for delegation feature 34368/head
authorLennart Poettering <lennart@poettering.net>
Fri, 9 May 2025 08:28:53 +0000 (10:28 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 20 May 2025 21:00:53 +0000 (23:00 +0200)
test/knot-data/knot.conf
test/knot-data/zones/test.zone
test/units/TEST-75-RESOLVED.sh

index 6d177d728591ef6069858587251988ab044197f0..8519a6c7e57f8df5335e051bf29f3a01e6d2517d 100644 (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
index 065ff7e2a00f92414eefae3a2d8483801142d40b..75583c4ce6fde099d5c7f647bfdd28777e94cce9 100644 (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
index be3a90385dc553401f22a71f1f5de9a3fe4083a0..6570febe7965a0793d29460ae9d9a0bffd59bdd9 100755 (executable)
@@ -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