Commit 4bb0b393 authored by Yadd's avatar Yadd
Browse files

Clean handler in SAML test before calling 2nd portal (#LEMONDAP-595)

parent b69bf110
......@@ -6,6 +6,7 @@ require 't/test-lib.pm';
my $tests = 0;
my $debug = 'debug';
my $res;
my %handlerOR = ( issuer => [], sp => [] );
SKIP: {
eval "use Lasso";
......@@ -13,13 +14,23 @@ SKIP: {
skip 'Lasso not found', $tests;
}
my $issuer = issuer();
$handlerOR{issuer} = \@Lemonldap::NG::Handler::Main::Reload::_onReload;
switch ('sp');
my $sp = sp();
$handlerOR{sp} = \@Lemonldap::NG::Handler::Main::Reload::_onReload;
}
count($tests);
done_testing( count() );
sub switch {
my $type = shift;
@Lemonldap::NG::Handler::Main::Reload::_onReload = @{
$handlerOR{$type};
};
}
sub issuer {
return LLNG::Manager::Test->new(
{
......@@ -29,7 +40,7 @@ sub issuer {
portal => 'auth.idp.com',
authentication => 'Demo',
userDB => 'Demo',
issuerDBSAMLActivation => "1",
issuerDBSAMLActivation => 1,
samlSPMetaDataOptions => {
'sp.com' => {
samlSPMetaDataOptionsEncryptionMode => 'none',
......@@ -277,6 +288,7 @@ sub sp {
domain => 'sp.com',
authentication => 'SAML',
userDB => 'SAML',
issuerDBSAMLActivation => 0,
samlIDPMetaDataExportedAttributes => {
idp => {
mail => "0;mail;;",
......@@ -518,7 +530,6 @@ XVhuG8OrWQDoS5gYHSjdw1CTJyixeJwyoqA9RGYguG5nh9zndi3LWAh7Z0lx+tIz
+wIDAQAB
-----END PUBLIC KEY-----
",
samlSPMetaDataXML => {},
samlSPSSODescriptorAuthnRequestsSigned => 1,
samlStorageOptions => {},
},
......
......@@ -54,26 +54,28 @@ our $defaultIni = {
};
has app => (
is => 'rw',
isa => 'CodeRef',
is => 'rw',
isa => 'CodeRef',
);
has ini => ( is => 'rw',
default => sub { $defaultIni; },
trigger => sub {
my($self,$ini) = @_;
foreach my $k (keys %$defaultIni) {
$ini->{$k} //= $defaultIni->{$k};
has ini => (
is => 'rw',
default => sub { $defaultIni; },
trigger => sub {
my ( $self, $ini ) = @_;
foreach my $k ( keys %$defaultIni ) {
$ini->{$k} //= $defaultIni->{$k};
}
$self->{ini} = $ini;
main::ok( $self->{app} = Lemonldap::NG::Portal::Main->run($ini),
'Portal app' );
main::count(1);
$self;
}
$self->{ini} = $ini;
main::ok($self->{app} = Lemonldap::NG::Portal::Main->run($ini),'Portal app');
main::count(1);
$self;
}
);
sub logout {
my ($self,$id) = @_;
my ( $self, $id ) = @_;
my $res;
main::ok(
$res = $self->_get(
......@@ -84,9 +86,11 @@ sub logout {
),
'Logout'
);
main::ok( $res->[0] == 200, 'Response is 200' ) or explain( $res->[0], 200 );
main::ok( $res->[0] == 200, 'Response is 200' )
or explain( $res->[0], 200 );
my $c;
main::ok( ( defined( $c = $self->getCookies($res)->{lemonldap} ) and not $c ),
main::ok(
( defined( $c = $self->getCookies($res)->{lemonldap} ) and not $c ),
'Cookie is deleted' )
or explain( $res->[1], "Set-Cookie => 'lemonldap='" );
main::ok( $res = $self->_get( '/', cookie => "lemonldap=$id" ),
......@@ -98,7 +102,7 @@ sub logout {
}
sub getCookies {
my ($self,$resp) = @_;
my ( $self, $resp ) = @_;
my @hdrs = @{ $resp->[1] };
my $res = {};
while ( my $name = shift @hdrs ) {
......@@ -159,8 +163,8 @@ sub _post {
'HTTP_USER_AGENT' =>
'Mozilla/5.0 (VAX-4000; rv:36.0) Gecko/20350101 Firefox',
'PATH_INFO' => $path,
( $args{query} ? ( QUERY_STRING => $args{query} ) : () ),
( $args{referer} ? ( REFERER => $args{referer} ) : () ),
( $args{query} ? ( QUERY_STRING => $args{query} ) : () ),
( $args{referer} ? ( REFERER => $args{referer} ) : () ),
'REMOTE_ADDR' => '127.0.0.1',
(
$args{remote_user}
......@@ -169,9 +173,9 @@ sub _post {
),
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => $path . ( $args{query} ? "?$args{query}" : '' ),
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'auth.example.com',
'SERVER_PORT' => '8002',
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'auth.example.com',
'SERVER_PORT' => '8002',
'SERVER_PROTOCOL' => 'HTTP/1.1',
( $args{custom} ? %{ $args{custom} } : () ),
'psgix.input.buffered' => 1,
......
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