diff options
Diffstat (limited to 'bin/tests/system/ttl')
-rw-r--r-- | bin/tests/system/ttl/clean.sh | 17 | ||||
-rw-r--r-- | bin/tests/system/ttl/ns1/max-example.db | 20 | ||||
-rw-r--r-- | bin/tests/system/ttl/ns1/min-example.db | 20 | ||||
-rw-r--r-- | bin/tests/system/ttl/ns1/named.conf.in | 49 | ||||
-rw-r--r-- | bin/tests/system/ttl/ns2/hints.db | 13 | ||||
-rw-r--r-- | bin/tests/system/ttl/ns2/named.conf.in | 42 | ||||
-rw-r--r-- | bin/tests/system/ttl/setup.sh | 17 | ||||
-rw-r--r-- | bin/tests/system/ttl/tests_cache_ttl.py | 32 |
8 files changed, 210 insertions, 0 deletions
diff --git a/bin/tests/system/ttl/clean.sh b/bin/tests/system/ttl/clean.sh new file mode 100644 index 0000000..3bb41d9 --- /dev/null +++ b/bin/tests/system/ttl/clean.sh @@ -0,0 +1,17 @@ +#!/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. + +rm -f ./*/named.conf +rm -f ./*/named.memstats +rm -f ./*/named.run +rm -f ./ns*/managed-keys.bind* diff --git a/bin/tests/system/ttl/ns1/max-example.db b/bin/tests/system/ttl/ns1/max-example.db new file mode 100644 index 0000000..aeaafc7 --- /dev/null +++ b/bin/tests/system/ttl/ns1/max-example.db @@ -0,0 +1,20 @@ +; 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. + +max-example. 1209600 IN SOA ns root ( + 2000082401 ; serial + 1800 ; refresh (30 minutes) + 1800 ; retry (30 minutes) + 1814400 ; expire (3 weeks) + 1209600 ; minimum (2 weeks) + ) +max-example. 1209600 IN NS ns.max-example. +ns.max-example. 1209600 IN A 10.53.0.1 diff --git a/bin/tests/system/ttl/ns1/min-example.db b/bin/tests/system/ttl/ns1/min-example.db new file mode 100644 index 0000000..87d6e7e --- /dev/null +++ b/bin/tests/system/ttl/ns1/min-example.db @@ -0,0 +1,20 @@ +; 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. + +min-example. 0 IN SOA ns root ( + 2000082401 ; serial + 1800 ; refresh (30 minutes) + 1800 ; retry (30 minutes) + 1814400 ; expire (3 weeks) + 0 ; minimum (0 seconds) + ) +min-example. 0 IN NS ns.min-example. +ns.min-example. 0 IN A 10.53.0.1 diff --git a/bin/tests/system/ttl/ns1/named.conf.in b/bin/tests/system/ttl/ns1/named.conf.in new file mode 100644 index 0000000..51eee0c --- /dev/null +++ b/bin/tests/system/ttl/ns1/named.conf.in @@ -0,0 +1,49 @@ +/* + * 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. + */ + +key rndc_key { + secret "1234abcd8765"; + algorithm @DEFAULT_HMAC@; +}; + +controls { + inet 10.53.0.1 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; +}; + +options { + query-source address 10.53.0.1; + notify-source 10.53.0.1; + transfer-source 10.53.0.1; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.1; }; + listen-on-v6 { none; }; + recursion no; + dnssec-validation no; + check-integrity no; +}; + +zone "." { + type hint; + file "../../common/root.hint"; +}; + +zone "min-example" { + type primary; + file "min-example.db"; +}; + +zone "max-example" { + type primary; + file "max-example.db"; +}; diff --git a/bin/tests/system/ttl/ns2/hints.db b/bin/tests/system/ttl/ns2/hints.db new file mode 100644 index 0000000..c9264bf --- /dev/null +++ b/bin/tests/system/ttl/ns2/hints.db @@ -0,0 +1,13 @@ +; 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. + +. 60 IN NS ns.nil. +ns.nil. 60 IN A 10.53.0.1 diff --git a/bin/tests/system/ttl/ns2/named.conf.in b/bin/tests/system/ttl/ns2/named.conf.in new file mode 100644 index 0000000..1716807 --- /dev/null +++ b/bin/tests/system/ttl/ns2/named.conf.in @@ -0,0 +1,42 @@ +/* + * 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. + */ + +options { + directory "."; + query-source address 10.53.0.2; + notify-source 10.53.0.2; + transfer-source 10.53.0.2; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.2; }; + listen-on-v6 { none; }; + servfail-ttl 0; + max-recursion-depth 12; + recursion yes; + dnssec-validation no; + min-cache-ttl 60; + min-ncache-ttl 30; + max-cache-ttl 120; + max-ncache-ttl 60; +}; + +key rndc_key { + secret "1234abcd8765"; + algorithm @DEFAULT_HMAC@; +}; + +controls { + inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; +}; + +zone "." { type hint; file "hints.db"; }; diff --git a/bin/tests/system/ttl/setup.sh b/bin/tests/system/ttl/setup.sh new file mode 100644 index 0000000..6929ec5 --- /dev/null +++ b/bin/tests/system/ttl/setup.sh @@ -0,0 +1,17 @@ +#!/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. + +. ../conf.sh + +copy_setports ns1/named.conf.in ns1/named.conf +copy_setports ns2/named.conf.in ns2/named.conf diff --git a/bin/tests/system/ttl/tests_cache_ttl.py b/bin/tests/system/ttl/tests_cache_ttl.py new file mode 100644 index 0000000..9025283 --- /dev/null +++ b/bin/tests/system/ttl/tests_cache_ttl.py @@ -0,0 +1,32 @@ +# 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 pytest + +pytest.importorskip("dns") +import dns.message +import dns.query + + +@pytest.mark.parametrize( + "qname,rdtype,expected_ttl", + [ + ("min-example.", "SOA", 60), + ("min-example.", "MX", 30), + ("max-example.", "SOA", 120), + ("max-example.", "MX", 60), + ], +) +def test_cache_ttl(qname, rdtype, expected_ttl, named_port): + msg = dns.message.make_query(qname, rdtype) + response = dns.query.udp(msg, "10.53.0.2", timeout=10, port=named_port) + for rr in response.answer + response.authority: + assert rr.ttl == expected_ttl |