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 pytest 13 14pytest.importorskip("dns") 15import dns.message 16import dns.query 17 18 19@pytest.mark.parametrize( 20 "qname,rdtype,expected_ttl", 21 [ 22 ("min-example.", "SOA", 60), 23 ("min-example.", "MX", 30), 24 ("max-example.", "SOA", 120), 25 ("max-example.", "MX", 60), 26 ], 27) 28def test_cache_ttl(qname, rdtype, expected_ttl, named_port): 29 msg = dns.message.make_query(qname, rdtype) 30 response = dns.query.udp(msg, "10.53.0.2", timeout=10, port=named_port) 31 for rr in response.answer + response.authority: 32 assert rr.ttl == expected_ttl 33