mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 07:30:01 -04:00
Test checkconf and addzone with bad templates
named-checkconf should reject a template that has options that must be non-zero (max-refresh-time, max-retry-time, min-refresh-time, min-retry-time). rndc addzone with a zone that refers to such template should fail cleanly.
This commit is contained in:
parent
3a206cae5b
commit
c713e83948
3 changed files with 66 additions and 0 deletions
|
|
@ -21,6 +21,15 @@ template primary {
|
|||
initial-file "added.db";
|
||||
};
|
||||
|
||||
template bad {
|
||||
type secondary;
|
||||
primaries { 10.53.0.1; };
|
||||
max-refresh-time 0;
|
||||
max-retry-time 0;
|
||||
min-refresh-time 0;
|
||||
min-retry-time 0;
|
||||
};
|
||||
|
||||
zone "." {
|
||||
type hint;
|
||||
file "../../_common/root.hint";
|
||||
|
|
|
|||
45
bin/tests/system/addzone/tests_rndc_addzone_template.py
Normal file
45
bin/tests/system/addzone/tests_rndc_addzone_template.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# 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
|
||||
|
||||
pytestmark = pytest.mark.extra_artifacts(
|
||||
[
|
||||
"ns*/*.nzf*",
|
||||
"ns*/*.nzd*",
|
||||
"ns1/redirect.db",
|
||||
"ns2/new-zones",
|
||||
"ns2/redirect.db",
|
||||
"ns3/redirect.db",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_rndc_addzone_bad_template(ns2):
|
||||
"""
|
||||
Confirm "rndc addzone" fails for a zone that refers to a badly configured template.
|
||||
"""
|
||||
zone = "badtemplate.example"
|
||||
cmd = ns2.rndc(
|
||||
"addzone badtemplate.example {template bad;};",
|
||||
raise_on_exception=False,
|
||||
)
|
||||
assert cmd.rc == 1
|
||||
|
||||
assert "'max-retry-time' must not be zero" in ns2.log
|
||||
assert "'min-retry-time' must not be zero" in ns2.log
|
||||
assert "'max-refresh-time' must not be zero" in ns2.log
|
||||
assert "'min-refresh-time' must not be zero" in ns2.log
|
||||
|
||||
# Confirm that the addzone failed to add the zone
|
||||
cmd = ns2.rndc(f"showzone {zone}", raise_on_exception=False)
|
||||
assert cmd.rc == 1
|
||||
assert f"no matching zone '{zone}' in any view" in cmd.err
|
||||
12
bin/tests/system/checkconf/bad-template-non-zero-check.conf
Normal file
12
bin/tests/system/checkconf/bad-template-non-zero-check.conf
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
template "a" {
|
||||
type secondary;
|
||||
primaries { 10.53.0.1; };
|
||||
max-refresh-time 0;
|
||||
max-retry-time 0;
|
||||
min-refresh-time 0;
|
||||
min-retry-time 0;
|
||||
};
|
||||
|
||||
zone example {
|
||||
template a;
|
||||
};
|
||||
Loading…
Reference in a new issue