perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: modperl-2.0 Changes
Date Fri, 21 May 2004 23:12:55 GMT
stas        2004/05/21 16:12:55

  Modified:    t/response/TestAPR ipsubnet.pm
               todo     api_status
               xs/APR/IpSubnet APR__IpSubnet.h
               .        Changes
  Log:
  - APR::IpSubnet::new() now throws APR::Error exception (not returning rc)
  - more tests
  
  Revision  Changes    Path
  1.2       +34 -11    modperl-2.0/t/response/TestAPR/ipsubnet.pm
  
  Index: ipsubnet.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestAPR/ipsubnet.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -u -r1.1 -r1.2
  --- ipsubnet.pm	21 May 2004 19:25:46 -0000	1.1
  +++ ipsubnet.pm	21 May 2004 23:12:55 -0000	1.2
  @@ -19,7 +19,7 @@
       my $c = $r->connection;
       my $p = $r->pool;
   
  -    plan $r, tests => 5;
  +    plan $r, tests => 7;
   
       my $ip = $c->remote_ip;
   
  @@ -28,22 +28,45 @@
       ok t_cmp($ip, $c->remote_addr->ip_get,
                "remote_ip eq remote_addr->ip_get");
   
  -    my $ipsub = APR::IpSubnet->new($p, $ip);
  +    {
  +        my $ipsub = APR::IpSubnet->new($p, $ip);
   
  -    ok $ipsub->test($c->remote_addr);
  +        ok $ipsub->test($c->remote_addr);
  +    }
   
  -    my $reverse_remote_ip = scalar reverse $ip;
  +    # use IP mask
  +    {
  +        my $ipsub = APR::IpSubnet->new($p, $ip, "255.0.0.0");
   
  -    ok t_cmp($reverse_remote_ip, scalar reverse($c->remote_addr->ip_get),
  -             "reversed remote_ip eq reversed remote_addr->ip_get");
  +        ok $ipsub->test($c->remote_addr);
  +    }
   
  -    $ipsub = APR::IpSubnet->new($p, $reverse_remote_ip);
  +    # fail match
  +    {
  +        if ($ip =~ /^\d+\.\d+\.\d+\.\d+$/) {
  +            # arrange for the subnet to match only one IP, which is
  +            # one digit off the client IP, ensuring a mismatch
  +            (my $mismatch = $ip) =~ s/(?<=\.)(\d+)$/$1 == 255 ? $1-1 : $1+1/e;
  +            t_debug($mismatch);
  +            my $ipsub = APR::IpSubnet->new($p, $mismatch, $mismatch);
  +            ok ! $ipsub->test($c->remote_addr);
  +        }
  +        else {
  +            # XXX: similar ipv6 trick?
  +            ok 1;
  +        }
  +    }
   
  -    if (!$ipsub) {
  -        ok 1; #this happens on win32
  +    # bogus IP
  +    {
  +        my $ipsub = eval { APR::IpSubnet->new($p, "345.234.678.987") };
  +        ok t_cmp(qr/The specified IP address is invalid/, $@, "bogus IP");
       }
  -    else {
  -        ok ! $ipsub->test($c->remote_addr);
  +
  +    # bogus mask
  +    {
  +        my $ipsub = eval { APR::IpSubnet->new($p, $ip, "255.0") };
  +        ok t_cmp(qr/The specified network mask is invalid/, $@, "bogus mask");
       }
   
       Apache::OK;
  
  
  
  1.8       +1 -2      modperl-2.0/todo/api_status
  
  Index: api_status
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/todo/api_status,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -u -r1.7 -r1.8
  --- api_status	21 May 2004 19:25:46 -0000	1.7
  +++ api_status	21 May 2004 23:12:55 -0000	1.8
  @@ -80,8 +80,7 @@
   VV src/docs/2.0/api/APR/Error.pod
   
   -- src/docs/2.0/api/APR/Finfo.pod
  --- src/docs/2.0/api/APR/IpSubnet.pod
  -
  +VV src/docs/2.0/api/APR/IpSubnet.pod
   +V src/docs/2.0/api/APR/PerlIO.pod
   
   
  
  
  
  1.2       +2 -5      modperl-2.0/xs/APR/IpSubnet/APR__IpSubnet.h
  
  Index: APR__IpSubnet.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/APR/IpSubnet/APR__IpSubnet.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -u -r1.1 -r1.2
  --- APR__IpSubnet.h	21 May 2004 19:25:44 -0000	1.1
  +++ APR__IpSubnet.h	21 May 2004 23:12:55 -0000	1.2
  @@ -18,11 +18,8 @@
                                            const char *ipstr,
                                            const char *mask_or_numbits)
   {
  -    apr_status_t status;
       apr_ipsubnet_t *ipsub = NULL;
  -    status = apr_ipsubnet_create(&ipsub, ipstr, mask_or_numbits, p);
  -    if (status != APR_SUCCESS) {
  -        return NULL;
  -    }
  +    MP_RUN_CROAK(apr_ipsubnet_create(&ipsub, ipstr, mask_or_numbits, p),
  +                 "APR::IpSubnet::new");
       return ipsub;
   }
  
  
  
  1.377     +3 -0      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.376
  retrieving revision 1.377
  diff -u -u -r1.376 -r1.377
  --- Changes	21 May 2004 22:01:16 -0000	1.376
  +++ Changes	21 May 2004 23:12:55 -0000	1.377
  @@ -12,6 +12,9 @@
   
   =item 1.99_15-dev
   
  +APR::IpSubnet::new() now throws APR::Error exception (not returning
  +rc) [Stas]
  +
   rename package APR::NetLib -> APR::IpSubnet to match the class name
   [Stas]
   
  
  
  

Mime
View raw message