LEMONLDAP::NG : tests update

This commit is contained in:
Xavier Guimard 2008-06-06 03:53:14 +00:00
parent 7bac798370
commit 6679fe6f2b
16 changed files with 208 additions and 158 deletions

View File

@ -45,7 +45,7 @@ manager_conf:
cd ${MANAGERDIR}; perl Makefile.PL INSTALLDIRS=$(INSTALLDIRS)
touch manager_conf
test: manager_test handler_test portal_test
test: manager handler portal manager_test handler_test portal_test
manager_test: manager
$(MAKE) -C ${MANAGERDIR} test
@ -74,7 +74,7 @@ distclean: clean
clean: handler_clean portal_clean manager_clean
rm -rf example
find . -name '*.gz' -exec rm -vf {} \;
rm -vf *gz
handler_clean:
- $(MAKE) -C ${HANDLERDIR} distclean

View File

@ -78,8 +78,6 @@ t/03-Manager-Conf-DBI.t
t/04-Manager-Conf-SOAP.t
t/10-Manager.t
t/20-Manager-i18n.t
t/21-Manager-i18n-en.t
t/22-Manager-i18n-fr.t
t/50-Manager-SOAPServer.t
t/99-pod.t
TODO

View File

@ -155,7 +155,7 @@ sub fr {
isNotAValidDomainName => "n'est pas un nom de domaine valide",
isNotAValidGroupName => "n'est pas un nom de groupe valide",
isNotAValidHTTPHeaderName => "n'est pas un nom d'en-tête HTTP valide",
isNotAValidLDAPAttributeName => "is not a valid LDAP attribute name",
isNotAValidLDAPAttributeName => "n'est pas un nom d'attribut LDAP valide",
isNotAValidMacroName => "n'est pas un nom de macro valide",
isNotAValidVirtualHostName => "n'est pas un nom d'hôte virtuel valide",
lastConf => "Dernière",

View File

@ -1,23 +1,75 @@
use Test::More tests => 2;
BEGIN { use_ok('Lemonldap::NG::Manager::_i18n') }
# Lemonldap::NG::Manager translation test
#
# Here, we test :
# 1) each keyword is translated in each language
# 2) display functions in english language
ok ( &compare ( "en", "fr" ) );
BEGIN {
our %lang = (
en => 'English',
fr => 'French',
);
}
use Test::More tests => ( keys(%lang) + 4 );
use_ok('Lemonldap::NG::Manager');
my $win = 0;
$win ++ unless( -e '/dev/null' );
if($win) {
open STDOUT, '>test_stdout.txt';
}
else {
open STDOUT, '>/dev/null';
}
foreach ( keys %lang ) {
ok( &compare( "en", $_ ),
"Compare English and $lang{$_} translation coverage" )
unless ( $_ eq 'en' );
}
$ENV{SCRIPT_NAME} = "__SCRIPTNAME__";
$ENV{SCRIPT_FILENAME} = $0;
$ENV{HTTP_ACCEPT_LANGUAGE} = 'en';
my $h;
@ARGV = ("help=groups");
ok(
$h = new Lemonldap::NG::Manager(
{
configStorage => {
type => 'File',
dirName => ".",
},
dhtmlXTreeImageLocation => "/imgs/",
jsFile => 'example/lemonldap-ng-manager.js',
}
),
'New manager object'
);
ok( $h->main(), "HTML code" );
ok( $h->print_help(), "Help page" );
ok( $h->buildTree(), "XML tree" );
unlink('test_stdout.txt') if($win);
sub compare {
my ( $l1, $l2 ) = @_;
$r1 = &{"Lemonldap::NG::Manager::_i18n::" . $l1};
$r2 = &{"Lemonldap::NG::Manager::_i18n::" . $l2};
$r1 = &{ "Lemonldap::NG::Manager::_i18n::" . $l1 };
$r2 = &{ "Lemonldap::NG::Manager::_i18n::" . $l2 };
my $r = 1;
foreach ( keys %$r1 ) {
unless( $r2->{$_} ) {
unless ( $r2->{$_} ) {
print STDERR "$_ is present in $l1 but miss in $l2";
$r=0;
$r = 0;
}
}
foreach ( keys %$r2 ) {
unless( $r1->{$_} ) {
unless ( $r1->{$_} ) {
print STDERR "$_ is present in $l2 but miss in $l1";
$r=0;
$r = 0;
}
}
return $r;

View File

@ -1,35 +0,0 @@
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Manager.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 5;
BEGIN { use_ok('Lemonldap::NG::Manager') }
#########################
# 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.
$ENV{SCRIPT_NAME} = "__SCRIPTNAME__";
$ENV{SCRIPT_FILENAME} = $0;
$ENV{HTTP_ACCEPT_LANGUAGE} = "en";
my $h;
@ARGV = ("help=groups");
ok(
$h = new Lemonldap::NG::Manager(
{
configStorage => {
type => 'File',
dirName => ".",
},
dhtmlXTreeImageLocation => "/imgs/",
jsFile => 'example/lemonldap-ng-manager.js',
}
)
);
ok( $h->main() );
ok( $h->print_help() );
ok( $h->buildTree() );

View File

@ -1,35 +0,0 @@
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Manager.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 5;
BEGIN { use_ok('Lemonldap::NG::Manager') }
#########################
# 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.
$ENV{SCRIPT_NAME} = "__SCRIPTNAME__";
$ENV{SCRIPT_FILENAME} = $0;
$ENV{HTTP_ACCEPT_LANGUAGE} = "fr";
my $h;
@ARGV = ("help=groups");
ok(
$h = new Lemonldap::NG::Manager(
{
configStorage => {
type => 'File',
dirName => ".",
},
dhtmlXTreeImageLocation => "/imgs/",
jsFile => 'example/lemonldap-ng-manager.js',
}
)
);
ok( $h->main() );
ok( $h->print_help() );
ok( $h->buildTree() );

View File

@ -0,0 +1,87 @@
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Portal.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 12;
BEGIN { use_ok( 'Lemonldap::NG::Portal::Simple', ':all' ) }
SKIP: {
eval { require Net::LDAP::Control::PasswordPolicy };
skip
"Net::LDAP Password Policy Control is not installed (perl-ldap >= 0.35), so Password Policy will not be usable",
1
if ($@);
use_ok('Net::LDAP::Control::PasswordPolicy');
}
#########################
# 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 $p;
# CGI Environment
$ENV{SCRIPT_NAME} = '/test.pl';
$ENV{SCRIPT_FILENAME} = '/tmp/test.pl';
$ENV{REQUEST_METHOD} = 'GET';
$ENV{REQUEST_URI} = '/';
$ENV{QUERY_STRING} = '';
ok(
$p = Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'LDAP test=1',
}
),
'Portal object'
);
# Arg test passed
ok( $p->{test}, 'Authentication arguments' );
# Process test: first access
ok( $p->process == 0, 'No user' );
ok( $p->{error} == PE_FIRSTACCESS, 'Error code: first access' );
# Process test: user without password
$ENV{REQUEST_URI} = '/?user=test';
$ENV{QUERY_STRING} = 'user=test';
$p = Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
}
);
ok( $p->process == 0, 'User without password' );
ok( $p->{error} == PE_FORMEMPTY, 'Error code: missing password' );
# Process test without LDAP
# No ldap
$p->{extractFormInfo} = sub {
my $self = shift;
$self->{user} = 'user';
PE_OK;
};
$p->{connectLDAP} = sub { PE_OK };
$p->{bind} = sub { PE_OK };
$p->{search} = sub { PE_OK };
$p->{setSessionInfo} = sub { PE_OK };
$p->{unbind} = sub { PE_OK };
$p->{store} = sub { PE_OK };
ok( $p->process, 'User OK' );
# Cookie test
$p->{id} = 1;
ok( $p->buildCookie == PE_OK, 'Cookie build' );
ok( ( ref( $p->{cookie} ) eq 'ARRAY' and $p->{cookie}->[0]->isa('CGI::Cookie') ), 'Valid cookie' );
ok( $p->{cookie}->[0]->value eq '1', 'Cookie value' );

View File

@ -0,0 +1,39 @@
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Portal.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
BEGIN {
our %translations = (
fr => 'French',
ro => 'Romanian'
);
}
use Test::More tests => 5 + ( keys(%translations) * 2 );
BEGIN { use_ok('Lemonldap::NG::Portal::Simple') }
#########################
# 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.
ok( my @en = @{&Lemonldap::NG::Portal::_i18n::error_en},
'English translation' );
ok( $#en > 21, 'Translation count' );
foreach ( keys %translations ) {
ok( my @tmp = @{ &{"Lemonldap::NG::Portal::_i18n::error_$_"} },
"$translations{$_} translation" );
ok( $#tmp == $#en, "$translations{$_} translation count" );
}
my $p = bless {}, 'Lemonldap::NG::Portal::Simple';
$p->{error} = 10;
$ENV{HTTP_ACCEPT_LANGUAGE} = 'fr';
ok( $p->error() eq $p->error('fr'), 'HTTP_ACCEPT_LANGUAGE mechanism 1' );
ok( $p->error() ne $p->error('ro'), 'HTTP_ACCEPT_LANGUAGE mechanism 2' );

View File

@ -17,9 +17,9 @@ my $p;
ok(
$p = Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Apache',
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Apache',
}
)
);

View File

@ -17,9 +17,10 @@ my $p;
ok(
$p = Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'SSL',
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'SSL',
SSLRequired => 0,
}
)
);

View File

@ -16,16 +16,22 @@ use Test::More tests => 1;
# not run.
SKIP: {
eval { require AuthCAS };
skip "AuthCAS is not installed, so Lemonldap::NG::Portal::AuthCAS will not be useable", 1 if ($@);
skip
"AuthCAS is not installed, so Lemonldap::NG::Portal::AuthCAS will not be useable",
1
if ($@);
my $p;
eval { require Lemonldap::NG::Portal::Simple };
skip "Problem with Lemonldap::NG::Portal::Simple, Lemonldap::NG::Portal::AuthCAS will not be tested", 1 if ($@);
skip
"Problem with Lemonldap::NG::Portal::Simple, Lemonldap::NG::Portal::AuthCAS will not be tested",
1
if ($@);
ok(
$p = Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'CAS',
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'CAS',
}
)
);

View File

@ -1,39 +0,0 @@
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Portal.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 6;
BEGIN { use_ok( 'Lemonldap::NG::Portal::Simple', ':all' ) }
SKIP: {
eval { require Net::LDAP::Control::PasswordPolicy };
skip "Net::LDAP Password Policy Control is not installed (perl-ldap >= 0.35), so Password Policy will not be usable",
1
if ($@);
use_ok('Net::LDAP::Control::PasswordPolicy')
}
#########################
# 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 $p;
ok(
$p = Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
}
)
);
ok( $p->process == 0 );
ok( $p->{error} == PE_FIRSTACCESS );
$p->{id} = 1;
ok( $p->buildCookie == PE_OK );

View File

@ -1,24 +0,0 @@
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Portal.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 34;
BEGIN { use_ok( 'Lemonldap::NG::Portal::Simple', ':all' ) }
#########################
# 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 $p = bless {}, 'Lemonldap::NG::Portal::Simple';
foreach my $i ( 0 .. 10 ) {
$p->{error} = $i;
ok( $p->error('fr') );
ok( $p->error('en') );
ok( $p->error('') );
}