Unit test for adaptative authentication level plugin (#2336)
This commit is contained in:
parent
b573dbb789
commit
b21a5fc653
|
@ -630,6 +630,7 @@ t/59-Double-cookies-for-Double-sessions.t
|
|||
t/59-Double-cookies-Refresh-and-Logout.t
|
||||
t/59-Secured-cookie-Refresh-and-Logout.t
|
||||
t/60-Status.t
|
||||
t/61-AdaptativeAuthenticationLevel.t
|
||||
t/61-BruteForceProtection-with-Incremental-lockTimes-and-TOTP.t
|
||||
t/61-BruteForceProtection-with-Incremental-lockTimes.t
|
||||
t/61-BruteForceProtection.t
|
||||
|
|
81
lemonldap-ng-portal/t/61-AdaptativeAuthenticationLevel.t
Normal file
81
lemonldap-ng-portal/t/61-AdaptativeAuthenticationLevel.t
Normal file
|
@ -0,0 +1,81 @@
|
|||
use Test::More;
|
||||
use strict;
|
||||
use IO::String;
|
||||
use Data::Dumper;
|
||||
|
||||
BEGIN {
|
||||
require 't/test-lib.pm';
|
||||
}
|
||||
|
||||
my $res;
|
||||
my $id;
|
||||
my $json;
|
||||
|
||||
my $client = LLNG::Manager::Test->new(
|
||||
{
|
||||
ini => {
|
||||
logLevel => 'error',
|
||||
authentication => 'Demo',
|
||||
userDB => 'Same',
|
||||
adaptativeAuthenticationLevelRules => {
|
||||
'$uid eq "dwho"' => '+2',
|
||||
'$uid eq "msmith"' => '=5',
|
||||
},
|
||||
restSessionServer => 1,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
ok(
|
||||
$res = $client->_post(
|
||||
'/',
|
||||
IO::String->new('user=dwho&password=dwho'),
|
||||
accept => 'text/html',
|
||||
length => 23
|
||||
),
|
||||
'Auth query'
|
||||
);
|
||||
count(1);
|
||||
$id = expectCookie($res);
|
||||
|
||||
ok(
|
||||
$res = $client->_get(
|
||||
'/session/my/global/authenticationLevel',
|
||||
cookie => "lemonldap=$id"
|
||||
),
|
||||
'Get session'
|
||||
);
|
||||
count(1);
|
||||
$json = expectJSON($res);
|
||||
|
||||
ok( $json == 3, 'Authentication level upgraded' );
|
||||
count(1);
|
||||
|
||||
ok(
|
||||
$res = $client->_post(
|
||||
'/',
|
||||
IO::String->new('user=msmith&password=msmith'),
|
||||
accept => 'text/html',
|
||||
length => 27
|
||||
),
|
||||
'Auth query'
|
||||
);
|
||||
count(1);
|
||||
$id = expectCookie($res);
|
||||
|
||||
ok(
|
||||
$res = $client->_get(
|
||||
'/session/my/global/authenticationLevel',
|
||||
cookie => "lemonldap=$id"
|
||||
),
|
||||
'Get session'
|
||||
);
|
||||
count(1);
|
||||
$json = expectJSON($res);
|
||||
|
||||
ok( $json == 5, 'Authentication level upgraded' );
|
||||
count(1);
|
||||
|
||||
clean_sessions();
|
||||
|
||||
done_testing( count() );
|
Loading…
Reference in New Issue
Block a user