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

/branches/cname-collision

Add test and target record for checking adding an expiring CNAME after a
same-name record has expired.
See #72, #88

Location:
branches/cname-collision/t
Files:
3 edited

Legend:

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

    r993 r994  
    318318      }
    319319    };
     320    subtest 'collision with expired record' => sub {
     321      $newname = 'expires-at5.expiry2.test';
     322      ($code, $msg) = $dnsdb->addRec('n', 'n', 5, \$newname, \$rectype, \$newval, 900, undef, 't', $expirystamp);
     323      ok( $code eq 'OK', "addRec() claimed success" );
     324      if ($code eq 'OK') {
     325        # crosscheck in the DB
     326        ($rcount) = $dbh->selectrow_array("SELECT count(*) FROM records WHERE domain_id = 5 AND host = '$newname'");
     327        ok( $rcount == 2, " ... [$rcount] correct number of records for $newname" );
     328        my ($newstamp) = $dbh->selectrow_array("SELECT extract(epoch from stamp) FROM records WHERE domain_id = 5 AND host = '$newname' ".
     329                "AND stampactive = 't' AND expires = 't' AND stamp >= now()");
     330        my ($oldstamp) = $dbh->selectrow_array("SELECT extract(epoch from stamp) FROM records WHERE domain_id = 5 AND host = '$newname' ".
     331                "AND stampactive = 't' AND expires = 't' AND stamp <= now()");
     332        ok( $newstamp > $oldstamp, " ... added record expires after existing, already-expired record" );
     333      } else {
     334        print "not ok: $msg";
     335      }
     336    };
    320337  }; # add expiring CNAME
    321338
  • branches/cname-collision/t/dns-unitbase.sql

    r992 r994  
    6586583       example.net     1               1       2025121800      D       f       ab
    6596594       expiry1.test    1               1       2026011400      D       t       
    660 5       expiry2.test    1               1       2026011503      D       t       
     6605       expiry2.test    1               1       2026011600      D       t       
    661661\.
    662662
     
    77877870      5       1       1       admin   Initial User    Added record 'expires-at3.expiry2.test TXT active after pending expiry', TTL 5400, expires at 2026-01-15 18:00  2026-01-15 13:21:31.833257-05   0       0
    77977971      5       1       1       admin   Initial User    Added record 'expires-at4.expiry2.test TXT active before pending expiry', TTL 5400, expires at 2026-01-15 18:00 2026-01-15 17:59:01.61806-05    0       0
     78072      5       1       1       admin   Initial User    Added record 'expires-at5.expiry2.test TXT expired before now', TTL 5400, expires at 2026-01-15 18:00   2026-01-16 11:50:43.678446-05   0       0
    780781\.
    781782
     
    785786--
    786787
    787 SELECT pg_catalog.setval('public.log_log_id_seq', 71, true);
     788SELECT pg_catalog.setval('public.log_log_id_seq', 72, true);
    788789
    789790
     
    8878885       60      expires-at3.expiry2.test        16      active after pending expiry     0       0       0       5400    \N      0               2026-01-15 18:00:00-05  f       t       \N
    8888895       61      expires-at4.expiry2.test        16      active before pending expiry    0       0       0       5400    \N      0               2026-01-15 18:00:00-05  f       t       \N
     8905       62      expires-at5.expiry2.test        16      expired before now      0       0       0       5400    \N      0               2026-01-15 18:00:00-05  t       t       \N
    889891\.
    890892
     
    894896--
    895897
    896 SELECT pg_catalog.setval('public.records_record_id_seq', 61, true);
     898SELECT pg_catalog.setval('public.records_record_id_seq', 62, true);
    897899
    898900
  • branches/cname-collision/t/test-cname-timestamps.sql

    r992 r994  
    1111UPDATE records SET stamp = date_trunc('day', now() + interval '4 day') + '11:30' WHERE record_id = 60;
    1212UPDATE records SET stamp = date_trunc('day', now() + interval '2 day') + '11:30' WHERE record_id = 61;
     13UPDATE records SET stamp = date_trunc('day', now() - interval '2 day') + '11:30' WHERE record_id = 62;
Note: See TracChangeset for help on using the changeset viewer.