Improve unit tests (#2275)
This commit is contained in:
parent
4ba29f10a7
commit
192861d639
|
@ -143,9 +143,9 @@ m#<img class="renewcaptchaclick" src="/static/common/icons/arrow_refresh.png" al
|
|||
ok( $res = $client->_get( '/renewcaptcha', accept => 'text/html' ),
|
||||
'Unauth request to renew Captcha' );
|
||||
$json = eval { JSON::from_json( $res->[2]->[0] ) };
|
||||
ok( ( defined $json->{newtoken} and $json->{newtoken} =~ /^\d{10}_\d+$/ ),
|
||||
ok( ( defined $json->{newtoken} and $json->{newtoken} =~ /^\w+$/ ),
|
||||
'New token has been received' )
|
||||
or explain( $json->{newtoken}, 'NO token received' );
|
||||
or explain( $json->{newtoken}, 'New token not received' );
|
||||
ok( (
|
||||
defined $json->{newimage}
|
||||
and $json->{newimage} =~ m%^data:image/png;base64,.+%
|
||||
|
|
|
@ -13,15 +13,16 @@ my $res;
|
|||
|
||||
my $client = LLNG::Manager::Test->new( {
|
||||
ini => {
|
||||
logLevel => 'error',
|
||||
authentication => 'Demo',
|
||||
userDB => 'Same',
|
||||
loginHistoryEnabled => 0,
|
||||
bruteForceProtection => 0,
|
||||
requireToken => 0,
|
||||
securedCookie => 3,
|
||||
restSessionServer => 1,
|
||||
globalLogoutRule => 1,
|
||||
logLevel => 'error',
|
||||
authentication => 'Demo',
|
||||
userDB => 'Same',
|
||||
loginHistoryEnabled => 0,
|
||||
bruteForceProtection => 0,
|
||||
requireToken => 0,
|
||||
securedCookie => 3,
|
||||
restSessionServer => 1,
|
||||
globalLogoutRule => 1,
|
||||
tokenUseGlobalStorage => 1,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -117,9 +118,12 @@ ok(
|
|||
ok( $res->[2]->[0] =~ m%<span trmsg="47"></span>%, 'Found PE_LOGOUT_OK' )
|
||||
or explain( $res->[2]->[0], "PE_LOGOUT_OK" );
|
||||
my $nbr = count_sessions();
|
||||
ok( $nbr == 2, "Two sessions left" )
|
||||
or explain("Number of session(s) found = $nbr\n");
|
||||
count(3);
|
||||
ok( $nbr == 2, "Two SSO sessions found" )
|
||||
or explain( $nbr, "Two SSO sessions found" );
|
||||
$nbr = count_sessions('TOKEN');
|
||||
ok( $nbr == 1, "One TOKEN session found" )
|
||||
or explain( $nbr, "One TOKEN session found" );
|
||||
count(4);
|
||||
|
||||
clean_sessions();
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ ok( $res->[2]->[0] =~ m%<h3 trspan="otherSessions"></h3>%,
|
|||
or explain( $res->[2]->[0], 'otherSessions found' );
|
||||
ok(
|
||||
$res->[2]->[0] =~
|
||||
m%<a href="http://auth.example.com/removeOther\?token=\d{10}_\d+" onclick="_go=0" trspan="removeOtherSessions"></a>%,
|
||||
m%<a href="http://auth.example.com/removeOther\?token=\w+?" onclick="_go=0" trspan="removeOtherSessions"></a>%,
|
||||
'Link found'
|
||||
) or explain( $res->[2]->[0], 'Link found' );
|
||||
ok( $res->[2]->[0] =~ m%action="http://test1.example.com/"%, 'action found' )
|
||||
|
|
|
@ -18,6 +18,7 @@ SKIP: {
|
|||
totp2fSelfRegistration => 1,
|
||||
totp2fActivation => 1,
|
||||
sfRequired => 1,
|
||||
tokenUseGlobalStorage => 1,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -153,13 +153,22 @@ sub clean_sessions {
|
|||
}
|
||||
|
||||
sub count_sessions {
|
||||
my $dir = shift;
|
||||
$dir ||= $tmpDir;
|
||||
my ( $kind, $dir ) = @_;
|
||||
my $nbr = 0;
|
||||
$kind ||= 'SSO';
|
||||
$dir ||= $tmpDir;
|
||||
|
||||
opendir D, $dir or die $!;
|
||||
foreach ( grep { /^\w{64}$/ } readdir(D) ) {
|
||||
$nbr++;
|
||||
open( my $fh, '<', "$dir/$_" ) or die($!);
|
||||
while (<$fh>) {
|
||||
chomp;
|
||||
if ( $_ =~ /"_session_kind":"$kind"/ ) {
|
||||
$nbr++;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close $fh;
|
||||
}
|
||||
$nbr;
|
||||
}
|
||||
|
@ -582,14 +591,15 @@ our $defaultIni = {
|
|||
cache_root => $tmpDir,
|
||||
cache_depth => 0,
|
||||
},
|
||||
logLevel => 'error',
|
||||
cookieName => 'lemonldap',
|
||||
domain => 'example.com',
|
||||
templateDir => 'site/templates',
|
||||
staticPrefix => '/static',
|
||||
securedCookie => 0,
|
||||
https => 0,
|
||||
globalStorageOptions => {
|
||||
logLevel => 'error',
|
||||
cookieName => 'lemonldap',
|
||||
domain => 'example.com',
|
||||
templateDir => 'site/templates',
|
||||
staticPrefix => '/static',
|
||||
tokenUseGlobalStorage => 0,
|
||||
securedCookie => 0,
|
||||
https => 0,
|
||||
globalStorageOptions => {
|
||||
Directory => $tmpDir,
|
||||
LockDirectory => "$tmpDir/lock",
|
||||
generateModule =>
|
||||
|
@ -659,7 +669,7 @@ has ini => (
|
|||
main::ok( $self->{p} = $self->class->new(), 'Portal object' );
|
||||
main::count(1);
|
||||
unless ( $self->confFailure ) {
|
||||
main::ok( $self->{p}->init($ini), 'Init' );
|
||||
main::ok( $self->{p}->init($ini), 'Init' );
|
||||
main::ok( $self->{app} = $self->{p}->run(), 'Portal app' );
|
||||
main::count(2);
|
||||
no warnings 'redefine';
|
||||
|
|
Loading…
Reference in New Issue