Commit 3844ba41 authored by Yadd's avatar Yadd

"make tidy"

parent c7c093b4
......@@ -622,6 +622,6 @@ default-diff:
@$(DIFF) lemonldap-ng-manager/example/sessions.pl $(LMPREFIX)/htdocs/manager/sessions.pl ||true
tidy: clean
find lemon*/ -type f \( -name '*.pm' -or -name '*.pl' -or -name '*.t' \) -exec perltidy -b {} \;
find lemon*/ -type f \( -name '*.pm' -or -name '*.pl' -or -name '*.t' \) -print -exec perltidy -b {} \;
find lemon*/ -name '*.bak' -delete
......@@ -8,7 +8,8 @@ use Lemonldap::NG::Handler::ZimbraPreAuth;
__PACKAGE__->init(
{
# See Lemonldap::NG::Handler
# See Lemonldap::NG::Handler
}
);
......
......@@ -6,6 +6,7 @@ use Lemonldap::NG::Handler::UpdateCookie;
__PACKAGE__->init(
{
# See Lemonldap::NG::Handler
}
);
......
......@@ -33,12 +33,14 @@ sub run {
$datas->{_session_id} = 0;
$clear = 1;
}
elsif ( $refLocalStorage and my $ldatas = $refLocalStorage->get($id) ) {
elsif ( $refLocalStorage
and my $ldatas = $refLocalStorage->get($id) )
{
if ( $ldatas->{_utime} lt $utime ) {
$clear = 1;
}
}
if ( $clear ) {
if ($clear) {
$class->lmLog( "$class: remove $id from local cache", 'debug' );
$refLocalStorage->remove($id);
}
......
......@@ -425,7 +425,8 @@ sub struct {
grantSessionRule => 'textarea:/grantSessionRule',
storePassword => 'bool:/storePassword',
timeout => 'text:/timeout:timeout:text',
timeoutActivity => 'text:/timeoutActivity:timeoutActivity:timeoutActivityParams',
timeoutActivity =>
'text:/timeoutActivity:timeoutActivity:timeoutActivityParams',
sessionStorage => {
_nodes => [qw(globalStorage globalStorageOptions)],
......
......@@ -434,27 +434,27 @@ sub fr {
SSLVar => 'Champ extrait du certificat',
storePassword =>
"Stocke le mot-de-passe de l'utilisateur dans les données de session",
syntaxError => 'Erreur de syntaxe',
syslog => 'Facilité syslog',
timeout => 'Durée de vie maximale des sessions',
syntaxError => 'Erreur de syntaxe',
syslog => 'Facilité syslog',
timeout => 'Durée de vie maximale des sessions',
timeoutActivity => 'Délai d\'expiration des sessions',
trustedDomains => 'Domaines appouvés',
twitterAppName => 'Nom de l\'application',
twitterKey => 'Clé de l\'API',
twitterParams => 'Paramètres Twitter',
twitterSecret => 'Secret de l\'API',
unknownError => 'Erreur inconnue',
uploadDenied => 'Téléchargement refusé',
user => 'utilisateur',
users => 'utilisateurs',
userDB => "Module d'utilisateurs",
userControl => "Contrôle du nom d'utilisateur",
userPivot => 'Champ identifiant dans la table des utilisateurs',
trustedDomains => 'Domaines appouvés',
twitterAppName => 'Nom de l\'application',
twitterKey => 'Clé de l\'API',
twitterParams => 'Paramètres Twitter',
twitterSecret => 'Secret de l\'API',
unknownError => 'Erreur inconnue',
uploadDenied => 'Téléchargement refusé',
user => 'utilisateur',
users => 'utilisateurs',
userDB => "Module d'utilisateurs",
userControl => "Contrôle du nom d'utilisateur",
userPivot => 'Champ identifiant dans la table des utilisateurs',
useXForwardedForIP =>
"Utiliser l'adresse IP de l'en-tête X-Forwarded-For",
variables => "Variables",
virtualHosts => 'Hôtes virtuels',
whatToTrace => "Variable d'environnement REMOTE_USER",
variables => "Variables",
virtualHosts => 'Hôtes virtuels',
whatToTrace => "Variable d'environnement REMOTE_USER",
zimbraAccountKey => 'Clé de session pour le compte',
zimbraBy => 'Type de compte',
zimbraHandler => 'Zimbra',
......
......@@ -49,11 +49,13 @@ if ( $portal->process() ) {
# 1.1 Image mode
if ( $portal->{error} == PE_IMG_OK || $portal->{error} == PE_IMG_NOK ) {
$skinfile = $skin_dir . '/common/ok.png';
if ( $portal->{error} == PE_IMG_NOK ) {
$skinfile = $skin_dir . '/common/warning.png';
}
$portal->printImage($skinfile, 'image/png');
$skinfile = "$skin_dir/common/"
. (
$portal->{error} == PE_IMG_OK
? 'ok.png'
: 'warning.png'
);
$portal->printImage( $skinfile, 'image/png' );
exit;
}
......
......@@ -436,7 +436,7 @@ sub extractFormInfo {
$self->lmLog( "Logout request NameID content: $user", 'debug' );
# Get corresponding session
# TODO use SAML sessionIndex
# TODO use SAML sessionIndex
my $local_sessions =
$self->{samlStorage}
->searchOn( $self->{samlStorageOptions}, "_user", $user, );
......
......@@ -207,7 +207,7 @@ sub issuerForUnAuthUser {
}
# Send logout response
# TODO sendLogoutResponseAfterLogoutRequest does not exists
# TODO sendLogoutResponseAfterLogoutRequest does not exists
return PE_ERROR
unless (
$self->sendLogoutResponseAfterLogoutRequest(
......
......@@ -100,12 +100,12 @@ sub setSessionInfo {
}
elsif ( ref( $self->{exportedVars} ) eq 'HASH' ) {
foreach ( keys %{ $self->{exportedVars} } ) {
$self->{sessionInfo}->{$_} =
$self->{ldap}
->getLdapValue( $self->{entry}, $self->{exportedVars}->{$_} )
|| "";
}
$self->{sessionInfo}->{$_} =
$self->{ldap}
->getLdapValue( $self->{entry}, $self->{exportedVars}->{$_} )
|| "";
}
}
else {
$self->abort('Only hash reference are supported now in exportedVars');
}
......
......@@ -2241,7 +2241,8 @@ sub sendLogoutRequestToServiceProviders {
# Header of the block which will be displayed to the user, if needed.
$info .=
&Lemonldap::NG::Portal::_i18n::msg( Lemonldap::NG::Portal::Simple::PM_SAML_SPLOGOUT,
&Lemonldap::NG::Portal::_i18n::msg
( Lemonldap::NG::Portal::Simple::PM_SAML_SPLOGOUT,
$ENV{HTTP_ACCEPT_LANGUAGE} )
. '<ul>';
......
......@@ -65,14 +65,11 @@ _RETURN $getCookiesResponse Response
#@param sessionid optional session identifier
#@return session => { error => code , cookies => { cookieName1 => value ,... } }
sub getCookies {
my $self = shift;
my $user = shift;
my $password = shift;
my $sessionid = shift;
my ( $self, $user, $password, $sessionid ) = splice @_;
$self->{user} = $user;
$self->{password} = $password;
$self->{id} = $sessionid if ( defined($sessionid) && $sessionid );
$self->{error} = PE_OK;
$self->{error} = PE_OK;
$self->lmLog( "SOAP authentication request for $self->{user}", 'debug' );
unless ( $self->{user} && $self->{password} ) {
$self->{error} = PE_FORMEMPTY;
......@@ -92,8 +89,8 @@ sub getCookies {
foreach ( @{ $self->{cookie} } ) {
push @cookies, SOAP::Data->name( $_->name, $_->value );
}
push @cookies, SOAP::Data->name(
$self->{cookieName} . 'update', time() );
push @cookies,
SOAP::Data->name( $self->{cookieName} . 'update', time() );
}
else {
my @cookieNames = split /\s+/, $self->{cookieName};
......
......@@ -34,6 +34,7 @@ sub diff {
sub abort {
shift;
local $, = ' ';
#print STDERR @_;
}
......@@ -55,139 +56,139 @@ $ENV{SCRIPT_FILENAME} = '/tmp/test.pl';
$ENV{REQUEST_METHOD} = 'GET';
$ENV{REQUEST_URI} = '/';
$ENV{QUERY_STRING} = '';
$ENV{REMOTE_ADDR} = '127.0.0.1';
$ENV{REMOTE_ADDR} = '127.0.0.1';
my($test,$testU);
my ( $test, $testU );
{
$INC{'Lemonldap/NG/Portal/Auth1.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
$INC{'Lemonldap/NG/Portal/Auth2.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
$INC{'Lemonldap/NG/Portal/UserDB1.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
$INC{'Lemonldap/NG/Portal/UserDB2.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
$INC{'Lemonldap/NG/Portal/UserDB3.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
$INC{'Lemonldap/NG/Portal/UserDB4.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
open LOG, '>/tmp/log';
print LOG Dumper(\%INC);use Data::Dumper;
$|=1;
close LOG;
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1;2',
userDB => 'Multi 1;2',
getUser => sub { PE_OK },
setSessionInfo => sub { PE_OK },
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
$test = 0;
ok( ( $p->process() == 1 and $p->{error} == PE_OK and $test == 1 ),
'Second module was called' );
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1;2',
userDB => 'Multi 1;2',
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
$test = 0;
$testU = 0;
ok( ( $p->process() == 1 and $p->{error} == PE_OK and $testU == 1 ),
'Second userDB module was called' );
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1;2',
userDB => 'Multi 3;4',
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
$test = 0;
$testU = 0;
ok( ( $p->process() == 1 and $p->{error} == PE_OK and $testU == 1 ),
'Second userDB module was not called' );
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1 1==0;2 1==0',
userDB => 'Multi 3;4',
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
ok( ( $p->process() == 0 and $p->{error} == PE_NOSCHEME ),
'No scheme available' );
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1;2 1==0',
userDB => 'Multi 3;4',
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
ok( ( $p->process() == 0 and $p->{error} == PE_ERROR ),
'Error from previous module' );
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1;2 1==1',
userDB => 'Multi 3;4',
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
ok( ( $p->process() == 1 ),
'1 failed, 2 succeed' );
$INC{'Lemonldap/NG/Portal/Auth1.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
$INC{'Lemonldap/NG/Portal/Auth2.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
$INC{'Lemonldap/NG/Portal/UserDB1.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
$INC{'Lemonldap/NG/Portal/UserDB2.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
$INC{'Lemonldap/NG/Portal/UserDB3.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
$INC{'Lemonldap/NG/Portal/UserDB4.pm'} = 't/25-Lemonldap-NG-Portal-Multi.t';
open LOG, '>/tmp/log';
print LOG Dumper( \%INC );
use Data::Dumper;
$| = 1;
close LOG;
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1;2',
userDB => 'Multi 1;2',
getUser => sub { PE_OK },
setSessionInfo => sub { PE_OK },
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
$test = 0;
ok( ( $p->process() == 1 and $p->{error} == PE_OK and $test == 1 ),
'Second module was called' );
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1;2',
userDB => 'Multi 1;2',
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
$test = 0;
$testU = 0;
ok( ( $p->process() == 1 and $p->{error} == PE_OK and $testU == 1 ),
'Second userDB module was called' );
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1;2',
userDB => 'Multi 3;4',
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
$test = 0;
$testU = 0;
ok( ( $p->process() == 1 and $p->{error} == PE_OK and $testU == 1 ),
'Second userDB module was not called' );
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1 1==0;2 1==0',
userDB => 'Multi 3;4',
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
ok( ( $p->process() == 0 and $p->{error} == PE_NOSCHEME ),
'No scheme available' );
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1;2 1==0',
userDB => 'Multi 3;4',
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
ok( ( $p->process() == 0 and $p->{error} == PE_ERROR ),
'Error from previous module' );
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Multi 1;2 1==1',
userDB => 'Multi 3;4',
portal => 'http://abc',
sessionInfo => { uid => 't', },
userNotice => sub { },
}
),
'Portal object'
);
ok( ( $p->process() == 1 ), '1 failed, 2 succeed' );
}
package Lemonldap::NG::Portal::Auth1;
......
......@@ -53,11 +53,11 @@ $ENV{QUERY_STRING} = '';
ok(
$p = My::Portal->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Proxy',
portal => 'http://abc',
soapAuthService => 'https://lm.com',
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'Proxy',
portal => 'http://abc',
soapAuthService => 'https://lm.com',
}
),
'Portal object'
......
......@@ -15,24 +15,23 @@ BEGIN { use_ok('Lemonldap::NG::Portal::Simple') }
# Fake ENV
$ENV{"REQUEST_METHOD"} = 'GET';
$ENV{"TEST_STRING"} = 'OK';
$ENV{"REMOTE_ADDR"} = '127.0.0.1';
$ENV{"TEST_STRING"} = 'OK';
$ENV{"REMOTE_ADDR"} = '127.0.0.1';
my $p;
ok(
$p = Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
userDB => 'Null',
exportedVars => { uid => "TEST_STRING", },
globalStorage => 'Apache::Session::File',
domain => 'example.com',
userDB => 'Null',
exportedVars => { uid => "TEST_STRING", },
}
)
);
ok ( $p->setSessionInfo() == PE_OK, 'Run setSessionInfo' );
ok ( $p->{sessionInfo}->{"uid"} eq "OK", 'Read info in session' );
ok( $p->setSessionInfo() == PE_OK, 'Run setSessionInfo' );
ok( $p->{sessionInfo}->{"uid"} eq "OK", 'Read info in session' );
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment