LEMONLDAP::NG : more tests in Handler and perltidy on test files

environments/ppa-mbqj77/deployments/1
Xavier Guimard 18 years ago
parent d5bdcdcd80
commit cf4f11b7a0
  1. 2
      modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler.pm
  2. 3
      modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CGI.pm
  3. 8
      modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm
  4. 2
      modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Vhost.pm
  5. 2
      modules/lemonldap-ng-handler/t/Lemonldap-NG-Handler-CDA.t
  6. 2
      modules/lemonldap-ng-handler/t/Lemonldap-NG-Handler-CGI.t
  7. 2
      modules/lemonldap-ng-handler/t/Lemonldap-NG-Handler-Proxy.t
  8. 2
      modules/lemonldap-ng-handler/t/Lemonldap-NG-Handler-SharedConf.t
  9. 42
      modules/lemonldap-ng-handler/t/Lemonldap-NG-Handler-Simple.t
  10. 34
      modules/lemonldap-ng-handler/t/Lemonldap-NG-Handler-Vhost.t
  11. 2
      modules/lemonldap-ng-manager/t/Lemonldap-NG-Manager-Conf-DBI.t
  12. 2
      modules/lemonldap-ng-manager/t/Lemonldap-NG-Manager-Conf-File.t
  13. 6
      modules/lemonldap-ng-manager/t/Lemonldap-NG-Manager-Conf-SOAP.t
  14. 2
      modules/lemonldap-ng-manager/t/Lemonldap-NG-Manager-Conf.t
  15. 12
      modules/lemonldap-ng-manager/t/Lemonldap-NG-Manager.t
  16. 8
      modules/lemonldap-ng-manager/t/Lemonldap-NG-Manager_en.t
  17. 8
      modules/lemonldap-ng-manager/t/Lemonldap-NG-Manager_fr.t
  18. 10
      modules/lemonldap-ng-portal/t/Lemonldap-NG-Portal-AuthApache.t
  19. 13
      modules/lemonldap-ng-portal/t/Lemonldap-NG-Portal-AuthCAS.t
  20. 6
      modules/lemonldap-ng-portal/t/Lemonldap-NG-Portal-AuthLA.t
  21. 10
      modules/lemonldap-ng-portal/t/Lemonldap-NG-Portal-AuthSSL.t
  22. 2
      modules/lemonldap-ng-portal/t/Lemonldap-NG-Portal-CDA.t
  23. 6
      modules/lemonldap-ng-portal/t/Lemonldap-NG-Portal-SharedConf.t
  24. 10
      modules/lemonldap-ng-portal/t/Lemonldap-NG-Portal-Simple.t
  25. 4
      modules/lemonldap-ng-portal/t/Lemonldap-NG-Portal-i18n.t

@ -2,7 +2,7 @@ package Lemonldap::NG::Handler;
print STDERR print STDERR
"See Lemonldap::NG::Handler(3) to know which Lemonldap::NG::Handler::* module to use."; "See Lemonldap::NG::Handler(3) to know which Lemonldap::NG::Handler::* module to use.";
our $VERSION = "0.8"; our $VERSION = "0.81";
1; 1;

@ -10,13 +10,14 @@ our @ISA = qw(CGI);
use Lemonldap::NG::Handler::SharedConf qw(:all); use Lemonldap::NG::Handler::SharedConf qw(:all);
our $VERSION = '0.01'; our $VERSION = '0.02';
sub new { sub new {
my $class = shift; my $class = shift;
my $self = $class->SUPER::new(); my $self = $class->SUPER::new();
$self->{_handler} = bless {}, 'Lemonldap::NG::Handler::_CGI'; $self->{_handler} = bless {}, 'Lemonldap::NG::Handler::_CGI';
$self->_handler->init( @_ ); $self->_handler->init( @_ );
$self->initLocalStorage();
die "Unable to get configuration" unless $self->_handler->localConfUpdate() == OK; die "Unable to get configuration" unless $self->_handler->localConfUpdate() == OK;
return $self; return $self;
} }

@ -7,7 +7,7 @@ use Exporter 'import';
use Safe; use Safe;
require POSIX; require POSIX;
our $VERSION = '0.8'; our $VERSION = '0.81';
our %EXPORT_TAGS = ( our %EXPORT_TAGS = (
localStorage => localStorage =>
@ -231,7 +231,7 @@ sub localInit($$) {
$localStorageOptions->{default_expires_in} ||= 600; $localStorageOptions->{default_expires_in} ||= 600;
eval "use $localStorage;"; eval "use $localStorage;";
die("Unable to load $localStorage") if ($@); die("Unable to load $localStorage: $@") if ($@);
# At each Apache (re)start, we've to clear the cache to avoid living # At each Apache (re)start, we've to clear the cache to avoid living
# with old datas # with old datas
@ -269,6 +269,7 @@ sub localInit($$) {
PerlCleanupHandler => sub { return $class->cleanLocalStorage(@_); } PerlCleanupHandler => sub { return $class->cleanLocalStorage(@_); }
); );
} }
1;
} }
# Global initialization process : # Global initialization process :
@ -308,6 +309,7 @@ sub locationRulesInit {
# Default police: all authenticated users are accepted # Default police: all authenticated users are accepted
$defaultCondition = $class->conditionSub('accept') $defaultCondition = $class->conditionSub('accept')
unless ($defaultCondition); unless ($defaultCondition);
1;
} }
# conditionSub returns a pre-compiled subroutine used to grant users (used by # conditionSub returns a pre-compiled subroutine used to grant users (used by
@ -336,6 +338,7 @@ sub defaultValuesInit {
$whatToTrace =~ s/\$//g; $whatToTrace =~ s/\$//g;
$https = $args->{https} unless defined($https); $https = $args->{https} unless defined($https);
$https = 1 unless defined($https); $https = 1 unless defined($https);
1;
} }
# portalInit : verify that portal variable exists # portalInit : verify that portal variable exists
@ -385,6 +388,7 @@ sub forgeHeadersInit {
$forgeHeaders = $safe->reval("sub {$sub};"); $forgeHeaders = $safe->reval("sub {$sub};");
$class->lmLog( "$class: Unable to forge headers: $@: sub {$sub}", 'error' ) $class->lmLog( "$class: Unable to forge headers: $@: sub {$sub}", 'error' )
if ($@); if ($@);
1;
} }
################ ################

@ -29,6 +29,7 @@ sub locationRulesInit {
$defaultCondition->{$vhost} = $class->conditionSub('accept') $defaultCondition->{$vhost} = $class->conditionSub('accept')
unless ( $defaultCondition->{$vhost} ); unless ( $defaultCondition->{$vhost} );
} }
1;
} }
sub forgeHeadersInit { sub forgeHeadersInit {
@ -56,6 +57,7 @@ sub forgeHeadersInit {
'error' ) 'error' )
if ($@); if ($@);
} }
1;
} }
sub sendHeaders { sub sendHeaders {

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; use Test::More tests => 1;
BEGIN { use_ok('Lemonldap::NG::Handler::CDA') }; BEGIN { use_ok('Lemonldap::NG::Handler::CDA') }
######################### #########################

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; use Test::More tests => 1;
BEGIN { use_ok('Lemonldap::NG::Handler::CGI') }; BEGIN { use_ok('Lemonldap::NG::Handler::CGI') }
######################### #########################

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; use Test::More tests => 1;
BEGIN { use_ok('Lemonldap::NG::Handler::Proxy') }; BEGIN { use_ok('Lemonldap::NG::Handler::Proxy') }
######################### #########################

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; use Test::More tests => 1;
BEGIN { use_ok('Lemonldap::NG::Handler::SharedConf') }; BEGIN { use_ok('Lemonldap::NG::Handler::SharedConf') }
######################### #########################

@ -5,11 +5,49 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; use Test::More tests => 11;
BEGIN { use_ok('Lemonldap::NG::Handler::Simple') }; BEGIN { use_ok( 'Lemonldap::NG::Handler::Simple', ':all' ) }
######################### #########################
# Insert your test code below, the Test::More module is use()ed here so read # 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. # its man page ( perldoc Test::More ) for help writing this test script.
my $h;
$h = bless {}, 'Lemonldap::NG::Handler::Simple';
ok(
$h->localInit(
{
localStorage => 'Cache::FileCache',
localStorageOptions => { 'namespace' => 'MyNamespace', },
}
)
);
ok(
$h->locationRulesInit(
{
locationRules => {
default => 'accept',
'^/no' => 'deny',
'test' => '$groups =~ /\badmin\b/',
},
}
)
);
ok( $h->defaultValuesInit() );
ok( $h->portalInit( { portal => 'http://auth.example.com' } ) );
ok(
$h->globalStorageInit(
{
globalStorage => 'Apache::Session::File',
globalStorageOptions => {},
}
)
);
ok( $h->forgeHeadersInit );
ok( $h->forgeHeadersInit( { exportedHeaders => { Auth => '$uid', } } ) );
ok( $h->grant('/s') );
ok( !$h->grant('/no') );
ok( $h->cleanLocalStorage == DECLINED );

@ -5,11 +5,41 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; package My::Package;
BEGIN { use_ok('Lemonldap::NG::Handler::Vhost') };
use Test::More tests => 4;
BEGIN {
use_ok('Lemonldap::NG::Handler::Vhost');
use_ok('Lemonldap::NG::Handler::Simple');
}
######################### #########################
# Insert your test code below, the Test::More module is use()ed here so read # 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. # its man page ( perldoc Test::More ) for help writing this test script.
our @ISA = qw( Lemonldap::NG::Handler::Vhost Lemonldap::NG::Handler::Simple );
my $h;
$h = bless {}, 'My::Package';
ok(
$h->locationRulesInit(
{
locationRules => {
www1 => {
default => 'accept',
'^/no' => 'deny',
'test' => '$groups =~ /\badmin\b/',
},
},
}
)
);
ok(
$h->forgeHeadersInit(
{ exportedHeaders => { www1 => { Auth => '$uid', } } }
)
);

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; use Test::More tests => 1;
BEGIN { use_ok('Lemonldap::NG::Manager::Conf::DBI') }; BEGIN { use_ok('Lemonldap::NG::Manager::Conf::DBI') }
######################### #########################

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; use Test::More tests => 1;
BEGIN { use_ok('Lemonldap::NG::Manager::Conf::File') }; BEGIN { use_ok('Lemonldap::NG::Manager::Conf::File') }
######################### #########################

@ -6,11 +6,15 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; use Test::More tests => 1;
# SOAP::Lite is not required, so Lemonldap::NG::Manager::Conf::SOAP may # SOAP::Lite is not required, so Lemonldap::NG::Manager::Conf::SOAP may
# not run. # not run.
SKIP: { SKIP: {
eval { require SOAP::Lite }; eval { require SOAP::Lite };
skip "SOAP::Lite is not installed, so SOAP configuration access will not work", 1 if($@); skip
"SOAP::Lite is not installed, so SOAP configuration access will not work",
1
if ($@);
use_ok('Lemonldap::NG::Manager::Conf::SOAP'); use_ok('Lemonldap::NG::Manager::Conf::SOAP');
} }

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; use Test::More tests => 1;
BEGIN { use_ok('Lemonldap::NG::Manager::Conf') }; BEGIN { use_ok('Lemonldap::NG::Manager::Conf') }
######################### #########################

@ -16,8 +16,9 @@ BEGIN { use_ok('Lemonldap::NG::Manager') }
$ENV{SCRIPT_NAME} = "__SCRIPTNAME__"; $ENV{SCRIPT_NAME} = "__SCRIPTNAME__";
$ENV{SCRIPT_FILENAME} = $0; $ENV{SCRIPT_FILENAME} = $0;
my $h; my $h;
@ARGV = ( "help=groups" ); @ARGV = ("help=groups");
ok( $h = new Lemonldap::NG::Manager( ok(
$h = new Lemonldap::NG::Manager(
{ {
configStorage => { configStorage => {
type => 'File', type => 'File',
@ -26,7 +27,8 @@ ok( $h = new Lemonldap::NG::Manager(
dhtmlXTreeImageLocation => "/imgs/", dhtmlXTreeImageLocation => "/imgs/",
jsFile => 'example/lemonldap-ng-manager.js', jsFile => 'example/lemonldap-ng-manager.js',
} }
)); )
);
ok( $h->header_public() ); ok( $h->header_public() );
ok( $h->start_html() ); ok( $h->start_html() );
ok( $h->main() ); ok( $h->main() );
@ -36,10 +38,10 @@ ok( $h->print_lmjs() );
ok( $h->print_help() ); ok( $h->print_help() );
ok( $h->buildTree() ); ok( $h->buildTree() );
my $tmp = &xml; my $tmp = &xml;
ok( ref($h->tree2conf( \$tmp )) ); ok( ref( $h->tree2conf( \$tmp ) ) );
sub xml { sub xml {
return << 'EOF'; return << 'EOF';
<root><text>Configuration 9</text> <root><text>Configuration 9</text>
<generalParameters><text>Paramtres gnraux</text> <generalParameters><text>Paramtres gnraux</text>
<authParams><text>Paramtres d'authentification</text> <authParams><text>Paramtres d'authentification</text>

@ -17,8 +17,9 @@ $ENV{SCRIPT_NAME} = "__SCRIPTNAME__";
$ENV{SCRIPT_FILENAME} = $0; $ENV{SCRIPT_FILENAME} = $0;
$ENV{HTTP_ACCEPT_LANGUAGE} = "en"; $ENV{HTTP_ACCEPT_LANGUAGE} = "en";
my $h; my $h;
@ARGV = ( "help=groups" ); @ARGV = ("help=groups");
ok( $h = new Lemonldap::NG::Manager( ok(
$h = new Lemonldap::NG::Manager(
{ {
configStorage => { configStorage => {
type => 'File', type => 'File',
@ -27,7 +28,8 @@ ok( $h = new Lemonldap::NG::Manager(
dhtmlXTreeImageLocation => "/imgs/", dhtmlXTreeImageLocation => "/imgs/",
jsFile => 'example/lemonldap-ng-manager.js', jsFile => 'example/lemonldap-ng-manager.js',
} }
)); )
);
ok( $h->main() ); ok( $h->main() );
ok( $h->print_help() ); ok( $h->print_help() );
ok( $h->buildTree() ); ok( $h->buildTree() );

@ -17,8 +17,9 @@ $ENV{SCRIPT_NAME} = "__SCRIPTNAME__";
$ENV{SCRIPT_FILENAME} = $0; $ENV{SCRIPT_FILENAME} = $0;
$ENV{HTTP_ACCEPT_LANGUAGE} = "fr"; $ENV{HTTP_ACCEPT_LANGUAGE} = "fr";
my $h; my $h;
@ARGV = ( "help=groups" ); @ARGV = ("help=groups");
ok( $h = new Lemonldap::NG::Manager( ok(
$h = new Lemonldap::NG::Manager(
{ {
configStorage => { configStorage => {
type => 'File', type => 'File',
@ -27,7 +28,8 @@ ok( $h = new Lemonldap::NG::Manager(
dhtmlXTreeImageLocation => "/imgs/", dhtmlXTreeImageLocation => "/imgs/",
jsFile => 'example/lemonldap-ng-manager.js', jsFile => 'example/lemonldap-ng-manager.js',
} }
)); )
);
ok( $h->main() ); ok( $h->main() );
ok( $h->print_help() ); ok( $h->print_help() );
ok( $h->buildTree() ); ok( $h->buildTree() );

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 2; use Test::More tests => 2;
BEGIN { use_ok('Lemonldap::NG::Portal::Simple') }; BEGIN { use_ok('Lemonldap::NG::Portal::Simple') }
######################### #########################
@ -14,9 +14,13 @@ BEGIN { use_ok('Lemonldap::NG::Portal::Simple') };
# its man page ( perldoc Test::More ) for help writing this test script. # its man page ( perldoc Test::More ) for help writing this test script.
my $p; my $p;
ok( $p = Lemonldap::NG::Portal::Simple->new( { ok(
$p = Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File', globalStorage => 'Apache::Session::File',
domain => 'example.com', domain => 'example.com',
authentication => 'Apache', authentication => 'Apache',
} ) ); }
)
);

@ -16,13 +16,20 @@ use Test::More tests => 2;
# not run. # not run.
SKIP: { SKIP: {
eval { require AuthCAS }; 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 ($@);
use_ok('Lemonldap::NG::Portal::Simple'); use_ok('Lemonldap::NG::Portal::Simple');
my $p; my $p;
ok( $p = Lemonldap::NG::Portal::Simple->new( { ok(
$p = Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File', globalStorage => 'Apache::Session::File',
domain => 'example.com', domain => 'example.com',
authentication => 'CAS', authentication => 'CAS',
} ) ); }
)
);
} }

@ -6,11 +6,15 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; use Test::More tests => 1;
# SOAP::Lite is not required, so Lemonldap::NG::Manager::Conf::SOAP may # SOAP::Lite is not required, so Lemonldap::NG::Manager::Conf::SOAP may
# not run. # not run.
SKIP: { SKIP: {
eval { require lasso }; eval { require lasso };
skip "lasso is not installed, so Lemonldap::NG::Portal::AuthLA will not be useable", 1 if($@); skip
"lasso is not installed, so Lemonldap::NG::Portal::AuthLA will not be useable",
1
if ($@);
use_ok('Lemonldap::NG::Portal::AuthLA'); use_ok('Lemonldap::NG::Portal::AuthLA');
} }

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 2; use Test::More tests => 2;
BEGIN { use_ok('Lemonldap::NG::Portal::Simple') }; BEGIN { use_ok('Lemonldap::NG::Portal::Simple') }
######################### #########################
@ -14,9 +14,13 @@ BEGIN { use_ok('Lemonldap::NG::Portal::Simple') };
# its man page ( perldoc Test::More ) for help writing this test script. # its man page ( perldoc Test::More ) for help writing this test script.
my $p; my $p;
ok( $p = Lemonldap::NG::Portal::Simple->new( { ok(
$p = Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File', globalStorage => 'Apache::Session::File',
domain => 'example.com', domain => 'example.com',
authentication => 'SSL', authentication => 'SSL',
} ) ); }
)
);

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1; use Test::More tests => 1;
BEGIN { use_ok('Lemonldap::NG::Portal::CDA') }; BEGIN { use_ok('Lemonldap::NG::Portal::CDA') }
######################### #########################

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 3; use Test::More tests => 3;
BEGIN { use_ok('Lemonldap::NG::Portal::SharedConf') }; BEGIN { use_ok('Lemonldap::NG::Portal::SharedConf') }
######################### #########################
@ -14,6 +14,6 @@ BEGIN { use_ok('Lemonldap::NG::Portal::SharedConf') };
# its man page ( perldoc Test::More ) for help writing this test script. # its man page ( perldoc Test::More ) for help writing this test script.
my $p = bless {}, 'Lemonldap::NG::Portal::SharedConf'; my $p = bless {}, 'Lemonldap::NG::Portal::SharedConf';
ok( ! $p->scanexpr ( '1 == 0' ) ); ok( !$p->scanexpr('1 == 0') );
ok( $p->scanexpr ( '1 == 1' ) ); ok( $p->scanexpr('1 == 1') );

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 5; use Test::More tests => 5;
BEGIN { use_ok('Lemonldap::NG::Portal::Simple', ':all') }; BEGIN { use_ok( 'Lemonldap::NG::Portal::Simple', ':all' ) }
######################### #########################
@ -14,10 +14,14 @@ BEGIN { use_ok('Lemonldap::NG::Portal::Simple', ':all') };
# its man page ( perldoc Test::More ) for help writing this test script. # its man page ( perldoc Test::More ) for help writing this test script.
my $p; my $p;
ok( $p = Lemonldap::NG::Portal::Simple->new( { ok(
$p = Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File', globalStorage => 'Apache::Session::File',
domain => 'example.com', domain => 'example.com',
} ) ); }
)
);
ok( $p->process == 0 ); ok( $p->process == 0 );
ok( $p->{error} == PE_FIRSTACCESS ); ok( $p->{error} == PE_FIRSTACCESS );

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print'; # change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 31; use Test::More tests => 31;
BEGIN { use_ok('Lemonldap::NG::Portal::Simple', ':all') }; BEGIN { use_ok( 'Lemonldap::NG::Portal::Simple', ':all' ) }
######################### #########################
@ -15,7 +15,7 @@ BEGIN { use_ok('Lemonldap::NG::Portal::Simple', ':all') };
my $p = bless {}, 'Lemonldap::NG::Portal::Simple'; my $p = bless {}, 'Lemonldap::NG::Portal::Simple';
foreach my $i (1..10) { foreach my $i ( 1 .. 10 ) {
$p->{error} = $i; $p->{error} = $i;
ok( $p->error('fr;en') ); ok( $p->error('fr;en') );
ok( $p->error('en') ); ok( $p->error('en') );

Loading…
Cancel
Save