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 12 import dns.name 13 import dns.rdataclass 14 import dns.rdatatype 15 import pytest 16 17 from isctest.instance import NamedInstance 18 19 import isctest 20 21 22 def _a_records(response, qname: str) -> set[str]: 23 rrset = response.get_rrset( 24 response.answer, 25 dns.name.from_text(qname), 26 dns.rdataclass.IN, 27 dns.rdatatype.A, 28 ) 29 if rrset is None: 30 return set() 31 return {rdata.address for rdata in rrset} 32 33 34 @pytest.mark.parametrize("resolver_name", ["ns4", "ns5"]) 35 def test_forward_first_referral_ns_above_forward_zone_not_cached( 36 servers: dict[str, NamedInstance], 37 resolver_name: str, 38 ) -> None: 39 resolver = servers[resolver_name] 40 resolver.rndc("flush") 41 42 trigger = isctest.query.create("trigger.fwd.hack.", "A", dnssec=False) 43 isctest.query.tcp(trigger, resolver.ip) 44 45 sibling = isctest.query.create("victim.sibling.hack.", "A", dnssec=False) 46 response = isctest.query.tcp(sibling, resolver.ip) 47 isctest.check.noerror(response) 48 49 assert _a_records(response, "victim.sibling.hack.") == {"203.0.113.42"} 50