Fix some test problems with pdata (#1461)

This commit is contained in:
Xavier Guimard 2018-07-05 17:39:44 +02:00
parent 890ea8aa27
commit d0bd437191
4 changed files with 17 additions and 20 deletions

View File

@ -308,7 +308,7 @@ sub reloadConf {
# Clean $req->pdata after authentication
push @{ $self->afterDatas }, sub {
unless ( $_[0]->datas->{keepPdata} or $_[0]->mustRedirect ) {
unless ( $_[0]->datas->{keepPdata} ) {
$self->logger->debug('Cleaning pdata');
$_[0]->pdata( {} );
}

View File

@ -74,14 +74,8 @@ sub controlUrl {
}
}
$req->{datas}->{_url} ||= '';
my $url = $req->param('url');
my $issuerUrl = $req->param('issuerUrldc');
if ( $url or $issuerUrl ) {
if ($issuerUrl) {
$req->urlNotBase64(1);
$url = $issuerUrl;
}
my $url = $req->param('url');
if ($url) {
# REJECT NON BASE64 URL
if ( $req->urlNotBase64 ) {

View File

@ -67,7 +67,6 @@ LWP::Protocol::PSGI->register(
);
SKIP: {
skip 'Broken for now', $maintests;
eval "use Lasso";
if ($@) {
skip 'Lasso not found', $maintests;
@ -112,6 +111,7 @@ SKIP: {
ok( $res = $op->_get( $url, query => $query, accept => 'text/html' ),
"Push request to OP, endpoint $url" );
expectOK($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
# Try to authenticate to IdP
$query = "user=french&password=french&$query";
@ -121,6 +121,7 @@ SKIP: {
IO::String->new($query),
accept => 'text/html',
length => length($query),
cookie => $pdata,
),
"Post authentication, endpoint $url"
);

View File

@ -67,7 +67,6 @@ LWP::Protocol::PSGI->register(
);
SKIP: {
skip 'Broken for now', $maintests;
eval "use Lasso";
if ($@) {
skip 'Lasso not found', $maintests;
@ -120,15 +119,16 @@ SKIP: {
),
"Push request to OP, endpoint $url"
);
my $host;
( $host, $url, $query ) = expectForm( $res, '#', undef, 'confirm' );
my $spPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
my ( $host, $tmp );
( $host, $tmp, $query ) = expectForm( $res, '#', undef, 'confirm' );
ok(
$res = $sp->_post(
'/',
$url,
IO::String->new($query),
length => length($query),
accept => 'text/html',
cookie => 'lemonldapidp=http://auth.idp.com/saml/metadata'
cookie => "lemonldapidp=http://auth.idp.com/saml/metadata;$spPdata"
),
'Confirm IdP'
);
@ -145,6 +145,7 @@ SKIP: {
),
'Launch SAML request to IdP'
);
my $idpPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
my $tmp;
# Try to authenticate to IdP
@ -163,11 +164,12 @@ SKIP: {
IO::String->new($query),
accept => 'text/html',
length => length($query),
cookie => $idpPdata,
),
'Post authentication'
);
( $host, $url, $query ) = expectAutoPost($res);
( $host, $url, $query ) = expectAutoPost( $res, 'auth.sp.com' );
$query =~ s/\+/%2B/g;
my $idpId = expectCookie($res);
@ -178,13 +180,13 @@ SKIP: {
$url, IO::String->new($query),
length => length($query),
accept => 'text/html',
cookie => 'lemonldapidp=http://auth.idp.com/saml/metadata',
cookie => "lemonldapidp=http://auth.idp.com/saml/metadata;$spPdata"
),
'POST SAML response'
);
my $spId = expectCookie($res);
( $url, $query ) = expectRedirection( $res,
qr#http://auth.sp.com/*(/oauth2/authorize)\?(.*)$# );
qr#http://auth.sp.com/*(/oauth2[^\?]*)(?:\?(.*))?$# );
# Follow internal redirection
ok(
@ -193,7 +195,7 @@ SKIP: {
query => $query,
accept => 'text/html',
cookie =>
"lemonldap=$spId;lemonldapidp=http://auth.idp.com/saml/metadata"
"lemonldap=$spId;lemonldapidp=http://auth.idp.com/saml/metadata;$spPdata"
),
'Follow internal redirection from SAML-SP to OIDC-OP'
);
@ -204,7 +206,7 @@ SKIP: {
query => $query,
accept => 'text/html',
cookie =>
"lemonldap=$spId;lemonldapidp=http://auth.idp.com/saml/metadata"
"lemonldap=$spId;lemonldapidp=http://auth.idp.com/saml/metadata;$spPdata"
),
'Confirm OIDC sharing'
);