Improve unit tests (#1988)
This commit is contained in:
parent
6f31056a5b
commit
64d76148ef
|
@ -43,14 +43,14 @@ count(2);
|
|||
|
||||
# Required AuthnLevel = 1
|
||||
ok( $res = $client->_get( '/AuthWeak', undef, undef, "lemonldap=$sessionId" ),
|
||||
'Authentified query' );
|
||||
'Weak Authentified query' );
|
||||
ok( $res->[0] == 200, 'Code is 200' ) or explain( $res, 200 );
|
||||
count(2);
|
||||
|
||||
# Required AuthnLevel = 5
|
||||
ok(
|
||||
$res = $client->_get( '/AuthStrong', undef, undef, "lemonldap=$sessionId" ),
|
||||
'Authentified query'
|
||||
'Strong Authentified query'
|
||||
);
|
||||
ok( $res->[0] == 302, 'Code is 302' ) or explain( $res, 302 );
|
||||
%h = @{ $res->[1] };
|
||||
|
@ -87,7 +87,7 @@ ok(
|
|||
$res = $client->_get(
|
||||
'/AuthWeak', undef, 'test2.example.com', "lemonldap=$sessionId"
|
||||
),
|
||||
'Authentified query'
|
||||
'Weak Authentified query'
|
||||
);
|
||||
ok( $res->[0] == 200, 'Code is 200' ) or explain( $res, 200 );
|
||||
count(2);
|
||||
|
@ -96,7 +96,7 @@ count(2);
|
|||
ok(
|
||||
$res =
|
||||
$client->_get( '/', undef, 'test2.example.com', "lemonldap=$sessionId" ),
|
||||
'Authentified query'
|
||||
'Default Authentified query'
|
||||
);
|
||||
ok( $res->[0] == 302, 'Code is 302' ) or explain( $res, 302 );
|
||||
%h = @{ $res->[1] };
|
||||
|
|
|
@ -9,6 +9,7 @@ init('Lemonldap::NG::Handler::Server');
|
|||
my $res;
|
||||
|
||||
# Unauthentified query
|
||||
# --------------------
|
||||
ok( $res = $client->_get('/'), 'Unauthentified query' );
|
||||
ok( ref($res) eq 'ARRAY', 'Response is an array' ) or explain( $res, 'array' );
|
||||
ok( $res->[0] == 302, 'Code is 302' ) or explain( $res->[0], 302 );
|
||||
|
@ -23,17 +24,14 @@ ok(
|
|||
'Location => http://auth.example.com/?url='
|
||||
. encode_base64( 'http://test1.example.com/', '' )
|
||||
);
|
||||
|
||||
count(4);
|
||||
|
||||
# Authentified queries
|
||||
# --------------------
|
||||
|
||||
# Authorized query
|
||||
ok( $res = $client->_get( '/', undef, undef, "lemonldap=$sessionId" ),
|
||||
'Authentified query' );
|
||||
ok( $res->[0] == 200, 'Code is 200' ) or explain( $res->[0], 200 );
|
||||
|
||||
count(2);
|
||||
|
||||
# Check headers
|
||||
|
@ -46,9 +44,33 @@ count(1);
|
|||
ok( $res = $client->_get( '/deny', undef, undef, "lemonldap=$sessionId" ),
|
||||
'Denied query' );
|
||||
ok( $res->[0] == 403, 'Code is 403' ) or explain( $res->[0], 403 );
|
||||
|
||||
count(2);
|
||||
|
||||
# Required AuthnLevel = 1
|
||||
ok( $res = $client->_get( '/AuthWeak', undef, undef, "lemonldap=$sessionId" ),
|
||||
'Weak Authentified query' );
|
||||
ok( $res->[0] == 200, 'Code is 200' ) or explain( $res, 200 );
|
||||
count(2);
|
||||
|
||||
# Required AuthnLevel = 5
|
||||
ok(
|
||||
$res = $client->_get( '/AuthStrong', undef, undef, "lemonldap=$sessionId" ),
|
||||
'Strong Authentified query'
|
||||
);
|
||||
ok( $res->[0] == 302, 'Code is 302' ) or explain( $res, 302 );
|
||||
%h = @{ $res->[1] };
|
||||
ok(
|
||||
$h{Location} eq 'http://auth.example.com//upgradesession?url='
|
||||
. encode_base64( 'http://test1.example.com/AuthStrong', '' ),
|
||||
'Redirection points to http://test1.example.com/AuthStrong'
|
||||
)
|
||||
or explain(
|
||||
\%h,
|
||||
'http://auth.example.com//upgradesession?url='
|
||||
. encode_base64( 'http://test1.example.com/AuthStrong', '' )
|
||||
);
|
||||
count(3);
|
||||
|
||||
# Bad cookie
|
||||
ok(
|
||||
$res = $client->_get(
|
||||
|
@ -63,9 +85,38 @@ ok( $res->[0] == 302, 'Code is 302' ) or explain( $res->[0], 302 );
|
|||
unlink(
|
||||
't/sessions/lock/Apache-Session-e5eec18ebb9bc96352595e2d8ce962e8ecf7af7c9a98cb9a43f9cd181cf4b545.lock'
|
||||
);
|
||||
|
||||
count(2);
|
||||
|
||||
# Required AuthnLevel = 1
|
||||
ok(
|
||||
$res = $client->_get(
|
||||
'/AuthWeak', undef, 'test2.example.com', "lemonldap=$sessionId"
|
||||
),
|
||||
'Weak Authentified query'
|
||||
);
|
||||
ok( $res->[0] == 200, 'Code is 200' ) or explain( $res, 200 );
|
||||
count(2);
|
||||
|
||||
# Required AuthnLevel = 5
|
||||
ok(
|
||||
$res =
|
||||
$client->_get( '/', undef, 'test2.example.com', "lemonldap=$sessionId" ),
|
||||
'Default Authentified query'
|
||||
);
|
||||
ok( $res->[0] == 302, 'Code is 302' ) or explain( $res, 302 );
|
||||
%h = @{ $res->[1] };
|
||||
ok(
|
||||
$h{Location} eq 'http://auth.example.com//upgradesession?url='
|
||||
. encode_base64( 'http://test2.example.com/', '' ),
|
||||
'Redirection points to http://test2.example.com/'
|
||||
)
|
||||
or explain(
|
||||
\%h,
|
||||
'http://auth.example.com//upgradesession?url='
|
||||
. encode_base64( 'http://test2.example.com/', '' )
|
||||
);
|
||||
count(3);
|
||||
|
||||
done_testing( count() );
|
||||
|
||||
clean();
|
||||
|
|
|
@ -34,7 +34,6 @@ count(4);
|
|||
ok( $res = $client->_get( '/', undef, undef, "lemonldap=$sessionId" ),
|
||||
'Authentified query' );
|
||||
ok( $res->[0] == 200, 'Code is 200' ) or explain( $res->[0], 200 );
|
||||
|
||||
count(2);
|
||||
|
||||
# Check headers
|
||||
|
@ -49,9 +48,33 @@ count(2);
|
|||
ok( $res = $client->_get( '/deny', undef, undef, "lemonldap=$sessionId" ),
|
||||
'Denied query' );
|
||||
ok( $res->[0] == 403, 'Code is 403' ) or explain( $res->[0], 403 );
|
||||
|
||||
count(2);
|
||||
|
||||
# Required AuthnLevel = 1
|
||||
ok( $res = $client->_get( '/AuthWeak', undef, undef, "lemonldap=$sessionId" ),
|
||||
'Weak Authentified query' );
|
||||
ok( $res->[0] == 200, 'Code is 200' ) or explain( $res, 200 );
|
||||
count(2);
|
||||
|
||||
# Required AuthnLevel = 5
|
||||
ok(
|
||||
$res = $client->_get( '/AuthStrong', undef, undef, "lemonldap=$sessionId" ),
|
||||
'Strong Authentified query'
|
||||
);
|
||||
ok( $res->[0] == 401, 'Code is 401' ) or explain( $res, 401 );
|
||||
%h = @{ $res->[1] };
|
||||
ok(
|
||||
$h{Location} eq 'http://auth.example.com//upgradesession?url='
|
||||
. encode_base64( 'http://test1.example.com/AuthStrong', '' ),
|
||||
'Redirection points to http://test1.example.com/AuthStrong'
|
||||
)
|
||||
or explain(
|
||||
\%h,
|
||||
'http://auth.example.com//upgradesession?url='
|
||||
. encode_base64( 'http://test1.example.com/AuthStrong', '' )
|
||||
);
|
||||
count(3);
|
||||
|
||||
# Bad cookie
|
||||
ok(
|
||||
$res = $client->_get(
|
||||
|
@ -66,9 +89,38 @@ ok( $res->[0] == 401, 'Code is 401' ) or explain( $res->[0], 401 );
|
|||
unlink(
|
||||
't/sessions/lock/Apache-Session-e5eec18ebb9bc96352595e2d8ce962e8ecf7af7c9a98cb9a43f9cd181cf4b545.lock'
|
||||
);
|
||||
|
||||
count(2);
|
||||
|
||||
# Required AuthnLevel = 1
|
||||
ok(
|
||||
$res = $client->_get(
|
||||
'/AuthWeak', undef, 'test2.example.com', "lemonldap=$sessionId"
|
||||
),
|
||||
'Weak Authentified query'
|
||||
);
|
||||
ok( $res->[0] == 200, 'Code is 200' ) or explain( $res, 200 );
|
||||
count(2);
|
||||
|
||||
# Required AuthnLevel = 5
|
||||
ok(
|
||||
$res =
|
||||
$client->_get( '/', undef, 'test2.example.com', "lemonldap=$sessionId" ),
|
||||
'Default Authentified query'
|
||||
);
|
||||
ok( $res->[0] == 401, 'Code is 401' ) or explain( $res, 401 );
|
||||
%h = @{ $res->[1] };
|
||||
ok(
|
||||
$h{Location} eq 'http://auth.example.com//upgradesession?url='
|
||||
. encode_base64( 'http://test2.example.com/', '' ),
|
||||
'Redirection points to http://test2.example.com/'
|
||||
)
|
||||
or explain(
|
||||
\%h,
|
||||
'http://auth.example.com//upgradesession?url='
|
||||
. encode_base64( 'http://test2.example.com/', '' )
|
||||
);
|
||||
count(3);
|
||||
|
||||
done_testing( count() );
|
||||
|
||||
clean();
|
||||
|
|
Loading…
Reference in New Issue
Block a user