perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ran...@apache.org
Subject cvs commit: modperl-2.0/t/response/TestAPR util.pm
Date Thu, 15 Jul 2004 15:32:32 GMT
randyk      2004/07/15 08:32:32

  Modified:    t/response/TestAPR util.pm
  Added:       t/apr-ext util.t
               t/lib/TestAPRlib util.pm
  Log:
  Reviewed by:	stas
  put common util tests under t/lib/TestAPRlib/, and call them
  from both t/apr/ and t/apr-ext/.
  
  Revision  Changes    Path
  1.1                  modperl-2.0/t/apr-ext/util.t
  
  Index: util.t
  ===================================================================
  use strict;
  use warnings FATAL => 'all';
  use Apache::Test;
  
  use TestAPRlib::util;
  
  plan tests => TestAPRlib::util::num_of_tests();
  
  TestAPRlib::util::test();
  
  
  
  1.1                  modperl-2.0/t/lib/TestAPRlib/util.pm
  
  Index: util.pm
  ===================================================================
  package TestAPRlib::util;
  
  # test APR::Util
  
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestUtil;
  
  use APR::Util ();
  
  use constant CRYPT_WORKS => $^O !~ /^(MSWin32|beos|NetWare)$/;
  
  my $clear = "this is some text";
  # to get the hash values used:
  # htpasswd -nb[sm] user "this is some text"
  my %hashes = (
      crypt => 'pHM3JfnL6isho',
      md5   => '$apr1$Kld6H/..$o5OPPPWslI3zB20S54u9s1',
      sha1  => '{SHA}A5NpTRa4TethLkfOYlK9NfDYbAY=',
  );
  
  # BACK_COMPAT_MARKER (sha1 support added in 2.0.50)
  delete $hashes{sha1} unless have_apache_version('2.0.50');
  
  sub num_of_tests {
      return 1 + scalar keys %hashes;
  }
  
  sub test {
  
      # password_validate
      {
          ok ! APR::Util::password_validate("one", "two");
  
          while (my($mode, $hash) = each %hashes) {
              t_debug($mode);
              if ($mode eq 'crypt' && !CRYPT_WORKS) {
                  t_debug("crypt is not supported on $^O");
                  ok 1; # don't make noise
              }
              else {
                  ok APR::Util::password_validate($clear, $hash);
              }
          }
      }
  
  #this function seems unstable on certain platforms
  #    my $blen = 10;
  #    my $bytes = APR::generate_random_bytes($blen);
  #    ok length($bytes) == $blen;
  
  }
  
  1;
  
  
  
  1.11      +4 -39     modperl-2.0/t/response/TestAPR/util.pm
  
  Index: util.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestAPR/util.pm,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- util.pm	27 May 2004 21:07:33 -0000	1.10
  +++ util.pm	15 Jul 2004 15:32:32 -0000	1.11
  @@ -6,53 +6,18 @@
   use warnings FATAL => 'all';
   
   use Apache::Test;
  -use Apache::TestUtil;
  -
  -use APR::Util ();
   
   use Apache::Const -compile => 'OK';
   
  -use constant CRYPT_WORKS => $^O !~ /^(MSWin32|beos|NetWare)$/;
  -
  -my $clear = "this is some text";
  -# to get the hash values used:
  -# htpasswd -nb[sm] user "this is some text"
  -my %hashes = (
  -    crypt => 'pHM3JfnL6isho',
  -    md5   => '$apr1$Kld6H/..$o5OPPPWslI3zB20S54u9s1',
  -    sha1  => '{SHA}A5NpTRa4TethLkfOYlK9NfDYbAY=',
  -);
  -
  -# BACK_COMPAT_MARKER (sha1 support added in 2.0.50)
  -delete $hashes{sha1} unless have_apache_version('2.0.50');
  -
  -my $password_validate_tests = 1 + scalar keys %hashes;
  +use TestAPRlib::util;
   
   sub handler {
       my $r = shift;
   
  -    plan $r, tests => $password_validate_tests;
  -
  -    # password_validate
  -    {
  -        ok ! APR::Util::password_validate("one", "two");
  -
  -        while (my($mode, $hash) = each %hashes) {
  -            t_debug($mode);
  -            if ($mode eq 'crypt' && !CRYPT_WORKS) {
  -                t_debug("crypt is not supported on $^O");
  -                ok 1; # don't make noise
  -            }
  -            else {
  -                ok APR::Util::password_validate($clear, $hash);
  -            }
  -        }
  -    }
  +    my $num_of_tests = TestAPRlib::util::num_of_tests();
  +    plan $r, tests => $num_of_tests;
   
  -#this function seems unstable on certain platforms
  -#    my $blen = 10;
  -#    my $bytes = APR::generate_random_bytes($blen);
  -#    ok length($bytes) == $blen;
  +    TestAPRlib::util::test();
   
       Apache::OK;
   }
  
  
  

Mime
View raw message