bind9/bin/tests/system/ede24/common.py
Michal Nowak 27ee27d4e3
Add isctest.transfer.transfer_message() helper and convert tests
Add a new helper function, isctest.transfer.transfer_message(), to
bin/tests/system/isctest/transfer.py that generates the log message
produced by xfrin_log() in lib/dns/xfrin.c for an incoming zone
transfer:

    transfer of '<zone>/IN' from <source_ns>#<port>: <msg>

The helper always returns a compiled re.Pattern.  source_ns and port
each accept None to match any source address / port.  msg accepts
either a plain str (regex-escaped automatically) or a compiled
re.Pattern (spliced into the regex as-is), so callers that need regex
syntax in the message part can pass Re(r"...") without having to
wrap the whole result.

source_ns is passed through re.escape() when provided, so dots in
IPv4 addresses (e.g. "10.53.0.1") match a literal dot rather than
any character.

Convert the existing call sites across the system tests to use the
new helper.

Co-Authored-By: Nicki Křížek <nicki@isc.org>
Assisted-by: Claude:claude-sonnet-4-6
Assisted-by: Claude:claude-opus-4-7
2026-05-11 15:31:41 +02:00

39 lines
1.2 KiB
Python

# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
#
# SPDX-License-Identifier: MPL-2.0
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
from dns.edns import EDECode
import isctest
def check_soa_noerror():
msg = isctest.query.create("foo.fr", "SOA")
res = isctest.query.udp(msg, "10.53.0.2")
isctest.check.noerror(res)
def check_soa_servfail_ede24(edemsg):
msg = isctest.query.create("foo.fr", "SOA")
res = isctest.query.udp(msg, "10.53.0.2")
isctest.check.servfail(res)
isctest.check.ede(res, EDECode.INVALID_DATA, edemsg)
def check_ns2_ready(ns2, named_port):
# Sanity check that everything works first, once we're sure the foo.fr zone
# has transfered to ns2.
with ns2.watch_log_from_start() as watcher:
watcher.wait_for_line(
isctest.transfer.transfer_message(
"foo.fr", "10.53.0.1", "Transfer status: success", named_port
)
)
check_soa_noerror()