Improve unit test (#1857)

This commit is contained in:
Christophe Maudoux 2019-07-17 11:58:49 +02:00
parent b56331c649
commit 24a1fdcdb9
2 changed files with 95 additions and 2 deletions

View File

@ -34,7 +34,53 @@ my $client = LLNG::Manager::Test->new( {
}
);
# Try yo authenticate
# Try to authenticate
# -------------------
ok(
$res = $client->_post(
'/',
IO::String->new(
'user=dwho&password=dwho&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw=='),
accept => 'text/html',
length => 64,
),
'Auth query'
);
count(1);
expectOK($res);
my $id = expectCookie($res);
expectForm( $res, undef, '/notifback', 'reference1x1', 'url' );
# Verify that cookie is ciphered (session unvalid)
ok(
$res = $client->_get(
'/',
query => 'url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==',
cookie => "lemonldap=$id",
),
'Test cookie received'
);
count(1);
expectReject($res);
# Try to cancel notification
ok(
$res = $client->_get(
'/notifback',
query => "cancel=1",
cookie => "lemonldap=$id",
length => 64,
accept => 'text/html',
),
"Cancel notification"
);
my $c = getCookies($res);
ok( not( %$c{'lemonldap'} ), 'No cookie' ) or print STDERR Dumper($c);
count(2);
expectRedirection( $res, 'http://auth.example.com/' );
# Try to authenticate
# -------------------
ok(
$res = $client->_post(

View File

@ -38,7 +38,54 @@ SKIP: {
}
);
# Try yo authenticate
# Try to authenticate
# -------------------
ok(
$res = $client->_post(
'/',
IO::String->new(
'user=dwho&password=dwho&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw=='
),
accept => 'text/html',
length => 64,
),
'Auth query'
);
count(1);
expectOK($res);
my $id = expectCookie($res);
expectForm( $res, undef, '/notifback', 'reference1x1', 'url' );
# Verify that cookie is ciphered (session unvalid)
ok(
$res = $client->_get(
'/',
query => 'url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==',
cookie => "lemonldap=$id",
),
'Test cookie received'
);
count(1);
expectReject($res);
# Try to cancel notification
ok(
$res = $client->_get(
'/notifback',
query => "cancel=1",
cookie => "lemonldap=$id",
length => 64,
accept => 'text/html',
),
"Cancel notification"
);
my $c = getCookies($res);
ok( not( %$c{'lemonldap'} ), 'No cookie' ) or print STDERR Dumper($c);
count(2);
expectRedirection( $res, 'http://auth.example.com/' );
# Try to authenticate
# -------------------
ok(
$res = $client->_post(