Commit 08d992c37d for bind

commit 08d992c37d10163b70ff1524e9bfbf2ec7941c1b
Author: Nicki Křížek <nicki@isc.org>
Date:   Mon Oct 26 17:06:20 2026 +0000

    Test RRset lookups in the response a handler is given

    The ans1 handler looks up an RRset from zone data and one it appended
    itself with get_rrset(), and answers with what it found.

    Assisted-by: Claude:claude-opus-5-5

diff --git a/bin/tests/system/isctest/asyncserver/tests/response_handling/ans1/ans.py b/bin/tests/system/isctest/asyncserver/tests/response_handling/ans1/ans.py
index 353ced1c0b..a7a89a0f8f 100644
--- a/bin/tests/system/isctest/asyncserver/tests/response_handling/ans1/ans.py
+++ b/bin/tests/system/isctest/asyncserver/tests/response_handling/ans1/ans.py
@@ -45,6 +45,27 @@ class FreshResponseHandler(ResponseHandler):
         yield DnsResponseSend(qctx.prepare_new_response(with_zone_data=False))


+class LookupHandler(ResponseHandler):
+    """
+    Look up an RRset from zone data and one appended by the handler in the
+    prepared response, then answer with only the RRsets found.
+    """
+
+    matcher = Qname(f"lookup.{ZONE}")
+
+    async def get_responses(
+        self, qctx: QueryContext
+    ) -> AsyncGenerator[DnsResponseSend, None]:
+        response = qctx.response
+        response.answer.append(txt(qctx.qname, "appended by the handler"))
+        found = [
+            response.get_rrset(response.answer, qctx.qname, dns.rdataclass.IN, rdtype)
+            for rdtype in (dns.rdatatype.A, dns.rdatatype.TXT)
+        ]
+        response.answer = [rrset for rrset in found if rrset is not None]
+        yield DnsResponseSend(response)
+
+
 class RenderedBeforeSendHandler(ResponseHandler):
     """
     Render the response to wire before changing it, as a handler measuring
@@ -82,6 +103,7 @@ def main() -> None:
     server = AsyncDnsServer(default_aa=True, default_rcode=dns.rcode.NOTIMP)
     server.install_response_handlers(
         FreshResponseHandler(),
+        LookupHandler(),
         RenderedBeforeSendHandler(),
         RollbackHandler(),
     )
diff --git a/bin/tests/system/isctest/asyncserver/tests/response_handling/ans1/zones/response.test.db b/bin/tests/system/isctest/asyncserver/tests/response_handling/ans1/zones/response.test.db
index d24d0681b0..5dcec80f02 100644
--- a/bin/tests/system/isctest/asyncserver/tests/response_handling/ans1/zones/response.test.db
+++ b/bin/tests/system/isctest/asyncserver/tests/response_handling/ans1/zones/response.test.db
@@ -6,3 +6,4 @@ response.test.           300 IN NS    ns.response.test.
 ns.response.test.        300 IN A     10.53.0.1
 rollback.response.test.  300 IN A     192.0.2.1
 rendered.response.test.  300 IN A     192.0.2.2
+lookup.response.test.    300 IN A     192.0.2.3
diff --git a/bin/tests/system/isctest/asyncserver/tests/response_handling/tests_response_handling.py b/bin/tests/system/isctest/asyncserver/tests/response_handling/tests_response_handling.py
index 99b78dd5cb..1196085eec 100644
--- a/bin/tests/system/isctest/asyncserver/tests/response_handling/tests_response_handling.py
+++ b/bin/tests/system/isctest/asyncserver/tests/response_handling/tests_response_handling.py
@@ -47,6 +47,20 @@ def test_fresh_response_keeps_the_server_defaults():
     isctest.check.empty_authority(res)


+def test_rrsets_in_the_prepared_response_are_found():
+    res = query("lookup.response.test.")
+    isctest.check.noerror(res)
+    isctest.check.section_equal(
+        res.answer,
+        [
+            dns.rrset.from_text("lookup.response.test.", 300, "IN", "A", "192.0.2.3"),
+            dns.rrset.from_text(
+                "lookup.response.test.", 300, "IN", "TXT", '"appended by the handler"'
+            ),
+        ],
+    )
+
+
 def test_changes_after_rendering_reach_the_wire():
     res = query("rendered.response.test.")
     isctest.check.noerror(res)