"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/t/99md5gen.t" (15 Sep 2009, 1191 Bytes) of package /linux/www/Apache-Session-1.93.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 use Test::More;
    2 use Test::Exception;
    3 use File::Temp qw[tempdir];
    4 use Cwd qw[getcwd];
    5 
    6 plan skip_all => "Optional module (Digest::MD5) not installed"
    7   unless eval {
    8                require Digest::MD5;
    9               };
   10 
   11 plan tests => 33;
   12 
   13 my $package = 'Apache::Session::Generate::MD5';
   14 use_ok $package;
   15 
   16 #my $origdir = getcwd;
   17 #my $tempdir = tempdir( DIR => '.', CLEANUP => 1 );
   18 #chdir( $tempdir );
   19 
   20 my $session = {};
   21 
   22 Apache::Session::Generate::MD5::generate($session);
   23 
   24 ok exists($session->{data}->{_session_id}), 'session id created';
   25 
   26 ok keys(%{$session->{data}}) == 1, 'just one key in the data hashref';
   27 
   28 like $session->{data}->{_session_id}, qr/^[0-9a-fA-F]{32}$/, 'id looks like hex';
   29 
   30 my $old_id = $session->{data}->{_session_id};
   31 
   32 Apache::Session::Generate::MD5::generate($session);
   33 
   34 isnt $old_id, $session->{data}->{_session_id}, 'old session id does not match new one';
   35 
   36 for my $length (5 .. 32) {
   37     $session->{args}->{IDLength} = $length;
   38     
   39     Apache::Session::Generate::MD5::generate($session);
   40 
   41     like $session->{data}->{_session_id}, qr/^[0-9a-fA-F]{$length}$/,
   42          "id is $length chars long";
   43 }
   44 
   45 #chdir( $origdir );