1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
|
# $Id: 06-update.t,v 1.2 1997/07/05 17:47:06 mfuhr Exp $
BEGIN { $| = 1; print "1..65\n"; }
END {print "not ok 1\n" unless $loaded;}
use Net::DNS;
$loaded = 1;
print "ok 1\n";
sub is_empty {
my $string = shift;
return ($string eq "; no data" || $string eq "; rdlength = 0");
}
#------------------------------------------------------------------------------
# Canned data.
#------------------------------------------------------------------------------
$zone = "bar.com";
$name = "foo.bar.com";
$class = "HS";
$class2 = "CH";
$type = "A";
$ttl = 43200;
$rdata = "10.1.2.3";
#------------------------------------------------------------------------------
# Packet creation.
#------------------------------------------------------------------------------
$packet = new Net::DNS::Update($zone, $class);
print "not " unless $packet;
print "ok 2\n";
print "not " unless $packet->header->opcode eq "UPDATE";
print "ok 3\n";
print "not " unless ($packet->zone)[0]->zname eq $zone;
print "ok 4\n";
print "not " unless ($packet->zone)[0]->zclass eq $class;
print "ok 5\n";
print "not " unless ($packet->zone)[0]->ztype eq "SOA";
print "ok 6\n";
#------------------------------------------------------------------------------
# RRset exists (value-independent).
#------------------------------------------------------------------------------
$rr = yxrrset("$name $class $type");
print "not " unless $rr;
print "ok 7\n";
print "not " unless $rr->name eq $name;
print "ok 8\n";
print "not " unless $rr->ttl == 0;
print "ok 9\n";
print "not " unless $rr->class eq "ANY";
print "ok 10\n";
print "not " unless $rr->type eq $type;
print "ok 11\n";
print "not " unless is_empty($rr->rdatastr);
print "ok 12\n";
#------------------------------------------------------------------------------
# RRset exists (value-dependent).
#------------------------------------------------------------------------------
$rr = yxrrset("$name $class $type $rdata");
print "not " unless $rr;
print "ok 13\n";
print "not " unless $rr->name eq $name;
print "ok 14\n";
print "not " unless $rr->ttl == 0;
print "ok 15\n";
print "not " unless $rr->class eq $class;
print "ok 16\n";
print "not " unless $rr->type eq $type;
print "ok 17\n";
print "not " unless $rr->rdatastr eq $rdata;
print "ok 18\n";
#------------------------------------------------------------------------------
# RRset does not exist.
#------------------------------------------------------------------------------
$rr = nxrrset("$name $class $type");
print "not " unless $rr;
print "ok 19\n";
print "not " unless $rr->name eq $name;
print "ok 20\n";
print "not " unless $rr->ttl == 0;
print "ok 21\n";
print "not " unless $rr->class eq "NONE";
print "ok 22\n";
print "not " unless $rr->type eq $type;
print "ok 23\n";
print "not " unless is_empty($rr->rdatastr);
print "ok 24\n";
#------------------------------------------------------------------------------
# Name is in use.
#------------------------------------------------------------------------------
$rr = yxdomain("$name $class");
print "not " unless $rr;
print "ok 25\n";
print "not " unless $rr->name eq $name;
print "ok 26\n";
print "not " unless $rr->ttl == 0;
print "ok 27\n";
print "not " unless $rr->class eq "ANY";
print "ok 28\n";
print "not " unless $rr->type eq "ANY";
print "ok 29\n";
print "not " unless is_empty($rr->rdatastr);
print "ok 30\n";
#------------------------------------------------------------------------------
# Name is not in use.
#------------------------------------------------------------------------------
$rr = nxdomain("$name $class");
print "not " unless $rr;
print "ok 31\n";
print "not " unless $rr->name eq $name;
print "ok 32\n";
print "not " unless $rr->ttl == 0;
print "ok 33\n";
print "not " unless $rr->class eq "NONE";
print "ok 34\n";
print "not " unless $rr->type eq "ANY";
print "ok 35\n";
print "not " unless is_empty($rr->rdatastr);
print "ok 36\n";
#------------------------------------------------------------------------------
# Add to an RRset.
#------------------------------------------------------------------------------
$rr = rr_add("$name $ttl $class $type $rdata");
print "not " unless $rr;
print "ok 37\n";
print "not " unless $rr->name eq $name;
print "ok 38\n";
print "not " unless $rr->ttl == $ttl;
print "ok 39\n";
print "not " unless $rr->class eq $class;
print "ok 40\n";
print "not " unless $rr->type eq $type;
print "ok 41\n";
print "not " unless $rr->rdatastr eq $rdata;
print "ok 42\n";
#------------------------------------------------------------------------------
# Delete an RRset.
#------------------------------------------------------------------------------
$rr = rr_del("$name $class $type");
print "not " unless $rr;
print "ok 43\n";
print "not " unless $rr->name eq $name;
print "ok 44\n";
print "not " unless $rr->ttl == 0;
print "ok 45\n";
print "not " unless $rr->class eq "ANY";
print "ok 46\n";
print "not " unless $rr->type eq $type;
print "ok 47\n";
print "not " unless is_empty($rr->rdatastr);
print "ok 48\n";
#------------------------------------------------------------------------------
# Delete All RRsets From A Name.
#------------------------------------------------------------------------------
$rr = rr_del("$name $class");
print "not " unless $rr;
print "ok 49\n";
print "not " unless $rr->name eq $name;
print "ok 50\n";
print "not " unless $rr->ttl == 0;
print "ok 51\n";
print "not " unless $rr->class eq "ANY";
print "ok 52\n";
print "not " unless $rr->type eq "ANY";
print "ok 53\n";
print "not " unless is_empty($rr->rdatastr);
print "ok 54\n";
#------------------------------------------------------------------------------
# Delete An RR From An RRset.
#------------------------------------------------------------------------------
$rr = rr_del("$name $class $type $rdata");
print "not " unless $rr;
print "ok 55\n";
print "not " unless $rr->name eq $name;
print "ok 56\n";
print "not " unless $rr->ttl == 0;
print "ok 57\n";
print "not " unless $rr->class eq "NONE";
print "ok 58\n";
print "not " unless $rr->type eq $type;
print "ok 59\n";
print "not " unless $rr->rdatastr eq $rdata;
print "ok 60\n";
#------------------------------------------------------------------------------
# Make sure RRs in an update packet have the same class as the zone, unless
# the class is NONE or ANY.
#------------------------------------------------------------------------------
$packet = new Net::DNS::Update($zone, $class);
print "not " unless $packet;
print "ok 61\n";
$rr = yxrrset("$name $class $type $rdata");
$packet->push("pre", $rr);
print "not " unless ($packet->pre)[0]->class eq $class;
print "ok 62\n";
$rr = yxrrset("$name $class2 $type $rdata");
$packet->push("pre", $rr);
print "not " unless ($packet->pre)[1]->class eq $class;
print "ok 63\n";
$rr = yxrrset("$name $class2 $type");
$packet->push("pre", $rr);
print "not " unless ($packet->pre)[2]->class eq "ANY";
print "ok 64\n";
$rr = nxrrset("$name $class2 $type");
$packet->push("pre", $rr);
print "not " unless ($packet->pre)[3]->class eq "NONE";
print "ok 65\n";
|