Ignore:
Timestamp:
01/15/26 16:26:05 (5 days ago)
Author:
Kris Deugau
Message:

/branches/cname-collision

Add test subgroup for expiring CNAME. First two tests are arguably retries
of earlier tests from domain group, included for completeness.
See #72, #88

File:
1 edited

Legend:

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

    r984 r987  
    255255  }; # add non-timestamp CNAME
    256256
     257  subtest 'CNAME add - expires soon' => sub {
     258    my @ltime = localtime;
     259    $expirystamp = sprintf "%i-%i-%i %i:%i", $ltime[5] + 1900, $ltime[4] + 1, $ltime[3] + 3, 15, $ltime[1];
     260    $newval = 'target.example.com';
     261    subtest 'collision with nonexpiring record' => sub {
     262      $newname = 'expires-at1.expiry2.test';
     263      ($code, $msg) = $dnsdb->addRec('n', 'n', 5, \$newname, \$rectype, \$newval, 900, undef, 't', $expirystamp);
     264      ok($code eq 'FAIL', "addRec() returned failure");
     265      if ($code eq 'FAIL') {
     266        ($rcount) = $dbh->selectrow_array("SELECT count(*) FROM records WHERE domain_id = 5 AND host = '$newname'");
     267        ok( $rcount == 1, " ... [$rcount] yep, hostname only occurs once" );
     268        like( $msg, qr/One or more non-CNAME records/, " ... returned matching error" );
     269      }
     270    };
     271    subtest 'collision with expiring record' => sub {
     272      $newname = 'expires-at2.expiry2.test';
     273      ($code, $msg) = $dnsdb->addRec('n', 'n', 5, \$newname, \$rectype, \$newval, 900, undef, 't', $expirystamp);
     274      ok( $code eq 'FAIL', "addRec() returned failure");
     275      if ($code eq 'FAIL') {
     276        ($rcount) = $dbh->selectrow_array("SELECT count(*) FROM records WHERE domain_id = 5 AND host = '$newname' AND type <> 5");
     277        ok( $rcount == 1, " ... [$rcount] record(s) with $newname already exist" );
     278        like( $msg, qr/One or more non-CNAME records/, " ... returned matching error" );
     279      }
     280    };
     281  }; # add expiring CNAME
     282
    257283}; # record expiry/valid-after
    258284
Note: See TracChangeset for help on using the changeset viewer.