Commit 6dd9105d authored by Christophe Maudoux's avatar Christophe Maudoux

Improve unit tests (#1658)

parent 30c0f2ed
......@@ -66,7 +66,7 @@ count(1);
# Expired token
sleep 3;
$query =~ s/user=dwho/user=rtyler/;
$query =~ s/user=/user=rtyler/;
$query =~ s/url=/url=http%3A%2F%2Ftest1.example.com/;
ok(
......@@ -87,7 +87,7 @@ count(2);
# Valid token
$query =~ s/user=/user=rtyler/;
$query =~ s/url=/url=test1.example.com/;
$query =~ s/url=/url=http%3A%2F%2Ftest1.example.com/;
ok(
$res = $client->_post(
......
......@@ -18,7 +18,7 @@ my $client = LLNG::Manager::Test->new( {
portalMainLogo => 'common/logos/logo_llng_old.png',
checkUser => 1,
requireToken => 0,
checkUserIdRule => 1,
checkUserIdRule => '$uid ne "msmith"',
checkUserDisplayPersistentInfo => 1,
checkUserDisplayEmptyValues => 1,
}
......@@ -112,12 +112,7 @@ ok( $res->[2]->[0] =~ m%<span trspan="VHnotFound">%,
or explain( $res->[2]->[0], 'trspan="VHnotFound"' );
count(1);
( $host, $url, $query ) =
expectForm( $res, undef, '/checkuser', 'user', 'url' );
ok( $res->[2]->[0] =~ m%<span trspan="checkUser">%, 'Found trspan="checkUser"' )
or explain( $res->[2]->[0], 'trspan="checkUser"' );
count(1);
# Request with good VH & user
$query =~
s/url=http%3A%2F%2Ftry.example.com/url=http%3A%2F%2Ftest1.example.com/;
ok(
......@@ -169,9 +164,46 @@ ok( $res->[2]->[0] =~ m%<td class="text-left">uid</td>%, 'Found uid' )
or explain( $res->[2]->[0], 'Attribute Value uid' );
count(11);
$query =~ s/user=dwho/user=msmith/;
$query =~
s/url=http%3A%2F%2Ftest1.example.com/url=http%3A%2F%2Fmanager.example.com%2Fmanager.html/;
# Request a forbidden identity
$query =~ s/user=rtyler/user=msmith/;
ok(
$res = $client->_post(
'/checkuser',
IO::String->new($query),
cookie => "lemonldap=$id",
length => length($query),
accept => 'text/html',
),
'POST checkuser'
);
ok(
$res->[2]->[0] =~
m%<div class="message message-positive alert"><span trspan="PE5"></span></div>%,
'PE5 found'
) or explain( $res->[2]->[0], 'PE5' );
count(2);
# Request an unknown identity
$query =~ s/user=msmith/user=davros/;
ok(
$res = $client->_post(
'/checkuser',
IO::String->new($query),
cookie => "lemonldap=$id",
length => length($query),
accept => 'text/html',
),
'POST checkuser'
);
ok(
$res->[2]->[0] =~
m%<div class="message message-positive alert"><span trspan="PE5"></span></div>%,
'PE5 found'
) or explain( $res->[2]->[0], 'PE5' );
count(2);
# Request an unvalid identity
$query =~ s/user=dwho/user=$*/;
ok(
$res = $client->_post(
'/checkuser',
......@@ -184,9 +216,9 @@ ok(
);
ok(
$res->[2]->[0] =~
m%<div class="alert alert-danger"><b><span trspan="forbidden"></span></b></div>%,
'Found trspan="forbidden"'
) or explain( $res->[2]->[0], 'trspan="forbidden"' );
m%<div class="message message-positive alert"><span trspan="PE5"></span></div>%,
'PE5 found'
) or explain( $res->[2]->[0], 'PE5' );
count(2);
$client->logout($id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment