2017-02-19 08:17:48 +01:00
|
|
|
use Test::More;
|
|
|
|
use strict;
|
|
|
|
use IO::String;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
require 't/test-lib.pm';
|
|
|
|
}
|
|
|
|
|
|
|
|
my $res;
|
|
|
|
|
|
|
|
my $client = LLNG::Manager::Test->new(
|
2018-11-26 14:40:21 +01:00
|
|
|
{
|
|
|
|
ini => {
|
2018-10-13 22:26:09 +02:00
|
|
|
logLevel => 'error',
|
|
|
|
authentication => 'Demo',
|
|
|
|
userDB => 'Same',
|
|
|
|
loginHistoryEnabled => 1,
|
|
|
|
brutForceProtection => 0,
|
2018-10-21 22:12:56 +02:00
|
|
|
portalMainLogo => 'common/logos/logo_llng_old.png',
|
2018-10-12 22:50:01 +02:00
|
|
|
sessionDataToRemember =>
|
2018-11-26 14:40:21 +01:00
|
|
|
{ uid => 'identity', _auth => 'AuthModule' },
|
2017-02-19 08:17:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2018-09-22 11:21:37 +02:00
|
|
|
## First successful connection
|
2018-11-26 14:40:21 +01:00
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
2017-02-19 08:17:48 +01:00
|
|
|
'/',
|
|
|
|
IO::String->new('user=dwho&password=dwho&checkLogins=1'),
|
|
|
|
length => 37,
|
|
|
|
accept => 'text/html',
|
|
|
|
),
|
|
|
|
'Auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
|
|
|
expectOK($res);
|
|
|
|
my $id1 = expectCookie($res);
|
2018-10-21 22:12:56 +02:00
|
|
|
ok( $res->[2]->[0] =~ qr%<img src="/static/common/logos/logo_llng_old.png"%,
|
2018-10-13 22:26:09 +02:00
|
|
|
'Found custom Main Logo' )
|
2018-11-26 14:40:21 +01:00
|
|
|
or print STDERR Dumper( $res->[2]->[0] );
|
2018-10-13 22:26:09 +02:00
|
|
|
count(1);
|
2018-03-21 20:48:31 +01:00
|
|
|
ok( $res->[2]->[0] =~ /trspan="lastLogins"/, 'History found' )
|
2018-11-26 14:40:21 +01:00
|
|
|
or explain( $res->[2]->[0], 'trspan="noHistory"' );
|
2018-03-21 20:48:31 +01:00
|
|
|
my @c = ( $res->[2]->[0] =~ /<td>127.0.0.1/gs );
|
2018-09-22 11:21:37 +02:00
|
|
|
|
|
|
|
# History with 1 successLogin
|
|
|
|
ok( @c == 1, " -> One entry found" );
|
2018-03-21 20:48:31 +01:00
|
|
|
count(2);
|
2017-02-19 08:17:48 +01:00
|
|
|
|
|
|
|
ok( $res = $client->_get( '/', cookie => "lemonldap=$id1" ),
|
|
|
|
'Verify connection' );
|
|
|
|
count(1);
|
|
|
|
expectOK($res);
|
|
|
|
|
|
|
|
$client->logout($id1);
|
|
|
|
|
2018-09-22 11:21:37 +02:00
|
|
|
## Second successful connection
|
2018-11-26 14:40:21 +01:00
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
2017-02-19 08:17:48 +01:00
|
|
|
'/',
|
|
|
|
IO::String->new('user=dwho&password=dwho&checkLogins=1'),
|
|
|
|
length => 37,
|
|
|
|
accept => 'text/html',
|
|
|
|
),
|
|
|
|
'Auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
|
|
|
expectOK($res);
|
|
|
|
$id1 = expectCookie($res);
|
|
|
|
|
|
|
|
ok( $res->[2]->[0] =~ /trspan="lastLogins"/, 'History found' );
|
2018-03-21 20:48:31 +01:00
|
|
|
@c = ( $res->[2]->[0] =~ /<td>127.0.0.1/gs );
|
2018-09-22 11:21:37 +02:00
|
|
|
|
|
|
|
# History with 2 success
|
|
|
|
ok( @c == 2, ' -> Two entries found' );
|
2018-03-21 20:48:31 +01:00
|
|
|
count(2);
|
2017-02-19 08:17:48 +01:00
|
|
|
|
2018-09-22 22:25:30 +02:00
|
|
|
$client->logout($id1);
|
2018-09-22 11:21:37 +02:00
|
|
|
|
|
|
|
## First failed connection
|
2018-11-26 14:40:21 +01:00
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
2018-09-22 11:21:37 +02:00
|
|
|
'/',
|
|
|
|
IO::String->new('user=dwho&password=ohwd'),
|
|
|
|
length => 23
|
|
|
|
),
|
|
|
|
'Auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
|
|
|
expectReject($res);
|
|
|
|
|
|
|
|
## Second failed connection
|
2018-11-26 14:40:21 +01:00
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
2018-09-22 11:21:37 +02:00
|
|
|
'/',
|
|
|
|
IO::String->new('user=dwho&password=ohwd'),
|
|
|
|
length => 23
|
|
|
|
),
|
|
|
|
'Auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
|
|
|
expectReject($res);
|
|
|
|
|
|
|
|
## Third successful connection
|
2018-11-26 14:40:21 +01:00
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
2018-09-22 11:21:37 +02:00
|
|
|
'/',
|
|
|
|
IO::String->new('user=dwho&password=dwho&checkLogins=1'),
|
|
|
|
length => 37,
|
|
|
|
accept => 'text/html',
|
|
|
|
),
|
|
|
|
'Auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
|
|
|
expectOK($res);
|
|
|
|
$id1 = expectCookie($res);
|
|
|
|
|
|
|
|
ok( $res->[2]->[0] =~ /trspan="lastLogins"/, 'History found' );
|
|
|
|
@c = ( $res->[2]->[0] =~ /<td>127.0.0.1/gs );
|
2018-10-13 22:26:09 +02:00
|
|
|
my @cf = ( $res->[2]->[0] =~ /PE5<\/td>/gs );
|
2018-10-12 22:50:01 +02:00
|
|
|
my @ccv1 = ( $res->[2]->[0] =~ /<td>dwho<\/td>/gs );
|
|
|
|
my @ccv2 = ( $res->[2]->[0] =~ /<td>Demo<\/td>/gs );
|
2018-09-22 11:21:37 +02:00
|
|
|
|
2018-10-12 22:50:01 +02:00
|
|
|
# History with 5 entries and 10 custom values
|
2018-10-13 22:26:09 +02:00
|
|
|
ok( @c == 5, ' -> Five entries found' );
|
|
|
|
ok( @cf == 2, " -> Two 'failedLogin' entries found" );
|
2018-10-12 22:50:01 +02:00
|
|
|
ok( @ccv1 + @ccv2 == 10, " -> Ten custom value entries found" )
|
2018-11-26 14:40:21 +01:00
|
|
|
or print STDERR Dumper( $res->[2]->[0] );
|
2018-10-12 22:50:01 +02:00
|
|
|
count(4);
|
2018-09-22 11:21:37 +02:00
|
|
|
|
2018-09-22 22:25:30 +02:00
|
|
|
$client->logout($id1);
|
2017-02-19 08:17:48 +01:00
|
|
|
clean_sessions();
|
|
|
|
|
|
|
|
done_testing( count() );
|