From: Štěpán Balážik Date: Wed, 29 Apr 2026 08:31:17 +0000 (+0200) Subject: fixup! Reimplement the FORMERR system test in Python X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8942c14a28533f55cb1ae57638acef72b56709aa;p=thirdparty%2Fbind9.git fixup! Reimplement the FORMERR system test in Python --- diff --git a/bin/tests/system/formerr/badnsec3owner b/bin/tests/system/formerr/badnsec3owner deleted file mode 100644 index de6e692b17b..00000000000 --- a/bin/tests/system/formerr/badnsec3owner +++ /dev/null @@ -1,7 +0,0 @@ -# bad NSEC3 owner (:) not in base32hex valid characters -# header: id=0008 opcode=query questions=1 authority=1 -00 08 00 00 00 01 00 00 00 01 00 00 -# question: ./A/IN -00 00 01 00 01 -# :./NSEC3/IN/1 length=7 hashtype=240 flags=0 interations=0 salt=- hashlen=1 hash=ff -01 58 00 00 32 00 01 00 00 00 01 00 07 f0 00 00 00 00 01 ff diff --git a/bin/tests/system/formerr/badrecordname b/bin/tests/system/formerr/badrecordname deleted file mode 100644 index f79df49181b..00000000000 --- a/bin/tests/system/formerr/badrecordname +++ /dev/null @@ -1,21 +0,0 @@ -# oversized owner name -# header: additional=1 -00 00 00 00 00 00 00 00 00 00 00 01 -# owner name too big (256 octets) A/IN/1 0.0.0.0 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0e 41 41 41 41 41 41 41 41 41 41 41 41 41 41 00 -00 01 00 01 00 00 00 01 00 04 00 00 00 00 diff --git a/bin/tests/system/formerr/dupans b/bin/tests/system/formerr/dupans deleted file mode 100644 index 142022a7e93..00000000000 --- a/bin/tests/system/formerr/dupans +++ /dev/null @@ -1,8 +0,0 @@ -# multiple singletons (SOA) -# header questions=1 answers=2 -00 00 00 00 00 01 00 02 00 00 00 00 -# question SOA/IN -00 00 06 00 01 -# 2 SOA records that differ in expire -00 00 06 00 01 00 00 00 01 00 16 00 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 -00 00 06 00 01 00 00 00 01 00 16 00 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 06 diff --git a/bin/tests/system/formerr/dupquestion b/bin/tests/system/formerr/dupquestion deleted file mode 100644 index 327b8ca2588..00000000000 --- a/bin/tests/system/formerr/dupquestion +++ /dev/null @@ -1,10 +0,0 @@ -# header: 2 questions -00 00 00 00 00 02 00 00 00 00 00 00 -# question: AAAAAAAAAAAAAA./A/IN -0e 41 41 41 41 41 41 41 41 41 41 41 41 41 41 00 -00 01 -00 01 -# question: AAAAAAAAAAAAAA./A/IN -0e 41 41 41 41 41 41 41 41 41 41 41 41 41 41 00 -00 01 -00 01 diff --git a/bin/tests/system/formerr/keyclass b/bin/tests/system/formerr/keyclass deleted file mode 100644 index c84568afee1..00000000000 --- a/bin/tests/system/formerr/keyclass +++ /dev/null @@ -1,7 +0,0 @@ -# mismatched key class -# header: questions=1 additional=1 -00 00 00 00 00 01 00 00 00 00 00 01 -# question: ./A/IN -00 00 01 00 01 -# additional: ./KEY/CLASS2 flags=0 protocol=0 algorithm=248 keydata=00 -00 00 19 00 02 00 00 00 01 00 05 00 00 00 f8 00 diff --git a/bin/tests/system/formerr/malformeddeltype b/bin/tests/system/formerr/malformeddeltype deleted file mode 100644 index 2d14ae41de6..00000000000 --- a/bin/tests/system/formerr/malformeddeltype +++ /dev/null @@ -1,5 +0,0 @@ -# UPDATE malformed 'delete type' update change (non empty data) -# header: UPDATE authority=1 -00 00 28 00 00 00 00 00 00 01 00 00 -# ./A/ANY TTL=0 length=1 data=00 -00 00 01 00 ff 00 00 00 00 00 01 00 diff --git a/bin/tests/system/formerr/malformedrrsig b/bin/tests/system/formerr/malformedrrsig deleted file mode 100644 index 07d2af021ad..00000000000 --- a/bin/tests/system/formerr/malformedrrsig +++ /dev/null @@ -1,5 +0,0 @@ -# malformed RRRSIG -# header: QUERY, additional=1 -00 00 00 00 00 00 00 00 00 00 00 01 -# ./RRSIG/IN TTL=1 covers=0 algorithm=240 labels=0 ttl=1 expire=2 signed=3 id=0 -00 00 2e 00 01 00 00 00 01 00 14 00 00 f0 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 00 diff --git a/bin/tests/system/formerr/nametoolong b/bin/tests/system/formerr/nametoolong deleted file mode 100644 index b81545fadc5..00000000000 --- a/bin/tests/system/formerr/nametoolong +++ /dev/null @@ -1,19 +0,0 @@ -00 00 00 00 00 01 00 00 00 00 00 00 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 -0e 41 41 41 41 41 41 41 41 41 41 41 41 41 41 00 -00 01 -00 01 diff --git a/bin/tests/system/formerr/noquestions b/bin/tests/system/formerr/noquestions deleted file mode 100644 index f087bcd4b37..00000000000 --- a/bin/tests/system/formerr/noquestions +++ /dev/null @@ -1 +0,0 @@ -00 00 00 00 00 00 00 00 00 00 00 00 diff --git a/bin/tests/system/formerr/optwrongname b/bin/tests/system/formerr/optwrongname deleted file mode 100644 index 7b486d932b6..00000000000 --- a/bin/tests/system/formerr/optwrongname +++ /dev/null @@ -1,5 +0,0 @@ -# OPT record with wrong name (not .) -# header: QUERY, additional=1 -00 00 00 00 00 00 00 00 00 00 00 01 -# OPT record (owner A.) -01 41 00 00 29 00 01 00 00 00 00 00 00 diff --git a/bin/tests/system/formerr/qtypeasanswer b/bin/tests/system/formerr/qtypeasanswer deleted file mode 100644 index d254d1d42f9..00000000000 --- a/bin/tests/system/formerr/qtypeasanswer +++ /dev/null @@ -1,5 +0,0 @@ -# QTYPE-only type as answer -# header, answers=1 -00 00 00 00 00 00 00 01 00 00 00 00 -# ./MAILB/IN -00 00 fd 00 01 00 00 00 01 00 00 diff --git a/bin/tests/system/formerr/questionclass b/bin/tests/system/formerr/questionclass deleted file mode 100644 index b34d1e30f52..00000000000 --- a/bin/tests/system/formerr/questionclass +++ /dev/null @@ -1,7 +0,0 @@ -# two questions of different classes -# header: QUERY, questions=2 -00 00 00 00 00 02 00 00 00 00 00 00 -# ./A/IN -00 00 01 00 01 -# ./A/CLASS2 -00 00 01 00 02 diff --git a/bin/tests/system/formerr/shortquestion b/bin/tests/system/formerr/shortquestion deleted file mode 100644 index 168ed902edd..00000000000 --- a/bin/tests/system/formerr/shortquestion +++ /dev/null @@ -1,5 +0,0 @@ -# truncated question section -# header: QUERY, questions=1 -00 00 00 00 00 01 00 00 00 00 00 00 -# truncated question (no class) -00 00 01 diff --git a/bin/tests/system/formerr/shortrecord b/bin/tests/system/formerr/shortrecord deleted file mode 100644 index d9a2ab7c43f..00000000000 --- a/bin/tests/system/formerr/shortrecord +++ /dev/null @@ -1,5 +0,0 @@ -# truncated record -# header: QUERY, additional=1 -00 09 00 00 00 00 00 00 00 00 00 01 -# truncated A record (no ttl, length or data) -00 00 01 00 01 diff --git a/bin/tests/system/formerr/tests_formerr.py b/bin/tests/system/formerr/tests_formerr.py index 5c412519810..c8e3d13a4a1 100644 --- a/bin/tests/system/formerr/tests_formerr.py +++ b/bin/tests/system/formerr/tests_formerr.py @@ -9,7 +9,6 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. -from pathlib import Path from typing import SupportsInt import socket @@ -294,28 +293,10 @@ def query_raw_tcp(host: str, port: int, packet_wire: bytes) -> dns.message.Messa return response -PACKET_DIR = Path(__file__).parent - - -def parse_packet_file(packet_name: str) -> bytes: - text = (PACKET_DIR / packet_name).read_text(encoding="utf-8") - hex_bytes = [] - for line in text.splitlines(): - line = line.split("#", 1)[0].strip() - if line: - hex_bytes.append(line) - return bytes.fromhex(" ".join(hex_bytes)) - - -def validate_packet(packet_name: str, generated_wire: bytes) -> None: - assert generated_wire == parse_packet_file(packet_name) - - @pytest.mark.parametrize( - "packet_name,query_wire,expected_wire", + "query_wire,expected_wire", [ pytest.param( - "nametoolong", wire( dns_header(qdcount=1), question_wire(oversized_name_wire()), @@ -324,7 +305,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="nametoolong", ), pytest.param( - "twoquestionnames", wire( dns_header(qdcount=2), question_wire(name_wire("AAAAAAAAAAAAAA."), dns.rdatatype.RdataType.A), @@ -338,7 +318,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="twoquestionnames", ), pytest.param( - "twoquestiontypes", wire( dns_header(qdcount=2), question_wire(name_wire("AAAAAAAAAAAAAA."), dns.rdatatype.RdataType.A), @@ -348,7 +327,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="twoquestiontypes", ), pytest.param( - "dupquestion", wire( dns_header(qdcount=2), question_wire(name_wire("AAAAAAAAAAAAAA."), dns.rdatatype.RdataType.A), @@ -358,7 +336,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="dupquestion", ), pytest.param( - "dupans", wire( dns_header(qdcount=1, ancount=2), question_wire(root_wire(), dns.rdatatype.RdataType.SOA), @@ -372,7 +349,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="dupans", ), pytest.param( - "qtypeasanswer", wire( dns_header(ancount=1), rr_wire( @@ -386,7 +362,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="qtypeasanswer", ), pytest.param( - "noquestions", dns_header(), # This would be NOERROR if it included a COOKIE option, # but is a FORMERR without one. @@ -394,7 +369,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="noquestions", ), pytest.param( - "badnsec3owner", wire( dns_header(message_id=8, qdcount=1, nscount=1), question_wire(root_wire(), dns.rdatatype.RdataType.A), @@ -410,7 +384,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="badnsec3owner", ), pytest.param( - "shortrecord", wire( dns_header(message_id=9, arcount=1), # Truncated A record (no ttl, length or data) @@ -420,7 +393,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="shortrecord", ), pytest.param( - "shortquestion", wire( dns_header(qdcount=1), # Truncated question (no class) @@ -431,7 +403,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="shortquestion", ), pytest.param( - "questionclass", wire( dns_header(qdcount=2), question_wire( @@ -449,7 +420,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="questionclass", ), pytest.param( - "badrecordname", wire( dns_header(arcount=1), a_rr(owner=oversized_name_wire()), @@ -458,7 +428,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="badrecordname", ), pytest.param( - "wrongclass", wire( dns_header(arcount=2), a_rr(), @@ -474,7 +443,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="wrongclass", ), pytest.param( - "keyclass", wire( dns_header(qdcount=1, arcount=1), question_wire(root_wire(), dns.rdatatype.RdataType.A), @@ -487,7 +455,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="keyclass", ), pytest.param( - "optwrongname", wire( dns_header(arcount=1), # OPT owner should be root @@ -497,7 +464,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="optwrongname", ), pytest.param( - "malformedrrsig", wire( dns_header(arcount=1), malformed_rrsig_rr(), @@ -506,7 +472,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="malformedrrsig", ), pytest.param( - "malformeddeltype", wire( dns_header(opcode=dns.opcode.UPDATE, nscount=1), rr_wire( @@ -522,7 +487,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="malformeddeltype", ), pytest.param( - "tsigwrongclass", wire( dns_header(arcount=1), # Class should be ANY not IN @@ -532,7 +496,6 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: id="tsigwrongclass", ), pytest.param( - "tsignotlast", wire( dns_header(arcount=2), tsig_rr(), @@ -545,12 +508,10 @@ def validate_packet(packet_name: str, generated_wire: bytes) -> None: ], ) def test_formerr( - packet_name: str, query_wire: bytes, expected_wire: bytes, named_port: int, ns1, ) -> None: - validate_packet(packet_name, query_wire) response = query_raw_tcp(ns1.ip, named_port, query_wire) assert response.to_wire() == expected_wire diff --git a/bin/tests/system/formerr/tsignotlast b/bin/tests/system/formerr/tsignotlast deleted file mode 100644 index 108936c51f6..00000000000 --- a/bin/tests/system/formerr/tsignotlast +++ /dev/null @@ -1,8 +0,0 @@ -# SIG not last in additional -# header: QUERY additional=2 -00 00 00 00 00 00 00 00 00 00 00 02 -# Additional records: -# SIG record (class ANY) -00 00 fa 00 ff 00 00 00 01 00 12 00 01 02 03 04 05 06 01 02 00 01 00 00 00 00 00 00 00 -# A record -00 00 01 00 01 00 00 00 01 00 04 00 00 00 00 diff --git a/bin/tests/system/formerr/tsigwrongclass b/bin/tests/system/formerr/tsigwrongclass deleted file mode 100644 index 29aea084aa0..00000000000 --- a/bin/tests/system/formerr/tsigwrongclass +++ /dev/null @@ -1,5 +0,0 @@ -# TSIG wrong class -# header: QUERY, additional=1 -00 00 00 00 00 00 00 00 00 00 00 01 -# class should be ANY (00 ff) not IN (00 01) -00 00 fa 00 01 00 00 00 01 00 12 00 01 02 03 04 05 06 01 02 00 01 00 00 00 00 00 00 00 diff --git a/bin/tests/system/formerr/twoquestionnames b/bin/tests/system/formerr/twoquestionnames deleted file mode 100644 index f363a23c357..00000000000 --- a/bin/tests/system/formerr/twoquestionnames +++ /dev/null @@ -1,11 +0,0 @@ -# two questions with different names -00 00 00 00 00 02 00 00 00 00 00 00 -# AAAAAAAAAAAAAA./A/IN -0e 41 41 41 41 41 41 41 41 41 41 41 41 41 41 00 -00 01 -00 01 -# AAAAAAAAAAAAAB./A/IN -0e 41 41 41 41 41 41 41 41 41 41 41 41 41 41 00 -0e 41 41 41 41 41 41 41 41 41 41 41 41 41 42 00 -00 01 -00 01 diff --git a/bin/tests/system/formerr/twoquestiontypes b/bin/tests/system/formerr/twoquestiontypes deleted file mode 100644 index 451f8f6ee4e..00000000000 --- a/bin/tests/system/formerr/twoquestiontypes +++ /dev/null @@ -1,10 +0,0 @@ -# two questions that differ by type -00 00 00 00 00 02 00 00 00 00 00 00 -# AAAAAAAAAAAAAAA./A/IN -0e 41 41 41 41 41 41 41 41 41 41 41 41 41 41 00 -00 01 -00 01 -# AAAAAAAAAAAAAAA./NS/IN -0e 41 41 41 41 41 41 41 41 41 41 41 41 41 41 00 -00 02 -00 01 diff --git a/bin/tests/system/formerr/wrongclass b/bin/tests/system/formerr/wrongclass deleted file mode 100644 index 96211e07a8f..00000000000 --- a/bin/tests/system/formerr/wrongclass +++ /dev/null @@ -1,7 +0,0 @@ -# class mismatch -# header: QUERY, additional=2 -00 00 00 00 00 00 00 00 00 00 00 02 -# ./A/IN -00 00 01 00 01 00 00 00 01 00 04 00 00 00 00 -# ./TYPE65280/CLASS256 -00 ff 00 01 00 02 00 00 01 00 04 00 00 00 00