Improve unit test (#2381)
This commit is contained in:
parent
b40ae547f4
commit
ce54774ee7
|
@ -4,7 +4,10 @@ use MIME::Base64;
|
|||
use Data::Dumper;
|
||||
use URI::Escape;
|
||||
|
||||
require 't/test-psgi-lib.pm';
|
||||
BEGIN {
|
||||
require 't/test-psgi-lib.pm';
|
||||
require 't/custom.pm';
|
||||
}
|
||||
|
||||
init('Lemonldap::NG::Handler::Server::Nginx');
|
||||
|
||||
|
@ -31,6 +34,26 @@ count(4);
|
|||
# Authentified queries
|
||||
# --------------------
|
||||
|
||||
# Authorized query
|
||||
ok(
|
||||
$res =
|
||||
$client->_get( '/', undef, 'test4.example.com', "lemonldap=$sessionId" ),
|
||||
'Authentified query'
|
||||
);
|
||||
ok( $res->[0] == 200, 'Code is 200' ) or explain( $res->[0], 200 );
|
||||
count(2);
|
||||
|
||||
# Check headers
|
||||
%h = @{ $res->[1] };
|
||||
ok(
|
||||
$h{'Lm-Remote-Custom'} eq
|
||||
'dwho@badwolf.org alias Doctor Who:users; timelords',
|
||||
'Lm-Remote-User is overwriten'
|
||||
)
|
||||
or explain( \%h,
|
||||
'Lm-Remote-User => "dwho@badwolf.org alias Doctor Who:users; timelords"' );
|
||||
count(1);
|
||||
|
||||
# Authorized query
|
||||
ok( $res = $client->_get( '/', undef, undef, "lemonldap=$sessionId" ),
|
||||
'Authentified query' );
|
||||
|
@ -43,7 +66,11 @@ ok( $h{'Headername1'} eq 'Auth-User', 'Headername1 is set to "Auth-User"' )
|
|||
or explain( \%h, 'Headername1 => "Auth-User"' );
|
||||
ok( $h{'Headervalue1'} eq 'dwho', 'Headervalue1 is set to "dwho"' )
|
||||
or explain( \%h, 'Headervalue1 => "dwho"' );
|
||||
count(2);
|
||||
ok(
|
||||
$h{'Lm-Remote-Custom'} eq 'dwho@badwolf.org',
|
||||
'Lm-Remote-User is set "dwho@badwolf.org"'
|
||||
) or explain( \%h, 'Lm-Remote-User => "dwho@badwolf.org"' );
|
||||
count(3);
|
||||
|
||||
# Request an URI protected by custom function -> allowed
|
||||
ok(
|
||||
|
|
|
@ -4,6 +4,7 @@ use MIME::Base64;
|
|||
|
||||
BEGIN {
|
||||
require 't/test-psgi-lib.pm';
|
||||
require 't/custom.pm';
|
||||
}
|
||||
|
||||
init('Lemonldap::NG::Handler::PSGI');
|
||||
|
@ -39,7 +40,6 @@ ok(
|
|||
'Authentified query'
|
||||
);
|
||||
ok( $res->[0] == 200, 'Code is 200' ) or explain( $res, 200 );
|
||||
|
||||
count(2);
|
||||
|
||||
# Denied query
|
||||
|
@ -50,7 +50,6 @@ ok(
|
|||
'Denied query'
|
||||
);
|
||||
ok( $res->[0] == 403, 'Code is 403' ) or explain( $res->[0], 403 );
|
||||
|
||||
count(2);
|
||||
|
||||
# Bad cookie
|
||||
|
@ -67,11 +66,9 @@ ok( $res->[0] == 302, 'Code is 302' ) or explain( $res->[0], 302 );
|
|||
unlink(
|
||||
't/sessions/lock/Apache-Session-e5eec18ebb9bc96352595e2d8ce962e8ecf7af7c9a98cb9a43f9cd181cf4b545.lock'
|
||||
);
|
||||
|
||||
count(2);
|
||||
|
||||
done_testing( count() );
|
||||
|
||||
clean();
|
||||
|
||||
sub Lemonldap::NG::Handler::PSGI::handler {
|
||||
|
|
9
lemonldap-ng-handler/t/custom.pm
Normal file
9
lemonldap-ng-handler/t/custom.pm
Normal file
|
@ -0,0 +1,9 @@
|
|||
package My;
|
||||
|
||||
sub accessToTrace {
|
||||
my $hash = shift;
|
||||
return
|
||||
"$hash->{custom} alias $hash->{params}->[0] $hash->{params}->[1]:$hash->{session}->{groups}";
|
||||
}
|
||||
|
||||
1;
|
|
@ -58,6 +58,9 @@
|
|||
"^/logout": "logout_sso",
|
||||
"default": "accept"
|
||||
},
|
||||
"test4.example.com": {
|
||||
"default": "accept"
|
||||
},
|
||||
"*.example.org": {
|
||||
"^/orgdeny": "deny",
|
||||
"default": "accept"
|
||||
|
@ -80,8 +83,12 @@
|
|||
"userDB": "Demo",
|
||||
"vhostOptions": {
|
||||
"test2.example.com": {
|
||||
"vhostAuthnLevel": 5
|
||||
}
|
||||
"vhostAuthnLevel": 5
|
||||
},
|
||||
"test4.example.com": {
|
||||
"vhostAccessToTrace": "My::accessToTrace, Doctor, Who"
|
||||
}
|
||||
},
|
||||
"whatToTrace": "_whatToTrace"
|
||||
"whatToTrace": "_whatToTrace",
|
||||
"customToTrace": "mail"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user