xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/glue/tests_glue.py (revision 32d1c65c71fbdb65a012e8392a62a757dd6853e9)
1# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
2#
3# SPDX-License-Identifier: MPL-2.0
4#
5# This Source Code Form is subject to the terms of the Mozilla Public
6# License, v. 2.0.  If a copy of the MPL was not distributed with this
7# file, you can obtain one at https://mozilla.org/MPL/2.0/.
8#
9# See the COPYRIGHT file distributed with this work for additional
10# information regarding copyright ownership.
11
12import dns.message
13
14import isctest
15
16
17def test_glue_full_glue_set():
18    """test that a ccTLD referral gets a full glue set from the root zone"""
19    msg = dns.message.make_query("foo.bar.fi", "A")
20    msg.flags &= ~dns.flags.RD
21    res = isctest.query.udp(msg, "10.53.0.1")
22
23    answer = """;ANSWER
24;AUTHORITY
25fi. 172800 IN NS HYDRA.HELSINKI.fi.
26fi. 172800 IN NS NS.EU.NET.
27fi. 172800 IN NS NS.UU.NET.
28fi. 172800 IN NS NS.TELE.fi.
29fi. 172800 IN NS T.NS.VERIO.NET.
30fi. 172800 IN NS PRIFI.EUNET.fi.
31;ADDITIONAL
32NS.TELE.fi. 172800 IN A 193.210.18.18
33NS.TELE.fi. 172800 IN A 193.210.19.19
34PRIFI.EUNET.fi. 172800 IN A 193.66.1.146
35HYDRA.HELSINKI.fi. 172800 IN A 128.214.4.29
36NS.EU.NET. 172800 IN A 192.16.202.11
37T.NS.VERIO.NET. 172800 IN A 192.67.14.16
38NS.UU.NET. 172800 IN A 137.39.1.3
39"""
40    expected_answer = dns.message.from_text(answer)
41
42    isctest.check.noerror(res)
43    isctest.check.rrsets_equal(res.answer, expected_answer.answer)
44    isctest.check.rrsets_equal(res.authority, expected_answer.authority)
45    isctest.check.rrsets_equal(res.additional, expected_answer.additional)
46
47
48def test_glue_no_glue_set():
49    """test that out-of-zone glue is not found"""
50    msg = dns.message.make_query("example.net.", "A")
51    msg.flags &= ~dns.flags.RD
52    res = isctest.query.udp(msg, "10.53.0.1")
53
54    answer = """;ANSWER
55;AUTHORITY
56example.net. 300 IN NS ns2.example.
57example.net. 300 IN NS ns1.example.
58;ADDITIONAL
59"""
60    expected_answer = dns.message.from_text(answer)
61
62    isctest.check.noerror(res)
63    isctest.check.rrsets_equal(res.answer, expected_answer.answer)
64    isctest.check.rrsets_equal(res.authority, expected_answer.authority)
65    isctest.check.rrsets_equal(res.additional, expected_answer.additional)
66