Commit 505c9d2316 for bind
commit 505c9d2316f02e60db3944fabc04d0812d35f884
Author: Štěpán Balážik <stepan@isc.org>
Date: Wed Oct 21 12:28:03 2026 +0200
Negotiate the GSS-TSIG context with dnspython's TKEY adapter
The GSS context test framed the TCP exchange and stepped the GSS
context by hand: an unverified parse of the TKEY answer, a context
step and a second parse to verify the answer's TSIG. With
dns.tsig.GSSTSigAdapter as the query's keyring, dns.query.tcp() does
all of that in one call.
Assisted-by: Claude:claude-fable-5-1
diff --git a/bin/tests/system/tsiggss/tests_gss_context.py b/bin/tests/system/tsiggss/tests_gss_context.py
index bcea0fc800..829c48ab98 100644
--- a/bin/tests/system/tsiggss/tests_gss_context.py
+++ b/bin/tests/system/tsiggss/tests_gss_context.py
@@ -17,7 +17,6 @@ restart.
import concurrent.futures
import os
import socket
-import struct
import time
import dns.message
@@ -43,15 +42,6 @@ pytestmark = [
]
-def read_exact(sock, count):
- data = bytearray()
- while len(data) < count:
- chunk = sock.recv(count - len(data))
- assert chunk
- data.extend(chunk)
- return bytes(data)
-
-
def establish(ns1, monkeypatch):
"""
Negotiate using the existing ticket cache, without contacting a KDC.
@@ -85,19 +75,12 @@ def establish(ns1, monkeypatch):
token,
)
query.additional.append(dns.rrset.from_rdata(name, 0, tkey))
- wire = query.to_wire(prepend_length=True)
- with socket.create_connection((ns1.ip, ns1.ports.dns), timeout=5) as sock:
- sock.sendall(wire)
- size = struct.unpack("!H", read_exact(sock, 2))[0]
- response_wire = read_exact(sock, size)
- response = dns.message.from_wire(response_wire, keyring=False)
+ keyring = {name: dns.tsig.Key(name, context, dns.tsig.GSS_TSIG)}
+ query.keyring = dns.tsig.GSSTSigAdapter(keyring)
+ response = dns.query.tcp(query, ns1.ip, port=ns1.ports.dns, timeout=5)
assert response.rcode() == dns.rcode.NOERROR
assert response.answer[0][0].error == 0
- context.step(response.answer[0][0].key)
assert context.complete
- key = dns.tsig.Key(name, context, dns.tsig.GSS_TSIG)
- keyring = {name: key}
- dns.message.from_wire(response_wire, keyring=keyring)
return keyring