]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Rewrite glue system test to pytest
authorMichal Nowak <mnowak@isc.org>
Thu, 7 Mar 2024 13:58:38 +0000 (14:58 +0100)
committerMichal Nowak <mnowak@isc.org>
Tue, 19 Mar 2024 19:38:28 +0000 (20:38 +0100)
(cherry picked from commit 9950f6d651770d3ddd25873b5614f3d440797fec)

bin/tests/system/glue/clean.sh
bin/tests/system/glue/fi.good [deleted file]
bin/tests/system/glue/noglue.good [deleted file]
bin/tests/system/glue/tests.sh [deleted file]
bin/tests/system/glue/tests_glue.py [new file with mode: 0644]
bin/tests/system/glue/tests_sh_glue.py [deleted file]

index 4d84f068f895a0e46c64d9bc822c1e699568d58e..498baf923a279f60ff93bf8741c4f91eef03c58e 100644 (file)
@@ -15,7 +15,6 @@
 # Clean up after glue tests.
 #
 
-rm -f dig.out
 rm -f */named.conf
 rm -f */named.memstats
 rm -f */named.run
diff --git a/bin/tests/system/glue/fi.good b/bin/tests/system/glue/fi.good
deleted file mode 100644 (file)
index a08bc7a..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-
-; <<>> DiG 9.0 <<>> +norec @10.53.0.1 -p 5300 foo.bar.fi. A
-;; global options:  printcmd
-;; Got answer:
-;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58772
-;; flags: qr ad; QUERY: 1, ANSWER: 0, AUTHORITY: 6, ADDITIONAL: 7
-
-;; QUESTION SECTION:
-;foo.bar.fi.                   IN      A
-
-;; AUTHORITY SECTION:
-fi.                    172800  IN      NS      NS.EU.NET.
-fi.                    172800  IN      NS      NS.TELE.fi.
-fi.                    172800  IN      NS      PRIFI.EUNET.fi.
-fi.                    172800  IN      NS      NS.UU.NET.
-fi.                    172800  IN      NS      T.NS.VERIO.NET.
-fi.                    172800  IN      NS      HYDRA.HELSINKI.fi.
-
-;; ADDITIONAL SECTION:
-NS.TELE.fi.            172800  IN      A       193.210.19.19
-NS.TELE.fi.            172800  IN      A       193.210.18.18
-PRIFI.EUNET.fi.                172800  IN      A       193.66.1.146
-NS.UU.NET.             172800  IN      A       137.39.1.3
-T.NS.VERIO.NET.                172800  IN      A       192.67.14.16
-HYDRA.HELSINKI.fi.     172800  IN      A       128.214.4.29
-NS.EU.NET.             172800  IN      A       192.16.202.11
-
diff --git a/bin/tests/system/glue/noglue.good b/bin/tests/system/glue/noglue.good
deleted file mode 100644 (file)
index 22eca7b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-
-; <<>> DiG 9.0 <<>> @10.53.0.1 -p 5300 example.net a
-;; global options:  printcmd
-;; Got answer:
-;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29409
-;; flags: qr rd ad; QUERY: 1, ANSWER: 0, AUTHORITY: 2, ADDITIONAL: 0
-
-;; QUESTION SECTION:
-;example.net.                  IN      A
-
-;; AUTHORITY SECTION:
-example.net.           300     IN      NS      ns2.example.
-example.net.           300     IN      NS      ns1.example.
-
diff --git a/bin/tests/system/glue/tests.sh b/bin/tests/system/glue/tests.sh
deleted file mode 100644 (file)
index 0bfae45..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-# 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.
-
-set -e
-
-. ../conf.sh
-
-#
-# Do glue tests.
-#
-
-DIGOPTS="+norec -p ${PORT}"
-
-status=0
-
-echo_i "testing that a ccTLD referral gets a full glue set from the root zone"
-$DIG $DIGOPTS @10.53.0.1 foo.bar.fi. A >dig.out || status=1
-digcomp --lc fi.good dig.out || status=1
-
-echo_i "testing that we don't find out-of-zone glue"
-$DIG $DIGOPTS @10.53.0.1 example.net. a >dig.out || status=1
-digcomp noglue.good dig.out || status=1
-
-echo_i "exit status: $status"
-[ $status -eq 0 ] || exit 1
diff --git a/bin/tests/system/glue/tests_glue.py b/bin/tests/system/glue/tests_glue.py
new file mode 100644 (file)
index 0000000..a209c8b
--- /dev/null
@@ -0,0 +1,65 @@
+# 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.
+
+import dns.message
+
+import isctest
+
+
+def test_glue_full_glue_set():
+    """test that a ccTLD referral gets a full glue set from the root zone"""
+    msg = dns.message.make_query("foo.bar.fi", "A")
+    msg.flags &= ~dns.flags.RD
+    res = isctest.query.udp(msg, "10.53.0.1")
+
+    answer = """;ANSWER
+;AUTHORITY
+fi. 172800 IN NS HYDRA.HELSINKI.fi.
+fi. 172800 IN NS NS.EU.NET.
+fi. 172800 IN NS NS.UU.NET.
+fi. 172800 IN NS NS.TELE.fi.
+fi. 172800 IN NS T.NS.VERIO.NET.
+fi. 172800 IN NS PRIFI.EUNET.fi.
+;ADDITIONAL
+NS.TELE.fi. 172800 IN A 193.210.18.18
+NS.TELE.fi. 172800 IN A 193.210.19.19
+PRIFI.EUNET.fi. 172800 IN A 193.66.1.146
+HYDRA.HELSINKI.fi. 172800 IN A 128.214.4.29
+NS.EU.NET. 172800 IN A 192.16.202.11
+T.NS.VERIO.NET. 172800 IN A 192.67.14.16
+NS.UU.NET. 172800 IN A 137.39.1.3
+"""
+    expected_answer = dns.message.from_text(answer)
+
+    isctest.check.noerror(res)
+    isctest.check.rrsets_equal(res.answer, expected_answer.answer)
+    isctest.check.rrsets_equal(res.authority, expected_answer.authority)
+    isctest.check.rrsets_equal(res.additional, expected_answer.additional)
+
+
+def test_glue_no_glue_set():
+    """test that out-of-zone glue is not found"""
+    msg = dns.message.make_query("example.net.", "A")
+    msg.flags &= ~dns.flags.RD
+    res = isctest.query.udp(msg, "10.53.0.1")
+
+    answer = """;ANSWER
+;AUTHORITY
+example.net. 300 IN NS ns2.example.
+example.net. 300 IN NS ns1.example.
+;ADDITIONAL
+"""
+    expected_answer = dns.message.from_text(answer)
+
+    isctest.check.noerror(res)
+    isctest.check.rrsets_equal(res.answer, expected_answer.answer)
+    isctest.check.rrsets_equal(res.authority, expected_answer.authority)
+    isctest.check.rrsets_equal(res.additional, expected_answer.additional)
diff --git a/bin/tests/system/glue/tests_sh_glue.py b/bin/tests/system/glue/tests_sh_glue.py
deleted file mode 100644 (file)
index 4f3ff04..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-
-def test_glue(run_tests_sh):
-    run_tests_sh()