From d6c4b49b2a8b6685e885dade5e28831872c9be9d Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Tue, 21 Mar 2017 07:09:31 +0000 Subject: [PATCH] OIDC-RP to SAML-IdP works !!! (fixes: #1113) --- .../t/37-OIDC-RP-to-SAML-IdP.t | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/lemonldap-ng-portal/t/37-OIDC-RP-to-SAML-IdP.t b/lemonldap-ng-portal/t/37-OIDC-RP-to-SAML-IdP.t index 30c00fef3..25bae731f 100644 --- a/lemonldap-ng-portal/t/37-OIDC-RP-to-SAML-IdP.t +++ b/lemonldap-ng-portal/t/37-OIDC-RP-to-SAML-IdP.t @@ -8,7 +8,7 @@ BEGIN { require 't/saml-lib.pm'; } -my $maintests = 11; +my $maintests = 14; my $debug = 'error'; my ( $idp, $sp, $rp, $res ); my %handlerOR = ( idp => [], sp => [], rp => [] ); @@ -110,7 +110,8 @@ SKIP: { ), 'Post authentication' ); - #( $url, $query ) = expectRedirection($res,qw#http://auth.idp.com(/+saml/singleSignOn)\?(issuerRequest=.*)$#); + +#( $url, $query ) = expectRedirection($res,qw#http://auth.idp.com(/+saml/singleSignOn)\?(issuerRequest=.*)$#); ( $host, $url, $query ) = expectAutoPost($res); $query =~ s/\+/%2B/g; my $idpId = expectCookie($res); @@ -126,8 +127,38 @@ SKIP: { ), 'POST SAML response' ); - ( $url, $query ) = expectRedirection( $res, qr#http://auth.sp.com/*(/oauth2/authorize)\?(.*)$# ); - diag('TODO: follow redirection'); + my $spId = expectCookie($res); + ( $url, $query ) = expectRedirection( $res, + qr#http://auth.sp.com/*(/oauth2/authorize)\?(.*)$# ); + + # Follow internal redirection + ok( + $res = $sp->_get( + $url, + query => $query, + accept => 'text/html', + cookie => + "lemonldap=$spId;lemonldapidp=http://auth.idp.com/saml/metadata" + ), + 'Follow internal redirection from SAML-SP to OIDC-OP' + ); + ( $host, $tmp, $query ) = expectForm( $res, '#', undef, 'confirm' ); + ok( + $res = $sp->_get( + $url, + query => $query, + accept => 'text/html', + cookie => + "lemonldap=$spId;lemonldapidp=http://auth.idp.com/saml/metadata" + ), + 'Confirm OIDC sharing' + ); + ($query) = expectRedirection($res,qr#http://auth.rp.com/*\?(.*)$#); + + # Follow redirection to RP + switch('rp'); + ok($res = $rp->_get('/',query=>$query,accept=>'text/html'),'Follow redirection to RP'); + my $rpId = expectCookie($res); #print STDERR Dumper($res); }