environments/ppa-mbqj77/deployments/1
Xavier Guimard 15 years ago
parent b974e95f3e
commit d725c6753b
  1. 7
      modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/Regexp.pm
  2. 22
      modules/lemonldap-ng-common/t/35-Common-Crypto.t
  3. 44
      modules/lemonldap-ng-common/t/36-Common-Regexp.t

@ -21,12 +21,11 @@ __END__
=pod
=cut
sub reDomainsToHost {
my $list = shift;
return qr/^$/ unless($list);
$list =~ s/^\./\\\./;
$list = join('|',split (/\s+/,$list);
return qr/^$/ unless ($list);
$list =~ s/^\./\\\./g;
$list = join( '|', split( /\s+/, $list ) );
return qr/^(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:$list)$/;
}

@ -5,11 +5,29 @@
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1;
BEGIN { use_ok('Lemonldap::NG::Common::Crypto') }
use Test::More tests => 19;
use strict;
BEGIN {
use_ok('Lemonldap::NG::Common::Crypto');
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
my $c;
ok(
$c = Lemonldap::NG::Common::Crypto->new(
'lemonldap-ng-key', Crypt::Rijndael::MODE_CBC()
),
'New object'
);
foreach my $i ( 1 .. 17 ) {
my $s = '';
$s = join( '', map { chr( int( rand(94) ) + 33 ) } ( 1 .. $i ) );
ok( $c->decrypt( $c->encrypt($s) ) eq $s, "Test with $i characters string" );
}

@ -0,0 +1,44 @@
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Common.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 20;
use strict;
BEGIN {
use_ok('Lemonldap::NG::Common::Regexp');
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
*HOST = *Lemonldap::NG::Common::Regexp::HOST;
*HOSTNAME = *Lemonldap::NG::Common::Regexp::HOSTNAME;
*HTTP_URI = *Lemonldap::NG::Common::Regexp::HTTP_URI;
*reDomainsToHost = *Lemonldap::NG::Common::Regexp::reDomainsToHost;
ok( 'test.ex.com' =~ HOST() );
ok( 'test.ex.com' =~ HOSTNAME() );
ok( 'test..ex.com' !~ HOST() );
ok( 'test..ex.com' !~ HOSTNAME() );
ok( '10.1.1.1' =~ HOST() );
ok( '10.1.1.1' !~ HOSTNAME() );
ok( 'test.ex.com' !~ HTTP_URI() );
ok( 'https://test.ex.com' =~ HTTP_URI() );
ok( 'https://test.ex.com/' =~ HTTP_URI() );
ok( 'https://test.ex.com/a' =~ HTTP_URI() );
ok( 'https://test.ex.com/?<script>' !~ HTTP_URI() );
my $re;
ok( $re = reDomainsToHost('a.com b.org c.net') );
ok( 'test.d.fr' !~ $re );
foreach (qw(a.com b.org c.net)) {
ok( "test.$_" =~ $re );
ok( "test..$_" !~ $re );
}
Loading…
Cancel
Save