Commit 9b1fffa5 authored by Yadd's avatar Yadd
Browse files

SAML test in progress (#595)

parent a1eab6cc
......@@ -6,7 +6,7 @@ BEGIN {
require 't/test-lib.pm';
}
my $maintests = 19;
my $maintests = 25;
my $debug = 'debug';
my $res;
my %handlerOR = ( issuer => [], sp => [] );
......@@ -159,8 +159,23 @@ SKIP: {
),
'Post artifact to SP'
);
ok( $res->[0] == 302, 'Get redirection' );
$cookies = $sp->getCookies($res);
my $spId;
ok( $spId = $cookies->{lemonldap}, 'Get cookie' )
or explain( $res, 'Set-Cookie: something' );
ok( $sp->getRedirection($res) eq 'http://auth.sp.com',
'Redirection points to SP portal' )
or explain( $res, 'Location: http://auth.sp.com' );
ok( $res = $sp->_get( '/', cookie => "lemonldap=$spId" ), 'Get / on SP' );
ok( $res->[0] == 200, 'User is authentified' ) or explain( $res->[0], 200 );
ok(
$sp->getUser($res) eq 'dwho@badwolf.org@idp',
'User is identified as dwho@badwolf.org@idp'
) or explain( $res->[1], 'Lm-Remote-User: dwho@badwolf.org@idp' );
#print STDERR Dumper( $res, $url, $s );
#print STDERR Dumper($res);
}
count($maintests);
......@@ -189,6 +204,14 @@ sub issuer {
samlSPMetaDataOptionsEncryptionMode => 'none',
}
},
samlSPMetaDataExportedAttributes => {
'sp.com' => {
cn =>
'1;cn;urn:oasis:names:tc:SAML:2.0:attrname-format:basic',
uid =>
'1;uid;urn:oasis:names:tc:SAML:2.0:attrname-format:basic',
}
},
samlOrganizationDisplayName => "IDP",
samlOrganizationName => "IDP",
samlOrganizationURL => "http://www.idp.com/",
......
......@@ -133,6 +133,32 @@ sub getCookies {
return $res;
}
sub getRedirection {
my ( $self, $resp ) = @_;
my @hdrs = @{ $resp->[1] };
my $res = {};
while ( my $name = shift @hdrs ) {
my $v = shift @hdrs;
if ( $name eq 'Location' ) {
return $v;
}
}
return undef
}
sub getUser {
my ( $self, $resp ) = @_;
my @hdrs = @{ $resp->[1] };
my $res = {};
while ( my $name = shift @hdrs ) {
my $v = shift @hdrs;
if ( $name eq 'Lm-Remote-User' ) {
return $v;
}
}
return undef
}
sub _get {
my ( $self, $path, %args ) = @_;
return $self->app->(
......
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