update_test.pl revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
#
# Copyright (C) 2000 Internet Software Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# 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
# 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.4 2000/08/01 01:16:14 tale 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 300 A 73.80.65.49"),
yxrrset("a.$zone 300 A 73.80.65.50")]);
yxrrset("a.$zone 300 A 73.80.65.50"),
yxrrset("a.$zone 300 A 73.80.65.49")]);
yxrrset("a.$zone 300 A 73.80.65.49"),
yxrrset("a.$zone 300 A 73.80.65.50"),
yxrrset("a.$zone 300 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 300 A 73.80.65.52"),
yxrrset("e.$zone 300 TXT 'two'"),
yxrrset("e.$zone 300 A 73.80.65.51"),
yxrrset("e.$zone 300 TXT 'three'"),
yxrrset("e.$zone 300 A 73.80.65.50"),
yxrrset("f.$zone 300 A 73.80.65.52"),
yxrrset("e.$zone 300 A 73.80.65.49"),
yxrrset("e.$zone 300 TXT 'one'")]);
section("Subtraction of RRsets");
yxrrset("a.$zone 300 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 300 WKS 73.80.65.49 TCP smtp"),
# yxrrset("c.$zone 300 WKS 73.80.65.49 UDP telnet ftp"),
# yxrrset("c.$zone 300 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 300 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 300 NS ns2.$zone")]);
yxrrset("$zone 300 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 300 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 300 TXT aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc")]);
section("Updating TTLs only");
rr_del("t.$zone 300 A 73.80.65.49"),
rr_add("t.$zone 301 A 73.80.65.49")]);
section("Obscuring existing data by zone cut");
if ($failures) {
print "I:$failures tests failed.\n";
} else {
print "I:All tests successful.\n";
}
exit $failures;