Append unit test (#2180)
This commit is contained in:
parent
bd28760bd7
commit
c8eaf8978d
|
@ -628,6 +628,7 @@ t/61-GrantSession.t
|
|||
t/61-Session-ActivityTimeout.t
|
||||
t/61-Session-Timeout.t
|
||||
t/62-Refresh-plugin.t
|
||||
t/62-SingleSession-with-History.t
|
||||
t/62-SingleSession-with-Rules.t
|
||||
t/62-SingleSession.t
|
||||
t/62-UpgradeSession.t
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
use Test::More;
|
||||
use strict;
|
||||
use IO::String;
|
||||
|
||||
BEGIN {
|
||||
require 't/test-lib.pm';
|
||||
}
|
||||
|
||||
my $level = 'error';
|
||||
my $res;
|
||||
my $client = LLNG::Manager::Test->new( {
|
||||
ini => {
|
||||
logLevel => $level,
|
||||
authentication => 'Demo',
|
||||
userDB => 'Same',
|
||||
loginHistoryEnabled => 1,
|
||||
singleSession => 1,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
sub loginUser {
|
||||
my ( $client, $user, $ip, $history ) = @_;
|
||||
my $query = (
|
||||
$history
|
||||
? "user=$user&password=$user&checkLogins=1"
|
||||
: "user=$user&password=$user"
|
||||
);
|
||||
ok(
|
||||
my $res = $client->_post(
|
||||
'/',
|
||||
IO::String->new($query),
|
||||
length => length($query),
|
||||
accept => 'text/html',
|
||||
ip => $ip,
|
||||
),
|
||||
'Auth query'
|
||||
);
|
||||
count(1);
|
||||
return $res;
|
||||
}
|
||||
|
||||
####################
|
||||
# Test singleSession
|
||||
|
||||
# Test logins
|
||||
$res = loginUser( $client, "dwho", "127.0.0.1" );
|
||||
my $id = expectCookie($res);
|
||||
$res = loginUser( $client, "dwho", "127.0.0.1" );
|
||||
expectCookie($res);
|
||||
$res = loginUser( $client, "dwho", "127.0.0.1", 1 );
|
||||
expectCookie($res);
|
||||
ok( $res->[2]->[0] =~ m%<h3 trspan="sessionsDeleted"></h3>%,
|
||||
'sessionsDeleted found' )
|
||||
or explain( $res->[2]->[0], 'sessionsDeleted found' );
|
||||
count(1);
|
||||
|
||||
# Test history
|
||||
ok( $res->[2]->[0] =~ m%<h3 trspan="lastLogins"></h3%, 'History found' );
|
||||
my @c = ( $res->[2]->[0] =~ m%<td class="localeDate" val="\d{10}"></td>%gs );
|
||||
ok( @c == 4, ' -> Four entries found' )
|
||||
or explain( $res->[2]->[0], 'History entries found' );
|
||||
count(2);
|
||||
|
||||
clean_sessions();
|
||||
|
||||
done_testing( count() );
|
Loading…
Reference in New Issue