Changeset 997 for branches/cname-collision/t
- Timestamp:
- 01/23/26 11:48:50 (6 days ago)
- File:
-
- 1 edited
-
branches/cname-collision/t/cname.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cname-collision/t/cname.t
r994 r997 207 207 208 208 subtest 'CNAME add - nonexpiring' => sub { 209 subtest ' - collision with expired record' => sub { 209 $newval = 'target.example.com'; 210 subtest 'collision with expired record' => sub { 210 211 $newname = 'expired1.expiry1.test'; 211 $newval = 'target.example.com';212 212 ($code, $msg) = $dnsdb->addRec('n', 'n', 4, \$newname, \$rectype, \$newval, 900); 213 ok( $code eq ' OK', "addRec() claimed success" );214 if ($code eq ' OK') {215 ($rcount) = $dbh->selectrow_array("SELECT count(*) FROM records WHERE domain_id = 4 AND host = '$newname' AND stampactive = 'f'");213 ok( $code eq 'FAIL', "addRec() claimed failure" ); 214 if ($code eq 'FAIL') { 215 ($rcount) = $dbh->selectrow_array("SELECT count(*) FROM records WHERE domain_id = 4 AND host = '$newname'"); 216 216 ok( $rcount == 1, " ... [$rcount] yep, hostname only occurs once" ); 217 } else { 218 print "not ok: $msg"; 217 like( $msg, qr/non-CNAME records with timestamps already exist/, " ... returned matching error" ); 219 218 } 220 219 }; 221 220 # this test arguably overkill, subsumed by earlier test for nonexpiring collision 222 subtest ' -collision with soon to expire record' => sub {221 subtest 'collision with soon to expire record' => sub { 223 222 $newname = 'expired2.expiry1.test'; 224 223 ($code, $msg) = $dnsdb->addRec('n', 'n', 4, \$newname, \$rectype, \$newval, 900); … … 228 227 ok( $rcount == 1, " ... [$rcount] record(s) with $newname already exist" ); 229 228 # somewhat less overkill if we try to target a unique return based around the expiry bit 230 like( $msg, qr/ One or more non-CNAME records/, " ... returned matching error" );231 } 232 }; 233 subtest ' -collision with pending active-after record' => sub {229 like( $msg, qr/non-CNAME records with timestamps already exist/, " ... returned matching error" ); 230 } 231 }; 232 subtest 'collision with pending active-after record' => sub { 234 233 $newname = 'active-after1.expiry1.test'; 235 234 ($code, $msg) = $dnsdb->addRec('n', 'n', 4, \$newname, \$rectype, \$newval, 900); 236 ok( $code eq ' WARN', "addRec() claimed success with warning" );237 if ($code eq ' WARN') {235 ok( $code eq 'FAIL', "addRec() claimed success with warning" ); 236 if ($code eq 'FAIL') { 238 237 ($rcount) = $dbh->selectrow_array("SELECT count(*) FROM records WHERE domain_id = 4 AND host = '$newname'"); 239 ok( $rcount == 2, " ... [$rcount] correct number of records for $newname" ); 240 like( $msg, qr/added with expiry time; conflicting valid-after record found/, " ... returned appropriate warning message" ); 241 my ($newstamp) = $dbh->selectrow_array("SELECT stamp FROM records WHERE domain_id = 4 AND host = '$newname' ". 242 "AND stampactive = 't' AND expires = 't'"); 243 my ($oldstamp) = $dbh->selectrow_array("SELECT stamp FROM records WHERE domain_id = 4 AND host = '$newname' ". 244 "AND stampactive = 't' AND expires = 'f'"); 245 ok( $newstamp eq $oldstamp, " ... coerced timestamp matches existing active-after timestamp" ); 246 } else { 247 print "not ok: $msg"; 248 } 249 }; 250 subtest ' - collision with active active-after record' => sub { 238 ok( $rcount == 1, " ... [$rcount] correct number of records for $newname" ); 239 like( $msg, qr/non-CNAME records with timestamps already exist/, " ... returned matching error" ); 240 } 241 }; 242 subtest 'collision with active active-after record' => sub { 251 243 $newname = 'active-after2.expiry1.test'; 252 244 ($code, $msg) = $dnsdb->addRec('n', 'n', 4, \$newname, \$rectype, \$newval, 900); … … 255 247 ($rcount) = $dbh->selectrow_array("SELECT count(*) FROM records WHERE domain_id = 4 AND host = '$newname' AND type <> 5"); 256 248 ok( $rcount == 1, " ... [$rcount] record(s) with $newname already exist" ); 257 like( $msg, qr/ record with a valid-after time in the past/, " ... returned matching error" );249 like( $msg, qr/non-CNAME records with timestamps already exist/, " ... returned matching error" ); 258 250 } 259 251 };
Note:
See TracChangeset
for help on using the changeset viewer.
![[ DNS Administrator ]](/fx/dnsadmin-logo.png)