Modify tests to check login history

This commit is contained in:
Christophe Maudoux 2018-09-09 23:18:49 +02:00
parent 81cf828639
commit 30697c8cd5
2 changed files with 35 additions and 8 deletions

View File

@ -7,7 +7,7 @@ use LWP::Protocol::PSGI;
use Plack::Request;
require 't/test-lib.pm';
my $maintests = 4;
my $maintests = 6;
LWP::Protocol::PSGI->register(
sub {
@ -40,6 +40,9 @@ my $client = LLNG::Manager::Test->new(
rest2fInitArgs => { name => 'uid' },
rest2fVerifyUrl => 'http://auth.example.com/vrfy',
rest2fVerifyArgs => { code => 'code' },
loginHistoryEnabled => 1,
authentication => 'Demo',
userDB => 'Same',
}
}
);
@ -50,14 +53,14 @@ my $res;
ok(
$res = $client->_post(
'/',
IO::String->new('user=dwho&password=dwho'),
length => 23,
IO::String->new('user=dwho&password=dwho&checkLogins=1'),
length => 37,
accept => 'text/html',
),
'Auth query'
);
my ( $host, $url, $query ) =
expectForm( $res, undef, '/rest2fcheck', 'token', 'code' );
expectForm( $res, undef, '/rest2fcheck', 'token', 'code', 'checkLogins' );
$query =~ s/code=/code=1234/;
ok(
@ -65,10 +68,18 @@ ok(
'/rest2fcheck',
IO::String->new($query),
length => length($query),
accept => 'text/html',
),
'Post code'
);
my $id = expectCookie($res);
ok( $res->[2]->[0] =~ /trspan="lastLogins"/, 'History found' )
or print STDERR Dumper( $res->[2]->[0] );
my @c = ( $res->[2]->[0] =~ /<td>127.0.0.1/gs );
ok( @c == 1, 'One entry found' );
$client->logout($id);
#print STDERR Dumper($res);

View File

@ -4,7 +4,9 @@ use IO::String;
use Data::Dumper;
require 't/test-lib.pm';
my $maintests = 3;
my $maintests = 6;
use_ok('Lemonldap::NG::Common::FormEncode');
my $client = LLNG::Manager::Test->new(
{
@ -13,9 +15,13 @@ my $client = LLNG::Manager::Test->new(
ext2fActivation => 1,
ext2FSendCommand => 't/sendOTP.pl -uid $uid',
ext2FValidateCommand => 't/vrfyOTP.pl -uid $uid -code $code',
loginHistoryEnabled => 1,
authentication => 'Demo',
userDB => 'Same',
}
}
);
my $res;
# Try to authenticate
@ -23,13 +29,15 @@ my $res;
ok(
$res = $client->_post(
'/',
IO::String->new('user=dwho&password=dwho'),
length => 23,
IO::String->new('user=dwho&password=dwho&checkLogins=1'),
length => 37,
accept => 'text/html',
),
'Auth query'
);
my ( $host, $url, $query ) = expectForm( $res, undef, '/ext2fcheck', 'token', 'code' );
my ( $host, $url, $query ) =
expectForm( $res, undef, '/ext2fcheck', 'token', 'code', 'checkLogins' );
ok(
$res->[2]->[0] =~
@ -43,10 +51,18 @@ ok(
'/ext2fcheck',
IO::String->new($query),
length => length($query),
accept => 'text/html',
),
'Post code'
);
my $id = expectCookie($res);
ok( $res->[2]->[0] =~ /trspan="lastLogins"/, 'History found' )
or print STDERR Dumper( $res->[2]->[0] );
my @c = ( $res->[2]->[0] =~ /<td>127.0.0.1/gs );
ok( @c == 1, 'One entry found' );
$client->logout($id);
count($maintests);