update_test.pl revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
#
# Copyright (C) 2000, 2001, 2004, 2007, 2012, 2016 Internet Systems Consortium, Inc. ("ISC")
#
# 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 http://mozilla.org/MPL/2.0/.
#
# Dynamic update test suite.
#
# Usage:
#
# perl update_test.pl [-s server] [-p port] zone
#
# The server defaults to 127.0.0.1.
# The port defaults to 53.
#
# The "Special NS rules" tests will only work correctly if the
# zone has no NS records to begin with, or alternatively has a
# single NS record pointing at the name "ns1" (relative to
# the zone name).
#
# Installation notes:
#
# This program uses the Net::DNS::Resolver module.
# You can install it by saying
#
# perl -MCPAN -e "install Net::DNS"
#
# $Id: update_test.pl,v 1.10 2007/06/19 23:47:04 tbox Exp $
#
$opt_s = "127.0.0.1";
$opt_p = 53;
getopt('s:p:');
@ARGV == 1 or die
"usage: perl update_test.pl [-s server] [-p port] zone\n";
my $failures = 0;
sub assert {
my ($cond, $explanation) = @_;
if (!$cond) {
print "I:Test Failed: $explanation ***\n";
$failures++
}
}
sub test {
}
# Did it work?
if (defined $reply) {
} else {
}
}
sub section {
my ($msg) = @_;
print "I:$msg\n";
}
section("Delete any leftovers from previous tests");
section("Simple prerequisites in the absence of data");
# Name is in Use
# RRset exists (value independent)
# Name is not in use
# RRset does not exist
# RRset exists (value dependent)
section ("Simple creation of data");
section ("Simple prerequisites in the presence of data");
# Name is in use
# RRset exists (value independent)
# Name is not in use
# RRset does not exist
# RRset exists (value dependent)
#
# Merging of RRsets
#
section("Detailed tests of \"RRset exists (value dependent)\" prerequisites");
yxrrset("a.$zone A 73.80.65.49"),
yxrrset("a.$zone A 73.80.65.50")]);
yxrrset("a.$zone A 73.80.65.50"),
yxrrset("a.$zone A 73.80.65.49")]);
yxrrset("a.$zone A 73.80.65.49"),
yxrrset("a.$zone A 73.80.65.50"),
yxrrset("a.$zone A 73.80.65.51")]);
section("Torture test of \"RRset exists (value dependent)\" prerequisites.");
rr_add("e.$zone 300 A 73.80.65.49"),
rr_add("e.$zone 300 TXT 'one'"),
rr_add("e.$zone 300 A 73.80.65.50")]);
rr_add("e.$zone 300 A 73.80.65.52"),
rr_add("f.$zone 300 A 73.80.65.52"),
rr_add("e.$zone 300 A 73.80.65.51")]);
rr_add("e.$zone 300 TXT 'three'"),
rr_add("e.$zone 300 TXT 'two'")]);
rr_add("e.$zone 300 MX 10 mail.$zone")]);
yxrrset("e.$zone A 73.80.65.52"),
yxrrset("e.$zone TXT 'two'"),
yxrrset("e.$zone A 73.80.65.51"),
yxrrset("e.$zone TXT 'three'"),
yxrrset("e.$zone A 73.80.65.50"),
yxrrset("f.$zone A 73.80.65.52"),
yxrrset("e.$zone A 73.80.65.49"),
yxrrset("e.$zone TXT 'one'")]);
section("Subtraction of RRsets");
yxrrset("a.$zone A 73.80.65.50")]);
section("Other forms of deletion");
section("Case insensitivity");
section("Special CNAME rules");
# XXX should test with SIG, KEY, NXT, too.
#
# Currently commented out because Net::DNS does not properly
# support WKS records.
#
#section("Special WKS rules");
#test("NOERROR", ["update", rr_add("c.$zone 300 WKS 73.80.65.49 TCP telnet ftp")]);
#test("NOERROR", ["update", rr_add("c.$zone 300 WKS 73.80.65.49 UDP telnet ftp")]);
#test("NOERROR", ["update", rr_add("c.$zone 300 WKS 73.80.65.50 TCP telnet ftp")]);
#test("NOERROR", ["update", rr_add("c.$zone 300 WKS 73.80.65.49 TCP smtp")]);
#test("NOERROR", ["pre",
# yxrrset("c.$zone WKS 73.80.65.49 TCP smtp"),
# yxrrset("c.$zone WKS 73.80.65.49 UDP telnet ftp"),
# yxrrset("c.$zone WKS 73.80.65.50 TCP telnet ftp")]);
section("Special NS rules");
# Deleting the last NS record using "Delete an RR from an RRset"
# should fail at the zone apex and work elsewhere. The pseudocode
# in RFC2136 says it should fail everywhere, but this is in conflict
# with the actual text.
# Apex
rr_add("$zone 300 NS ns1.$zone"),
rr_add("$zone 300 NS ns2.$zone")]);
yxrrset("$zone NS ns2.$zone")]);
# Non-apex
# Other ways of deleting NS records should also fail at the apex
# and work elsewhere.
# Non-apex
# Apex
yxrrset("$zone NS ns2.$zone")]);
yxrrset("$zone NS ns2.$zone")]);
# They should not touch the SOA, either.
section("Idempotency");
rr_add("d.$zone 300 A 73.80.65.49"),
rr_del("d.$zone A")]);
rr_del("d.$zone A"),
rr_add("d.$zone 300 A 73.80.65.49")]);
section("Out-of-zone prerequisites and updates");
section("Glue");
section("Wildcards");
section("SOA serial handling");
my $soatimers = "20 20 1814400 3600";
# Get the current SOA serial number.
# Increment it by 10.
if ($new_serial > 0xFFFFFFFF) {
$new_serial -= 0x80000000;
$new_serial -= 0x80000000;
}
# Replace the SOA with a new one.
# Check that the SOA really got replaced.
# Check that attempts to decrement the serial number are ignored.
if ($new_serial < 0) {
$new_serial += 0x80000000;
$new_serial += 0x80000000;
}
# Check that attempts to leave the serial number unchanged are ignored.
$soatimers)]);
#
# Currently commented out because Net::DNS does not properly
# support multiple strings in TXT records.
#
#section("Big data");
#test("NOERROR", ["update", rr_add("a.$zone 300 TXT aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc")]);
#test("NOERROR", ["update", rr_del("a.$zone TXT aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc")]);
section("Updating TTLs only");
rr_del("t.$zone A 73.80.65.49"),
rr_add("t.$zone 301 A 73.80.65.49")]);
# Add an RR that is identical to an existing one except for the TTL.
# RFC2136 is not clear about what this should do; it says "duplicate RRs
# will be silently ignored" but is an RR differing only in TTL
# to be considered a duplicate or not? The test assumes that it
# should not be considered a duplicate.
section("TTL normalization");
# The desired behaviour is that the old RRs get their TTL
# changed to match the new one. RFC2136 does not explicitly
# specify this, but I think it makes more sense than the
# alternatives.
foreach $a (@answers) {
}
section("Obscuring existing data by zone cut");
if ($failures) {
print "I:$failures tests failed.\n";
} else {
print "I:All tests successful.\n";
}
exit $failures;