Changeset 997 for branches


Ignore:
Timestamp:
01/23/26 11:48:50 (6 days ago)
Author:
Kris Deugau
Message:

/branches/cname-collision

Fix up tests for non-timestamped CNAME colliding with timestamped existing
records to match revised logic tree collision and truth table
See #72

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cname-collision/t/cname.t

    r994 r997  
    207207
    208208  subtest 'CNAME add - nonexpiring' => sub {
    209     subtest '  - collision with expired record' => sub {
     209    $newval = 'target.example.com';
     210    subtest 'collision with expired record' => sub {
    210211      $newname = 'expired1.expiry1.test';
    211       $newval = 'target.example.com';
    212212      ($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'");
    216216        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" );
    219218      }
    220219    };
    221220# 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 {
    223222      $newname = 'expired2.expiry1.test';
    224223      ($code, $msg) = $dnsdb->addRec('n', 'n', 4, \$newname, \$rectype, \$newval, 900);
     
    228227        ok( $rcount == 1, " ... [$rcount] record(s) with $newname already exist" );
    229228# 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 {
    234233      $newname = 'active-after1.expiry1.test';
    235234      ($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') {
    238237        ($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 {
    251243      $newname = 'active-after2.expiry1.test';
    252244      ($code, $msg) = $dnsdb->addRec('n', 'n', 4, \$newname, \$rectype, \$newval, 900);
     
    255247        ($rcount) = $dbh->selectrow_array("SELECT count(*) FROM records WHERE domain_id = 4 AND host = '$newname' AND type <> 5");
    256248        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" );
    258250      }
    259251    };
Note: See TracChangeset for help on using the changeset viewer.