1#!/usr/bin/python3
2
3# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4#
5# SPDX-License-Identifier: MPL-2.0
6#
7# This Source Code Form is subject to the terms of the Mozilla Public
8# License, v. 2.0.  If a copy of the MPL was not distributed with this
9# file, you can obtain one at https://mozilla.org/MPL/2.0/.
10#
11# See the COPYRIGHT file distributed with this work for additional
12# information regarding copyright ownership.
13
14import pytest
15
16pytest.importorskip("dns")
17import dns.message
18import dns.query
19import dns.rcode
20
21
22def test_connreset(named_port):
23    msg = dns.message.make_query(
24        "sub.example.", "A", want_dnssec=True, use_edns=0, payload=1232
25    )
26    ans = dns.query.udp(msg, "10.53.0.2", timeout=10, port=named_port)
27    assert ans.rcode() == dns.rcode.SERVFAIL
28