mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 06:49:58 -04:00
Use jinja2 templates in rpz test
- The ns3/named.conf.j2 uses has a "#BAD" section that is only included after restart. Turn it into ns3/named2.conf. - Since the original config is then restored, keep a copy of it as ns3/named1.conf using a symlink, causing it to be rendered twice. - Use jinja2 templates for test* files to render the port number instead of calling copy_setports in load_db().
This commit is contained in:
parent
efc302b0ad
commit
c93733263a
22 changed files with 29 additions and 26 deletions
|
|
@ -15,6 +15,8 @@
|
|||
* Main rpz test DNS server.
|
||||
*/
|
||||
|
||||
{% set bad_dlz = bad_dlz | default(False) %}
|
||||
|
||||
options {
|
||||
query-source address 10.53.0.3;
|
||||
notify-source 10.53.0.3;
|
||||
|
|
@ -170,12 +172,12 @@ zone "wild-cname" {
|
|||
file "wild-cname.db";
|
||||
};
|
||||
|
||||
{% if bad_dlz %}
|
||||
# A faulty dlz configuration to check if named with response policy zones
|
||||
# survives a certain class of failed configuration attempts (see GL #3880).
|
||||
# "dlz" is used because the dlz processing code is located in an ideal place in
|
||||
# the view configuration function for the test to cover the view reverting code.
|
||||
# The "BAD" comments below are necessary, because they will be removed using
|
||||
# 'sed' by tests.sh in order to activate the faulty configuration.
|
||||
#BAD dlz "bad-dlz" {
|
||||
#BAD database "dlopen bad-dlz.@DYLIB@ example.org";
|
||||
#BAD };
|
||||
dlz "bad-dlz" {
|
||||
database "dlopen bad-dlz.@DYLIB@ example.org";
|
||||
};
|
||||
{% endif %}
|
||||
1
bin/tests/system/rpz/ns3/named1.conf.j2
Symbolic link
1
bin/tests/system/rpz/ns3/named1.conf.j2
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
named.conf.j2
|
||||
16
bin/tests/system/rpz/ns3/named2.conf.j2
Normal file
16
bin/tests/system/rpz/ns3/named2.conf.j2
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
{% set bad_dlz = True %}
|
||||
|
||||
{% include "ns3/named.conf.j2" %}
|
||||
|
|
@ -20,17 +20,6 @@ for dir in ns*; do
|
|||
nextpart $dir/named.run >/dev/null
|
||||
done
|
||||
|
||||
copy_setports ns1/named.conf.in ns1/named.conf
|
||||
copy_setports ns2/named.conf.in ns2/named.conf
|
||||
copy_setports ns3/named.conf.in ns3/named.conf
|
||||
copy_setports ns4/named.conf.in ns4/named.conf
|
||||
copy_setports ns5/named.conf.in ns5/named.conf
|
||||
copy_setports ns6/named.conf.in ns6/named.conf
|
||||
copy_setports ns7/named.conf.in ns7/named.conf
|
||||
copy_setports ns8/named.conf.in ns8/named.conf
|
||||
copy_setports ns9/named.conf.in ns9/named.conf
|
||||
copy_setports ns10/named.conf.in ns10/named.conf
|
||||
|
||||
# set up test policy zones.
|
||||
# bl is the main test zone
|
||||
# bl-2 is used to check competing zones.
|
||||
|
|
|
|||
|
|
@ -134,9 +134,7 @@ ck_soa() {
|
|||
# (re)load the response policy zones with the rules in the file $TEST_FILE
|
||||
load_db() {
|
||||
if test -n "$TEST_FILE"; then
|
||||
copy_setports $TEST_FILE tmp
|
||||
|
||||
if $NSUPDATE -v tmp; then
|
||||
if $NSUPDATE -v $TEST_FILE; then
|
||||
:
|
||||
$RNDCCMD $ns3 sync
|
||||
else
|
||||
|
|
@ -144,7 +142,6 @@ load_db() {
|
|||
$RNDCCMD $ns3 sync
|
||||
exit 1
|
||||
fi
|
||||
rm -f tmp
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -250,8 +247,7 @@ start_group() {
|
|||
end_group() {
|
||||
if test -n "$TEST_FILE"; then
|
||||
# remove the previous set of test rules
|
||||
copy_setports $TEST_FILE tmp
|
||||
sed -e 's/[ ]add[ ]/ delete /' tmp | $NSUPDATE
|
||||
sed -e 's/[ ]add[ ]/ delete /' $TEST_FILE | $NSUPDATE
|
||||
rm -f tmp
|
||||
TEST_FILE=
|
||||
fi
|
||||
|
|
@ -678,12 +674,10 @@ restart 3 "rebuild-bl-rpz"
|
|||
|
||||
t=$((t + 1))
|
||||
echo_i "checking if rpz survives a certain class of failed reconfiguration attempts (${t})"
|
||||
sed -e "s/^#BAD//" <ns3/named.conf.in >ns3/named.conf.tmp
|
||||
copy_setports ns3/named.conf.tmp ns3/named.conf
|
||||
rm ns3/named.conf.tmp
|
||||
cp ns3/named2.conf ns3/named.conf
|
||||
$RNDCCMD $ns3 reconfig >/dev/null 2>&1 && setret "failed"
|
||||
sleep 1
|
||||
copy_setports ns3/named.conf.in ns3/named.conf
|
||||
cp ns3/named1.conf ns3/named.conf
|
||||
$RNDCCMD $ns3 reconfig || setret "failed"
|
||||
|
||||
t=$((t + 1))
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pytestmark = pytest.mark.extra_artifacts(
|
|||
"dnsrps.conf",
|
||||
"dnsrps.zones",
|
||||
"proto.*",
|
||||
"test*",
|
||||
"trusted.conf",
|
||||
"ns2/K*",
|
||||
"ns2/bl.tld2.db",
|
||||
|
|
|
|||
Loading…
Reference in a new issue