Login token is OK (#1140)
This commit is contained in:
parent
2e77ef4cc4
commit
f59ec29f48
|
@ -7,7 +7,14 @@ require 't/test-lib.pm';
|
|||
my $res;
|
||||
|
||||
my $client = LLNG::Manager::Test->new(
|
||||
{ ini => { logLevel => 'debug', useSafeJail => 1, requireToken => 1, } } );
|
||||
{
|
||||
ini => {
|
||||
logLevel => 'error',
|
||||
useSafeJail => 1,
|
||||
requireToken => 1,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
# Test normal first access
|
||||
# ------------------------
|
||||
|
@ -19,6 +26,44 @@ ok( $res = $client->_get( '/', accept => 'text/html' ), 'Unauth request' );
|
|||
count(1);
|
||||
|
||||
my ( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
|
||||
$query =~ s/.*\b(token=[^&]+).*/$1/;
|
||||
|
||||
# Try to auth without token
|
||||
ok(
|
||||
$res = $client->_post(
|
||||
'/',
|
||||
IO::String->new('user=dwho&password=dwho'),
|
||||
length => 23
|
||||
),
|
||||
'Try to auth without token'
|
||||
);
|
||||
count(1);
|
||||
expectReject($res);
|
||||
|
||||
# Try to auth with token
|
||||
$query .= '&user=dwho&password=dwho';
|
||||
ok(
|
||||
$res =
|
||||
$client->_post( '/', IO::String->new($query), length => length($query) ),
|
||||
'Try to auth with token'
|
||||
);
|
||||
count(1);
|
||||
expectOK($res);
|
||||
my $id = expectCookie($res);
|
||||
|
||||
# Verify auth
|
||||
ok( $res = $client->_get( '/', cookie => "lemonldap=$id" ), 'Verify auth' );
|
||||
count(1);
|
||||
expectOK($res);
|
||||
|
||||
# Try to reuse the same token
|
||||
ok(
|
||||
$res =
|
||||
$client->_post( '/', IO::String->new($query), length => length($query) ),
|
||||
'Try to reuse the same token'
|
||||
);
|
||||
count(1);
|
||||
expectReject($res);
|
||||
|
||||
clean_sessions();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user