diff --git a/lemonldap-ng-portal/t/00-Switch.t b/lemonldap-ng-portal/t/00-Switch.t new file mode 100644 index 0000000000000000000000000000000000000000..7a4cb15a1e5de335b8e38e503abdaf7dc9636145 --- /dev/null +++ b/lemonldap-ng-portal/t/00-Switch.t @@ -0,0 +1,51 @@ +use warnings; +use Test::More; +use strict; +use IO::String; +use MIME::Base64; +use URI; +use URI::QueryParam; + +require 't/test-lib.pm'; + +my $res; + +my $client = register( + 'client1', + sub { + LLNG::Manager::Test->new( { + ini => { + portal => 'https://auth.example.com/', + } + } + ); + } +); + +my $client2 = register( + 'client2', + sub { + LLNG::Manager::Test->new( { + ini => { + portal => 'https://auth.example2.com/', + } + } + ); + } +); + +switch ("client1"); +is( Lemonldap::NG::Handler::Main->tsv->{portal}->(), + 'https://auth.example.com/' ); +switch ("client2"); +is( Lemonldap::NG::Handler::Main->tsv->{portal}->(), + 'https://auth.example2.com/' ); +switch ("client1"); +is( Lemonldap::NG::Handler::Main->tsv->{portal}->(), + 'https://auth.example.com/' ); +switch ("client2"); +is( Lemonldap::NG::Handler::Main->tsv->{portal}->(), + 'https://auth.example2.com/' ); +count(4); + +done_testing( count() ); diff --git a/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-Logout-20.t b/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-Logout-20.t index 459e5fe3c3ae048c439f259efd99ab300ca709f4..62a23c254ec04420bc4aef8a755124913209b62c 100644 --- a/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-Logout-20.t +++ b/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-Logout-20.t @@ -61,6 +61,7 @@ $issuer = register( 'issuer', \&issuer ); $sp = register( 'sp', \&sp ); # Simple SP access +switch ('sp'); ok( $res = $sp->_get( '/', accept => 'text/html', @@ -188,9 +189,9 @@ sub issuer { casAttributes => { cn => 'cn', uid => 'uid', }, casAccessControlPolicy => 'none', multiValuesSeparator => ';', - "locationRules" => { - "test1.idp.com" => { - "default" => "accept" + casAppMetaDataOptions => { + myapp => { + casAppMetaDataOptionsService => "http://test1.idp.com", }, }, } diff --git a/lemonldap-ng-portal/t/35-REST-config-backend.t b/lemonldap-ng-portal/t/35-REST-config-backend.t index 0478fb95230fe26cb19203264727167f5abf5d88..c46f11dc76b2598b838c7c6d7724fe2aac404975 100644 --- a/lemonldap-ng-portal/t/35-REST-config-backend.t +++ b/lemonldap-ng-portal/t/35-REST-config-backend.t @@ -20,11 +20,13 @@ LWP::Protocol::PSGI->register( $req->uri =~ m#http://auth.idp.com(.*?)(?:\?(.*))?$#, ' @ REST request (' . $req->method . " $1)" ); + switch ('issuer'); count(1); my $url = $1; my $query = $2; my $res; my $s = $req->content; + if ( $req->method =~ /^(post|put)$/i ) { my $mth = '_' . lc($1); my $s = $req->content; @@ -58,6 +60,7 @@ LWP::Protocol::PSGI->register( } pass(' @ END OF REST REQUEST'); count(1); + switch ('sp'); return $res; } ); diff --git a/lemonldap-ng-portal/t/35-SOAP-config-backend.t b/lemonldap-ng-portal/t/35-SOAP-config-backend.t index 06d1fc748972d6d8afe98accb1271981363bea2b..9008aa568240be24545589d7a349064ee5541aa3 100644 --- a/lemonldap-ng-portal/t/35-SOAP-config-backend.t +++ b/lemonldap-ng-portal/t/35-SOAP-config-backend.t @@ -24,6 +24,7 @@ LWP::Protocol::PSGI->register( my $res; my $s = $req->content; my $client = ( $host eq 'idp' ? $issuer : $sp ); + switch ( ( $host eq 'idp' ? 'issuer' : 'sp' ) ); ok( $res = $client->_post( $url, @@ -42,6 +43,7 @@ LWP::Protocol::PSGI->register( or explain( $res->[1], 'Content-Type => application/xml' ); pass(' @ END OF SOAP REQUEST @'); count(4); + switch ( ( $host eq 'idp' ? 'sp' : 'issuer' ) ); return $res; } ); diff --git a/lemonldap-ng-portal/t/test-lib.pm b/lemonldap-ng-portal/t/test-lib.pm index 58ba5e7618d971b6f936ed70b8f192de60f6bc8a..897e4fbcdb11f6091038996aea945aada9129fbf 100644 --- a/lemonldap-ng-portal/t/test-lib.pm +++ b/lemonldap-ng-portal/t/test-lib.pm @@ -702,6 +702,7 @@ sub tempdb { } my %handlerOR; +my %handlerTSHV; =head4 register @@ -714,10 +715,24 @@ sub register { my ( $type, $constructor ) = @_; my $obj; @Lemonldap::NG::Handler::Main::_onReload = (); + $Lemonldap::NG::Handler::Main::_tshv = { + tsv => {}, + cfgNum => 0, + cfgDate => 0, + lastCheck => 0, + checkTime => 600, + confAcc => {}, + logger => {}, + userLogger => {}, + lmConf => {}, + localConfig => {}, + }; + &Lemonldap::NG::Handler::Main::cfgNum( 0, 0 ); ok( $obj = $constructor->(), 'Register $type' ); count(1); - $handlerOR{$type} = \@Lemonldap::NG::Handler::Main::_onReload; + $handlerOR{$type} = \@Lemonldap::NG::Handler::Main::_onReload; + $handlerTSHV{$type} = $Lemonldap::NG::Handler::Main::_tshv; return $obj; } @@ -734,6 +749,8 @@ sub switch { @Lemonldap::NG::Handler::Main::_onReload = @{ $handlerOR{$type}; }; + + $Lemonldap::NG::Handler::Main::_tshv = $handlerTSHV{$type}; } =head4 encodeUrl( $url );