stas 2004/05/26 19:09:28
Modified: t/response/TestAPR util.pm
Log:
- crypt is not supported on 3 platforms
- add tests for md5 and sha1
Revision Changes Path
1.9 +30 -7 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.8
retrieving revision 1.9
diff -u -u -r1.8 -r1.9
--- util.pm 22 May 2004 21:47:32 -0000 1.8
+++ util.pm 27 May 2004 02:09:28 -0000 1.9
@@ -1,5 +1,7 @@
package TestAPR::util;
+# test APR::Util
+
use strict;
use warnings FATAL => 'all';
@@ -10,21 +12,42 @@
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=',
+);
+
sub handler {
my $r = shift;
- plan $r, tests => 2;
+ plan $r, tests => 4;
+
+ # 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;
-
- ok ! APR::Util::password_validate("one", "two");
-
- my $clear = "pass1";
- my $hash = "1fWDc9QWYCWrQ";
- ok APR::Util::password_validate($clear, $hash);
Apache::OK;
}