Fix unit test (#2564) & some warnings
This commit is contained in:
parent
350f2e505e
commit
21ba445141
|
@ -639,6 +639,7 @@ sub oauth2Init {
|
|||
|
||||
sub substitute {
|
||||
my ( $class, $expr ) = @_;
|
||||
$expr ||= '';
|
||||
|
||||
# substitute special vars, just for retro-compatibility
|
||||
$expr =~ s/\$date\b/&date/sg;
|
||||
|
|
|
@ -140,7 +140,7 @@ sub run {
|
|||
|
||||
# Try to recover cookie and user session
|
||||
$id = $class->fetchId($req);
|
||||
$class->data( {} ) unless($id);
|
||||
$class->data( {} ) unless ($id);
|
||||
if ( $id
|
||||
and $session = $class->retrieveSession( $req, $id ) )
|
||||
{
|
||||
|
@ -321,7 +321,7 @@ sub getLevel {
|
|||
$i++
|
||||
)
|
||||
{
|
||||
if ( $uri =~ $class->tsv->{locationRegexp}->{$vhost}->[$i] ) {
|
||||
if ( $uri && $uri =~ $class->tsv->{locationRegexp}->{$vhost}->[$i] ) {
|
||||
$level = $class->tsv->{locationAuthnLevel}->{$vhost}->[$i];
|
||||
last;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ ok( &$checkDate == "1",
|
|||
|
||||
my $sub4 =
|
||||
"sub { return(checkDate('20000101000000+0100','21000101000000+0100')) }";
|
||||
my $checkDate = $jail->jail_reval($sub4);
|
||||
$checkDate = $jail->jail_reval($sub4);
|
||||
ok( &$checkDate == "1",
|
||||
'checkDate extended function working without Safe Jail' );
|
||||
|
||||
|
|
|
@ -406,7 +406,9 @@ sub tests {
|
|||
},
|
||||
|
||||
samlSignatureOverrideNeedsCertificate => sub {
|
||||
return 1 if $conf->{samlServicePublicKeySig} =~ /CERTIFICATE/;
|
||||
return 1
|
||||
if $conf->{samlServicePublicKeySig}
|
||||
&& $conf->{samlServicePublicKeySig} =~ /CERTIFICATE/;
|
||||
|
||||
my @offenders;
|
||||
for my $idp ( keys %{ $conf->{samlIDPMetaDataOptions} } ) {
|
||||
|
@ -693,7 +695,7 @@ sub tests {
|
|||
abs $_;
|
||||
}
|
||||
grep { /\d+/ }
|
||||
split /\s*,\s*/, $conf->{bruteForceProtectionLockTimes};
|
||||
split /\s*,\s*/, $conf->{bruteForceProtectionLockTimes} || '';
|
||||
$conf->{bruteForceProtectionLockTimes} = join ', ', @lockTimes
|
||||
if scalar @lockTimes;
|
||||
return 1 unless ( $conf->{bruteForceProtection} );
|
||||
|
|
|
@ -576,14 +576,14 @@ sub updateSession {
|
|||
if ($id) {
|
||||
|
||||
# Update sessionInfo data
|
||||
## sessionInfo updated if $id defined : quite strange !!
|
||||
## sessionInfo updated if $id defined : quite strange!!
|
||||
## See https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues/430
|
||||
$self->logger->debug("Update session $id");
|
||||
foreach ( keys %$infos ) {
|
||||
$self->logger->debug("Update sessionInfo $_");
|
||||
$self->_dump( $infos->{$_} );
|
||||
$req->{sessionInfo}->{$_} = $infos->{$_};
|
||||
if ( $id eq $self->HANDLER->data->{_session_id} ) {
|
||||
if ( $self->HANDLER->data->{_session_id} && $id eq $self->HANDLER->data->{_session_id} ) {
|
||||
$self->HANDLER->data->{$_} = $infos->{$_};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ sub _register {
|
|||
|
||||
# Mail session expiration date
|
||||
my $expTimestamp =
|
||||
( $self->{conf}->{registerTimeout} || $self->conf->{timeout} ) + time;
|
||||
( $self->conf->{registerTimeout} || $self->conf->{timeout} ) + time;
|
||||
|
||||
$self->logger->debug("Register expiration timestamp: $expTimestamp");
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ SKIP: {
|
|||
),
|
||||
'Query IdP to access to SP'
|
||||
);
|
||||
my ( $host, $url, $query ) =
|
||||
( $host, $url, $query ) =
|
||||
expectAutoPost( $res, 'auth.sp.com', '/saml/proxySingleSignOnPost',
|
||||
'SAMLResponse' );
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ SKIP: {
|
|||
),
|
||||
'Test if still logged on PROXY' );
|
||||
|
||||
my ( $urlidp, $queryidp ) =
|
||||
( $urlidp, $queryidp ) =
|
||||
expectRedirection( $res,
|
||||
qr#http://auth.idp.com(/saml/singleSignOn)\?(.*)$# );
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ BEGIN {
|
|||
};
|
||||
}
|
||||
|
||||
my $maintests = 14;
|
||||
my $maintests = 16;
|
||||
my ( $res, $user, $pwd, $mail, $subject, $email, $ipAddr );
|
||||
|
||||
SKIP: {
|
||||
|
@ -26,13 +26,16 @@ SKIP: {
|
|||
authentication => 'Demo',
|
||||
userDB => 'Same',
|
||||
registerDB => 'Demo',
|
||||
registerTimeout => '600',
|
||||
registerConfirmSubject => 'Registration demonstration',
|
||||
registerConfirmBody =>
|
||||
'Hello $firstname $lastname, follows this link to register your account $url',
|
||||
'Hello $firstname $lastname, follows this link to register your account $url
|
||||
Expired time: $expMailDate $expMailTime',
|
||||
registerDoneSubject => 'Registration successful',
|
||||
registerDoneBody =>
|
||||
'Congratulations! Your account has been succesfully created with $mail from [$ipAddr]...
|
||||
Login=$login & Password=$password - Thanks to LemonLDAP::NG team.',
|
||||
Login=$login & Password=$password - Thanks to LemonLDAP::NG team.
|
||||
Go to Portal $url',
|
||||
captcha_register_enabled => 0,
|
||||
}
|
||||
}
|
||||
|
@ -67,12 +70,14 @@ Login=$login & Password=$password - Thanks to LemonLDAP::NG team.',
|
|||
) or explain( $subject, 'Custom registration subject' );
|
||||
ok(
|
||||
$mail =~
|
||||
m#Hello Fôo Bà Bar, follows this link to register your account http://auth.example.com/register\?(.+?)&skin=bootstrap#,
|
||||
'Found register token'
|
||||
) or explain( $mail, 'Custom body' );
|
||||
m#Hello Fôo Bà Bar, follows this link to register your account http://auth\.example\.com/register#s,
|
||||
'Found custom body'
|
||||
) or explain( $mail, 'Custom body (link)' );
|
||||
ok( $mail =~ /[?&](register_token=.+)[$&]/, 'Found register_token' );
|
||||
$query = $1;
|
||||
ok( $query =~ /register_token=/, 'Found register_token' );
|
||||
ok( $mail =~ /Fôo/, 'UTF-8 works' ) or explain( $mail, 'Fôo' );
|
||||
ok( $mail =~ m#Expired time: \d{2}/\d{2}/\d{4} \d{2}:\d{2}#s, 'Found time' )
|
||||
or explain( $mail, 'Custom body (expired time)' );
|
||||
|
||||
ok(
|
||||
$res =
|
||||
|
@ -96,12 +101,17 @@ m#Congratulations! Your account has been succesfully created with (.+?) from \[(
|
|||
or explain( $email, 'email' );
|
||||
ok( $ipAddr eq '127.0.0.1', 'Get good ipAddr' )
|
||||
or explain( $ipAddr, 'ipAddr' );
|
||||
ok( $mail =~ m#Login=(\w+?) & Password=(.+?)- Thanks to LemonLDAP::NG team\.#s,
|
||||
'Found user and password' )
|
||||
or explain( $mail, 'Custom done body' );
|
||||
ok(
|
||||
$mail =~
|
||||
m#Login=(\w+?) & Password=(.+?)- Thanks to LemonLDAP::NG team\.#s,
|
||||
'Found user and password'
|
||||
) or explain( $mail, 'Custom done body ($login & $password)' );
|
||||
$user = $1;
|
||||
$pwd = $2;
|
||||
ok( $user eq 'fbabar', 'Get good login' );
|
||||
ok( $mail =~ m#Go to Portal http://auth.example.com/\?skin=bootstrap#s,
|
||||
'Custom done body (Portal $url)' )
|
||||
or explain( $mail, 'Custom done body' );
|
||||
|
||||
ok(
|
||||
$res = $client->_post(
|
||||
|
|
Loading…
Reference in New Issue
Block a user