This commit is contained in:
Xavier Guimard 2020-02-20 23:34:02 +01:00
parent 6e4a874650
commit 4459a47f76
163 changed files with 866 additions and 789 deletions

View File

@ -107,6 +107,7 @@ sub store {
$req->content( to_json($conf) );
$req->header( 'Content-Type' => 'application/json' );
my $resp = $self->ua->request($req);
if ( $resp->is_success ) {
my $res;
eval { $res = from_json( $resp->content, { allow_nonref => 1 } ) };

View File

@ -39,7 +39,9 @@ has notifField => (
sub BUILD {
my $self = shift;
$self->extension('xml') if $self->p->conf->{oldNotifFormat};
$self->logger->debug('Use extension "' . $self->extension . '" to store notification files');
$self->logger->debug( 'Use extension "'
. $self->extension
. '" to store notification files' );
}
sub getNotifications {
@ -62,7 +64,8 @@ sub getNotifications {
sub getAcceptedNotifs {
my ( $self, $uid, $ref ) = @_;
my $forAll = $self->getAccepted( $self->conf->{notificationWildcard}, $ref );
my $forAll =
$self->getAccepted( $self->conf->{notificationWildcard}, $ref );
my $forUser = $self->getAccepted( $uid, $ref );
if ( $forUser and $forAll ) {
return { %$forUser, %$forAll };

View File

@ -42,7 +42,8 @@ sub newNotification {
unless ( exists $notif->{condition} ) {
$self->userLogger->info(
"Set defaultCondition ($defaultCond) for notification $notif->{reference}");
"Set defaultCondition ($defaultCond) for notification $notif->{reference}"
);
$notif->{condition} = $defaultCond;
}

View File

@ -59,8 +59,8 @@ sub newNotification {
}
else {
$self->userLogger->info(
"Set defaultCondition ($defaultCond) for notification " . $notif->{reference}
);
"Set defaultCondition ($defaultCond) for notification "
. $notif->{reference} );
push @data, $defaultCond;
}
}

View File

@ -49,7 +49,8 @@ sub userData {
return $self->{userData}
|| {
( $Lemonldap::NG::Handler::Main::tsv->{whatToTrace}
|| '_whatToTrace' ) => $self->{user}, };
|| '_whatToTrace' ) => $self->{user},
};
}
sub respHeaders {

View File

@ -75,11 +75,13 @@ sub fetchId {
# Get access token session
my $infos = $class->getOIDCInfos($access_token);
# If this token is tied to a regular session ID
if ( my $_session_id = $infos->{user_session_id} ) {
$class->logger->debug( 'Get user session id ' . $_session_id );
return $_session_id;
}
# If this token is tied to an Offline session
if ( my $_session_id = $infos->{offline_session_id} ) {
$class->logger->debug( 'Get offline session id ' . $_session_id );

View File

@ -45,7 +45,8 @@ sub fetchId {
}
# Is token in good interval ?
my $ttl = $class->localConfig->{vhostOptions}->{$vhost}->{vhostServiceTokenTTL}
my $ttl =
$class->localConfig->{vhostOptions}->{$vhost}->{vhostServiceTokenTTL}
|| $class->tsv->{serviceTokenTTL}->{$vhost};
$ttl = $class->tsv->{handlerServiceTokenTTL} unless ( $ttl and $ttl > 0 );
my $now = time;

View File

@ -69,7 +69,8 @@ sub run {
my ( $user, $uri, $code ) = ( $1, $2, $3 );
# Portal error translation
$code = portalConsts->{$code} || $code if ( $code =~ /^\-?\d+$/ );
$code = portalConsts->{$code} || $code
if ( $code =~ /^\-?\d+$/ );
# Per user activity
$status->{user}->{$user}->{$code}++;

View File

@ -439,7 +439,8 @@ sub fetchId {
my ( $class, $req ) = @_;
my $t = $req->{env}->{HTTP_COOKIE} or return 0;
my $vhost = $class->resolveAlias($req);
$class->logger->debug("VH $vhost is HTTPS") if $class->_isHttps( $req, $vhost );
$class->logger->debug("VH $vhost is HTTPS")
if $class->_isHttps( $req, $vhost );
my $lookForHttpCookie = ( $class->tsv->{securedCookie} =~ /^(2|3)$/
and not $class->_isHttps( $req, $vhost ) );
my $cn = $class->tsv->{cookieName};

View File

@ -41,33 +41,55 @@ ok( $h{'Auth-User'} eq 'dwho', 'Header Auth-User is set to "dwho"' )
count(1);
# Request an URI protected by custom function -> allowed
ok( $res = $client->_get( '/test-restricted_uri/dwho/', undef, undef, "lemonldap=$sessionId" ),
'Authentified query' );
ok( $res->[0] == 200, '/test-restricted_uri -> Code is 200' ) or explain( $res, 200 );
ok(
$res = $client->_get(
'/test-restricted_uri/dwho/', undef, undef, "lemonldap=$sessionId"
),
'Authentified query'
);
ok( $res->[0] == 200, '/test-restricted_uri -> Code is 200' )
or explain( $res, 200 );
count(2);
# Request an URI protected by custom function -> denied
ok( $res = $client->_get( '/test-restricted_uri/dwho', undef, undef, "lemonldap=$sessionId" ),
'Denied query' );
ok( $res->[0] == 403, '/test-restricted_uri -> Code is 403' ) or explain( $res->[0], 403 );
ok(
$res = $client->_get(
'/test-restricted_uri/dwho', undef, undef, "lemonldap=$sessionId"
),
'Denied query'
);
ok( $res->[0] == 403, '/test-restricted_uri -> Code is 403' )
or explain( $res->[0], 403 );
count(2);
# Request an URI protected by custom function -> allowed
ok( $res = $client->_get( '/test-uri2/dwho/dummy', undef, undef, "lemonldap=$sessionId" ),
'Authentified query' );
ok(
$res = $client->_get(
'/test-uri2/dwho/dummy', undef, undef, "lemonldap=$sessionId"
),
'Authentified query'
);
ok( $res->[0] == 200, '/test-uri2 -> Code is 200' ) or explain( $res, 200 );
count(2);
# Request an URI protected by custom function -> denied
ok( $res = $client->_get( '/test-uri1/dwho/', undef, undef, "lemonldap=$sessionId" ),
'Denied query' );
ok( $res->[0] == 403, '/test-uri1 -> Code is 403' ) or explain( $res->[0], 403 );
ok(
$res =
$client->_get( '/test-uri1/dwho/', undef, undef, "lemonldap=$sessionId" ),
'Denied query'
);
ok( $res->[0] == 403, '/test-uri1 -> Code is 403' )
or explain( $res->[0], 403 );
count(2);
# Request an URI protected by custom function -> denied
ok( $res = $client->_get( '/test-uri1/dwh', undef, undef, "lemonldap=$sessionId" ),
'Denied query' );
ok( $res->[0] == 403, '/test-uri1 -> Code is 403' ) or explain( $res->[0], 403 );
ok(
$res =
$client->_get( '/test-uri1/dwh', undef, undef, "lemonldap=$sessionId" ),
'Denied query'
);
ok( $res->[0] == 403, '/test-uri1 -> Code is 403' )
or explain( $res->[0], 403 );
count(2);
# Denied query

View File

@ -45,27 +45,42 @@ ok( $h{'Headervalue1'} eq 'dwho', 'Headervalue1 is set to "dwho"' )
count(2);
# Request an URI protected by custom function -> allowed
ok( $res = $client->_get( '/test-uri1/dwho', undef, undef, "lemonldap=$sessionId" ),
'Authentified query' );
ok(
$res =
$client->_get( '/test-uri1/dwho', undef, undef, "lemonldap=$sessionId" ),
'Authentified query'
);
ok( $res->[0] == 200, '/test-uri1 -> Code is 200' ) or explain( $res, 200 );
count(2);
# Request an URI protected by custom function -> allowed
ok( $res = $client->_get( '/test-uri2/dwho/dummy', undef, undef, "lemonldap=$sessionId" ),
'Authentified query' );
ok(
$res = $client->_get(
'/test-uri2/dwho/dummy', undef, undef, "lemonldap=$sessionId"
),
'Authentified query'
);
ok( $res->[0] == 200, '/test-uri2 -> Code is 200' ) or explain( $res, 200 );
count(2);
# Request an URI protected by custom function -> denied
ok( $res = $client->_get( '/test-uri1/dwho/', undef, undef, "lemonldap=$sessionId" ),
'Denied query' );
ok( $res->[0] == 403, '/test-uri1 -> Code is 403' ) or explain( $res->[0], 403 );
ok(
$res =
$client->_get( '/test-uri1/dwho/', undef, undef, "lemonldap=$sessionId" ),
'Denied query'
);
ok( $res->[0] == 403, '/test-uri1 -> Code is 403' )
or explain( $res->[0], 403 );
count(2);
# Request an URI protected by custom function -> denied
ok( $res = $client->_get( '/test-uri1/dwh', undef, undef, "lemonldap=$sessionId" ),
'Denied query' );
ok( $res->[0] == 403, '/test-uri1 -> Code is 403' ) or explain( $res->[0], 403 );
ok(
$res =
$client->_get( '/test-uri1/dwh', undef, undef, "lemonldap=$sessionId" ),
'Denied query'
);
ok( $res->[0] == 403, '/test-uri1 -> Code is 403' )
or explain( $res->[0], 403 );
count(2);
# Denied query

View File

@ -38,8 +38,9 @@ my $crypt = Lemonldap::NG::Common::Crypto->new('qwertyui');
my $token = $crypt->encrypt(
join ':', time,
$sessionId, 'test1.example.com',
'XFromVH=app1-auth.example.com', "serviceHeader1=$sessionId","serviceHeader2=$sessionId",
'test2.example.com', '*.example.com'
'XFromVH=app1-auth.example.com', "serviceHeader1=$sessionId",
"serviceHeader2=$sessionId", 'test2.example.com',
'*.example.com'
);
ok(

View File

@ -163,13 +163,17 @@ sub init {
sub tplParams {
my ( $self, $req ) = @_;
my $res = eval { $self->hLoadedPlugins->{viewer}->brwRule->( $req, $req->{userData} ) } || 0;
my $res = eval {
$self->hLoadedPlugins->{viewer}->brwRule->( $req, $req->{userData} );
} || 0;
return ( VERSION => $VERSION, ALLOWBROWSER => $res );
}
sub javascript {
my ( $self, $req ) = @_;
my $res = eval { $self->hLoadedPlugins->{viewer}->diffRule->( $req, $req->{userData} )} || 0;
my $res = eval {
$self->hLoadedPlugins->{viewer}->diffRule->( $req, $req->{userData} );
} || 0;
print STDERR $@ if $@;
my $impPrefix = $self->{impersonationPrefix} || 'real_';
my $ttl = $self->{timeout} || 72000;

View File

@ -456,15 +456,16 @@ our \$VERSION = '$Lemonldap::NG::Manager::Build::Attributes::VERSION';
use constant HANDLER => 'Lemonldap::NG::Handler::PSGI::Main';
use constant {
EOF
for my $pe ( sort { $portalConstants{$a} <=> $portalConstants{$b} }
keys %portalConstants )
for my $pe (
sort { $portalConstants{$a} <=> $portalConstants{$b} }
keys %portalConstants
)
{
my $str = $portalConstants{$pe};
$content .= " $pe => $str,\n";
}
my $exports = join ", ",
map { "'$_'" }
my $exports = join ", ", map { "'$_'" }
sort { $portalConstants{$a} <=> $portalConstants{$b} }
keys %portalConstants;

View File

@ -309,8 +309,9 @@ sub newRawConf {
# chances to be equal to last config cfgNum
my $s = $self->confAcc->saveConf( $new, force => 1 );
if ( $s > 0 ) {
$self->userLogger->notice(
'User ' . $self->p->userId($req) . " has stored (raw) conf $s" );
$self->userLogger->notice( 'User '
. $self->p->userId($req)
. " has stored (raw) conf $s" );
$res->{result} = 1;
$res->{cfgNum} = $s;
}

View File

@ -109,7 +109,8 @@ sub viewDiff {
# Check Diff activation rule
unless ( $self->diffRule->( $req, $req->{userData} ) ) {
my $user = $req->{userData}->{_whatToTrace} || 'anonymous';
$self->userLogger->warn("$user is not authorized to compare configurations");
$self->userLogger->warn(
"$user is not authorized to compare configurations");
return $self->sendJSONresponse( $req, { 'value' => '_Hidden_' } );
}
@ -173,7 +174,8 @@ sub viewKey {
$self->logger->debug(
" $req->{env}->{REQUEST_URI} -> URI FORBIDDEN");
my $user = $req->{userData}->{_whatToTrace} || 'anonymous';
$self->userLogger->warn("$user is not authorized to browse configurations");
$self->userLogger->warn(
"$user is not authorized to browse configurations");
$self->rejectKey( $req, @args );
}
}

View File

@ -41,7 +41,8 @@ sub newSession {
_session_kind => $kind,
_2fDevices => to_json($sfaDevices),
}
), "New $kind session for $uid"
),
"New $kind session for $uid"
);
count(1);
}

View File

@ -25,7 +25,8 @@ ok( $resBody = from_json( $res->[2]->[0] ), "Result body contains JSON text" );
ok( $resBody->{result} == 1, "JSON response contains \"result:1\"" )
or print STDERR Dumper($resBody);
ok(
$resBody->{details}->{__warnings__} and @{ $resBody->{details}->{__warnings__} } == 2,
$resBody->{details}->{__warnings__}
and @{ $resBody->{details}->{__warnings__} } == 2,
'JSON response contains 2 warnings'
) or print STDERR Dumper($resBody);
@ -38,18 +39,18 @@ foreach my $i ( 0 .. 1 ) {
}
ok(
$resBody->{details}->{__changes__} and @{ $resBody->{details}->{__changes__} } == 24,
$resBody->{details}->{__changes__}
and @{ $resBody->{details}->{__changes__} } == 24,
'JSON response contains 24 changes'
) or print STDERR Dumper($resBody);
ok(
$resBody->{details}->{__changes__}->[23]->{confCompacted} == 1,
'Conf. has been compacted'
) or print STDERR Dumper($resBody);
ok( $resBody->{details}->{__changes__}->[23]->{confCompacted} == 1,
'Conf. has been compacted' )
or print STDERR Dumper($resBody);
my @removedKeys = split /; /, $resBody->{details}->{__changes__}->[23]->{removedKeys};
ok(
@removedKeys == 60, 'All removed keys found'
) or print STDERR Dumper(\@removedKeys);
my @removedKeys = split /; /,
$resBody->{details}->{__changes__}->[23]->{removedKeys};
ok( @removedKeys == 60, 'All removed keys found' )
or print STDERR Dumper( \@removedKeys );
#print STDERR Dumper($resBody);
ok( -f $confFiles->[1], 'File is created' );
@ -105,8 +106,7 @@ ok( @c2 == 15, '15 keys changed or created in conf 2' )
count(5);
ok( $res = &client->jsonResponse('/confs/latest'),
'Get last config metadata' );
ok( $res = &client->jsonResponse('/confs/latest'), 'Get last config metadata' );
ok( $res->{prev} == 1, ' Get previous configuration' );
count(2);
@ -119,8 +119,7 @@ done_testing( count() );
`rm -rf t/sessions`;
sub changes {
return [
{
return [ {
'key' => 'portal',
'new' => 'http://auth2.example.com/',
'old' => 'http://auth.example.com/'

View File

@ -57,7 +57,6 @@ SKIP: {
@cmd = qw(-yes 1 set locationRules/test1.example.com/default deny);
Capture::Tiny::capture_stdout( sub { $client->run(@cmd) } );
# Test 'save' command
@cmd = ('save');
$res = Capture::Tiny::capture_stdout( sub { $client->run(@cmd) } );
@ -95,16 +94,10 @@ SKIP: {
qr#\bAuthor IP\b#s,
'"Author IP" OK'
);
Test::Output::combined_like(
$res = sub { $commonClient->run(@cmd) },
qr#\bLog\b#s,
'"Log" OK'
);
Test::Output::combined_like(
$res = sub { $commonClient->run(@cmd) },
qr#\bVersion\b#s,
'"Version" OK'
);
Test::Output::combined_like( $res = sub { $commonClient->run(@cmd) },
qr#\bLog\b#s, '"Log" OK' );
Test::Output::combined_like( $res = sub { $commonClient->run(@cmd) },
qr#\bVersion\b#s, '"Version" OK' );
}
count($tests);

View File

@ -44,7 +44,8 @@ SKIP: {
$client->jsonPostResponse( 'notifications/actives', '',
IO::String->new($notif),
'application/json', length($notif) );
ok( $res->{error} =~ /^Notification not created: Bad date/, 'Notification not inserted' );
ok( $res->{error} =~ /^Notification not created: Bad date/,
'Notification not inserted' );
$notif =
'{"date":"2099-13-30","uid":"dwho","reference":"Test","xml":"{\"title\":\"Test\"}"}';
@ -52,7 +53,8 @@ SKIP: {
$client->jsonPostResponse( 'notifications/actives', '',
IO::String->new($notif),
'application/json', length($notif) );
ok( $res->{error} =~ /^Notification not created: Bad date/, 'Notification not inserted' );
ok( $res->{error} =~ /^Notification not created: Bad date/,
'Notification not inserted' );
$notif =
'{"date":"2099-05_12","uid":"dwho","reference":"Test","xml":"{\"title\":\"Test\"}"}';

View File

@ -16,7 +16,8 @@ my $res =
&client->jsonPostResponse( 'notifications/actives', '',
IO::String->new($notif),
'application/json', length($notif) );
ok( $res->{error} =~ /^Notification not created: Bad date/, 'Notification not inserted' );
ok( $res->{error} =~ /^Notification not created: Bad date/,
'Notification not inserted' );
count(1);
$notif =
@ -25,7 +26,8 @@ $res =
&client->jsonPostResponse( 'notifications/actives', '',
IO::String->new($notif),
'application/json', length($notif) );
ok( $res->{error} =~ /^Notification not created: Bad date/, 'Notification not inserted' );
ok( $res->{error} =~ /^Notification not created: Bad date/,
'Notification not inserted' );
count(1);
$notif =

View File

@ -32,7 +32,8 @@ count(2);
# Try to display latest conf
$res = &client->jsonResponse('/view/latest');
ok( $res->{cfgNum} eq '1', 'Latest conf loaded' ) or explain($res,"cfgNum => 1");
ok( $res->{cfgNum} eq '1', 'Latest conf loaded' )
or explain( $res, "cfgNum => 1" );
count(1);
ok(

View File

@ -1472,7 +1472,8 @@ sub getIDP {
if ( $idpName eq $idpConfKey ) {
$idp = $_;
$self->logger->debug(
"IDP $idp selected from idpName URL Parameter ($idpName)");
"IDP $idp selected from idpName URL Parameter ($idpName)"
);
last;
}
}

View File

@ -13,7 +13,8 @@ sub new {
my $res = $self->{p}->loadModule( $self->{conf}->{customResetCertByMail} );
unless ($res) {
die 'Unable to load register module ' . $self->{conf}->{customResetCertByMail};
die 'Unable to load register module '
. $self->{conf}->{customResetCertByMail};
}
return $res;

View File

@ -38,7 +38,8 @@ sub checkHeader {
my $slave_header = 'HTTP_' . uc( $self->{conf}->{slaveHeaderName} );
$slave_header =~ s/\-/_/g;
my $headerContent = $req->env->{$slave_header};
$self->logger->debug("Required Slave header => $self->{conf}->{slaveHeaderName}");
$self->logger->debug(
"Required Slave header => $self->{conf}->{slaveHeaderName}");
$self->logger->debug("Received Slave header content => $headerContent");
return 1
if ( $headerContent

View File

@ -122,7 +122,8 @@ sub display {
# 1.3 There is a message to display
elsif ( my $info = $req->info ) {
my $method = $req->data->{infoFormMethod} || $self->conf->{infoFormMethod};
my $method =
$req->data->{infoFormMethod} || $self->conf->{infoFormMethod};
$self->logger->debug('Display: info detected');
$self->logger->debug('Hidden values :');
$self->logger->debug( " $_: " . $req->{portalHiddenFormValues}->{$_} )
@ -311,7 +312,8 @@ sub display {
ASK_LOGINS => $req->param('checkLogins') || 0,
DISPLAY_RESETPASSWORD => $self->conf->{portalDisplayResetPassword},
DISPLAY_REGISTER => $self->conf->{portalDisplayRegister},
DISPLAY_UPDATECERTIF => $self->conf->{portalDisplayCertificateResetByMail},
DISPLAY_UPDATECERTIF =>
$self->conf->{portalDisplayCertificateResetByMail},
MAILCERTIF_URL => $self->conf->{certificateResetByMailURL},
MAIL_URL => $self->conf->{mailUrl},
REGISTER_URL => $self->conf->{registerUrl},

View File

@ -102,14 +102,22 @@ sub error_type {
if (
scalar(
grep { /^$code$/ } (
PE_INFO, PE_SESSIONEXPIRED,
PE_FORMEMPTY, PE_FIRSTACCESS,
PE_PP_GRACE, PE_PP_EXP_WARNING,
PE_NOTIFICATION, PE_BADURL,
PE_CONFIRM, PE_MAILFORMEMPTY,
PE_MAILCONFIRMATION_ALREADY_SENT, PE_PASSWORDFORMEMPTY,
PE_CAPTCHAEMPTY, PE_REGISTERFORMEMPTY,
PE_PP_CHANGE_AFTER_RESET, PE_RESETCERTIFICATE_FORMEMPTY,
PE_INFO,
PE_SESSIONEXPIRED,
PE_FORMEMPTY,
PE_FIRSTACCESS,
PE_PP_GRACE,
PE_PP_EXP_WARNING,
PE_NOTIFICATION,
PE_BADURL,
PE_CONFIRM,
PE_MAILFORMEMPTY,
PE_MAILCONFIRMATION_ALREADY_SENT,
PE_PASSWORDFORMEMPTY,
PE_CAPTCHAEMPTY,
PE_REGISTERFORMEMPTY,
PE_PP_CHANGE_AFTER_RESET,
PE_RESETCERTIFICATE_FORMEMPTY,
)
)
);

View File

@ -33,8 +33,7 @@ sub groupsAndMacros {
sub authProcess { qw(extractFormInfo getUser authenticate) }
sub sessionData {
return
qw(setAuthSessionInfo setSessionInfo), $_[0]->groupsAndMacros,
return qw(setAuthSessionInfo setSessionInfo), $_[0]->groupsAndMacros,
qw(setPersistentSessionInfo setLocalGroups store secondFactor);
}

View File

@ -119,7 +119,8 @@ sub storeBrowser {
}
}
else {
$self->userLogger->error("StayConnected called with an expired token");
$self->userLogger->error(
"StayConnected called with an expired token");
}
}
else {

View File

@ -7,8 +7,7 @@ require 't/test-lib.pm';
my $res;
my $client = LLNG::Manager::Test->new(
{
my $client = LLNG::Manager::Test->new( {
ini => {
logLevel => 'error',
useSafeJail => 1,

View File

@ -116,8 +116,7 @@ m%<form id="lformKerberos" action="#" method="post" class="login Kerberos">%,
my $header = getHeader( $res, 'Content-Security-Policy' );
ok( $header =~ m%;form-action \* https://test.example.com;%,
' CSP URL found' )
or
explain( $res->[1], 'form-action * https://test.example.com;' );
or explain( $res->[1], 'form-action * https://test.example.com;' );
ok( $res->[2]->[0] !~ /4_demo/, '4_Demo not displayed' );
ok(
$res->[2]->[0] =~ qr%<img src="/static/common/logos/logo_llng_old.png"%,

View File

@ -233,8 +233,7 @@ qr%<input name="code" value="" type="text" class="form-control" id="extcode" trp
$res = $sp->_get(
'/',
accept => 'text/html',
cookie =>
"lemonldap=$spId"
cookie => "lemonldap=$spId"
),
'Test if user is reject on SP'
);

View File

@ -76,6 +76,7 @@ SKIP: {
# Build CAS server
$issuer = register( 'issuer', \&issuer );
# Build CAS App
$sp = register( 'sp', \&sp );

View File

@ -116,8 +116,10 @@ ok( $refresh_token, "Got refresh token" );
ok( $id_token, "Got ID token" );
count(3);
my $id_token_payload = JSON::from_json(decode_base64([split /\./, $id_token]->[1]));
is($id_token_payload->{name}, 'Frédéric Accents', 'Found claim in ID token');
my $id_token_payload =
JSON::from_json( decode_base64( [ split /\./, $id_token ]->[1] ) );
is( $id_token_payload->{name}, 'Frédéric Accents',
'Found claim in ID token' );
count(1);
# Get userinfo
@ -142,7 +144,6 @@ $op->logout($idpId);
$query = "grant_type=refresh_token&refresh_token=$refresh_token";
ok(
$res = $op->_post(
"/oauth2/token",
@ -167,8 +168,10 @@ ok( $id_token, "Got refreshed ID token" );
ok( !defined $refresh_token2, "Refresh token not present" );
count(3);
$id_token_payload = JSON::from_json(decode_base64([split /\./, $id_token]->[1]));
is($id_token_payload->{name}, 'Frédéric Accents', 'Found claim in ID token');
$id_token_payload =
JSON::from_json( decode_base64( [ split /\./, $id_token ]->[1] ) );
is( $id_token_payload->{name}, 'Frédéric Accents',
'Found claim in ID token' );
count(1);
## Get userinfo again
@ -197,7 +200,6 @@ Time::Fake->offset("+10d");
$query = "grant_type=refresh_token&refresh_token=$refresh_token";
ok(
$res = $op->_post(
"/oauth2/token",
@ -222,8 +224,10 @@ ok( $id_token, "Got refreshed ID token" );
ok( !defined $refresh_token2, "Refresh token not present" );
count(3);
$id_token_payload = JSON::from_json(decode_base64([split /\./, $id_token]->[1]));
is($id_token_payload->{name}, 'Frédéric Accents', 'Found claim in ID token');
$id_token_payload =
JSON::from_json( decode_base64( [ split /\./, $id_token ]->[1] ) );
is( $id_token_payload->{name}, 'Frédéric Accents',
'Found claim in ID token' );
count(1);
## Get userinfo again

View File

@ -116,8 +116,10 @@ ok( $access_token, "Got access token" );
ok( $refresh_token, "Got refresh token" );
ok( $id_token, "Got ID token" );
my $id_token_payload = JSON::from_json(decode_base64([split /\./, $id_token]->[1]));
is($id_token_payload->{name}, 'Frédéric Accents', 'Found claim in ID token');
my $id_token_payload =
JSON::from_json( decode_base64( [ split /\./, $id_token ]->[1] ) );
is( $id_token_payload->{name}, 'Frédéric Accents',
'Found claim in ID token' );
# Get userinfo
$res = $op->_post(
@ -175,8 +177,10 @@ ok( $access_token, "Got refreshed Access token" );
ok( $id_token, "Got refreshed ID token" );
ok( !defined $json->{refresh_token}, "Refresh token not present" );
$id_token_payload = JSON::from_json(decode_base64([split /\./, $id_token]->[1]));
is($id_token_payload->{name}, 'Frédéric Accents', 'Found claim in ID token');
$id_token_payload =
JSON::from_json( decode_base64( [ split /\./, $id_token ]->[1] ) );
is( $id_token_payload->{name}, 'Frédéric Accents',
'Found claim in ID token' );
# Try refreshed access token
$res = $op->_post(

View File

@ -179,7 +179,6 @@ ok( $token, 'Access token present' );
count(1);
Time::Fake->offset("+2h");
ok(
$res = $op->_post(
"/oauth2/userinfo",

View File

@ -158,8 +158,7 @@ SKIP: {
switch ('sp');
ok(
$res = $sp->_get(
'/',
accept => 'text/html',
'/', accept => 'text/html',
),
'Try SAML SP'
);

View File

@ -97,8 +97,7 @@ SKIP: {
switch ('sp');
ok(
$res = $sp->_get(
'/',
accept => 'text/html',
'/', accept => 'text/html',
),
'Try SAML SP'
);

View File

@ -98,8 +98,7 @@ SKIP: {
switch ('sp');
ok(
$res = $sp->_get(
'/',
accept => 'text/html',
'/', accept => 'text/html',
),
'Try SAML SP'
);

View File

@ -30,7 +30,8 @@ SKIP: {
skip 'LLNGTESTLDAP is not set', $maintests unless ( $ENV{LLNGTESTLDAP} );
require 't/test-ldap.pm';
use Net::LDAP;
$notif = Lemonldap::NG::Common::Notifications::LDAP->new($notificationStorageOptions);
$notif = Lemonldap::NG::Common::Notifications::LDAP->new(
$notificationStorageOptions);
my $ldap = Net::LDAP->new($ldapServer);
my $mesg = $ldap->bind( $ldapBindDN, password => $ldapBindPassword );
is( $mesg->code, 0, "Bind to LDAP server" ) or diag $mesg->error;

View File

@ -99,8 +99,7 @@ SKIP: {
'Auth query'
);
expectOK($res);
$id
= expectCookie($res);
$id = expectCookie($res);
expectForm( $res, undef, '/notifback', 'reference1x1', 'url' );
# Verify that cookie is ciphered (session unvalid)

View File

@ -98,6 +98,7 @@ SKIP: {
useSafeJail => 1,
notification => 1,
notificationServer => 1,
#notificationDefaultCond => '$env->{REMOTE_ADDR} =~ /127.0.0.1/',
notificationStorage => 'File',
notificationStorageOptions => {

View File

@ -3,6 +3,7 @@ use strict;
use IO::String;
my $userdb;
BEGIN {
eval {
require 't/test-lib.pm';

View File

@ -73,8 +73,7 @@ ok( $res->[2]->[0] =~ m%<span trspan="decryptCipheredValue">%,
count(2);
# Decrypt ciphered value
$query =~
s%cipheredValue=%cipheredValue=lowercase%;
$query =~ s%cipheredValue=%cipheredValue=lowercase%;
ok(
$res = $client->_post(
'/decryptvalue',
@ -85,7 +84,8 @@ ok(
),
'POST decryptvalue with valid value'
);
ok( $res->[2]->[0] =~ m%<span trspan="LOWERCASE"></span>%, 'Found decryted value' )
ok( $res->[2]->[0] =~ m%<span trspan="LOWERCASE"></span>%,
'Found decryted value' )
or explain( $res->[2]->[0], 'Decryted value NOT found' );
count(2);
( $host, $url, $query ) =

View File

@ -39,8 +39,10 @@ ok(
),
'Auth query'
);
ok( $res->[2]->[0] !~ m%<input type="hidden" name="skin" value="bootstrap" />%, '"skin=bootstrap" input not found' )
or explain( $res->[2]->[0], '"skin=bootstrap" found' );
ok(
$res->[2]->[0] !~ m%<input type="hidden" name="skin" value="bootstrap" />%,
'"skin=bootstrap" input not found'
) or explain( $res->[2]->[0], '"skin=bootstrap" found' );
count(2);
expectOK($res);
my $id2 = expectCookie($res);

View File

@ -52,7 +52,6 @@ ok(
count(1);
my $id = expectCookie($res);
# Portal IS NOT a handler
#########################
ok(

View File

@ -29,7 +29,10 @@ require 't/test-lib.pm';
my $res;
my $client = register('portal', sub { LLNG::Manager::Test->new( {
my $client = register(
'portal',
sub {
LLNG::Manager::Test->new( {
ini => {
logLevel => 'error',
useSafeJail => 1,
@ -37,8 +40,9 @@ my $client = register('portal', sub { LLNG::Manager::Test->new( {
logger => 'Lemonldap::NG::Common::Logger::Std',
}
}
)
} );
);
}
);
# CDA with unauthentified user
ok(

View File

@ -10,7 +10,10 @@ require 't/test-lib.pm';
my $res;
my $client = register('portal', sub {LLNG::Manager::Test->new( {
my $client = register(
'portal',
sub {
LLNG::Manager::Test->new( {
ini => {
logLevel => 'error',
useSafeJail => 1,
@ -18,7 +21,7 @@ my $client = register('portal', sub {LLNG::Manager::Test->new( {
logger => 'Lemonldap::NG::Common::Logger::Std',
}
}
)
);
}
);
@ -64,7 +67,8 @@ count(2);
my ( $cli, $app );
switch ('app');
$app = register('app', sub {Lemonldap::NG::Handler::Server->run( $client->ini ) } );
$app = register( 'app',
sub { Lemonldap::NG::Handler::Server->run( $client->ini ) } );
ok(
$res = $app->( {

View File

@ -65,7 +65,9 @@ LWP::Protocol::PSGI->register(
}
);
$client = register ('portal', sub {
$client = register(
'portal',
sub {
LLNG::Manager::Test->new( {
ini => {
logLevel => $debug,
@ -112,7 +114,9 @@ use_ok('Lemonldap::NG::Common::PSGI::Cli::Lib');
my ( $cli, $app );
&Lemonldap::NG::Handler::Main::cfgNum( 0, 0 );
switch ('app');
$app = register('app', sub {
$app = register(
'app',
sub {
Lemonldap::NG::Handler::Server->run( {
%{ $client->ini },
globalStorage => 'Lemonldap::NG::Common::Apache::Session::REST',
@ -120,7 +124,7 @@ $app = register('app', sub {
{ baseUrl => 'http://auth.example.com/sessions/global/' },
localSessionStorage => undef,
}
)
);
}
);

View File

@ -52,7 +52,9 @@ SKIP: {
if ($@) {
skip 'SOAP::Lite not found', $maintests;
}
$client = register('portal', sub {
$client = register(
'portal',
sub {
LLNG::Manager::Test->new( {
ini => {
logLevel => $debug,
@ -62,7 +64,7 @@ SKIP: {
logger => 'Lemonldap::NG::Common::Logger::Std',
}
}
)
);
}
);
@ -101,15 +103,18 @@ SKIP: {
my ( $cli, $app );
&Lemonldap::NG::Handler::Main::cfgNum( 0, 0 );
switch ('app');
$app = register('app', sub {
$app = register(
'app',
sub {
Lemonldap::NG::Handler::Server->run( {
%{ $client->ini },
globalStorage => 'Lemonldap::NG::Common::Apache::Session::SOAP',
globalStorage =>
'Lemonldap::NG::Common::Apache::Session::SOAP',
globalStorageOptions =>
{ proxy => 'http://auth.example.com/adminSessions' },
localSessionStorage => undef,
}
)
);
}
);

View File

@ -259,7 +259,8 @@ count(1);
expectForm( $res, undef, '/checkuser', 'user', 'url' );
ok( $res->[2]->[0] =~ m%<span trspan="checkUser">%, 'Found trspan="checkUser"' )
or explain( $res->[2]->[0], 'trspan="checkUser"' );
ok( $res->[2]->[0] =~ m%value="dwho\@badwolf.org" trplaceholder="user"%, 'Found trplaceholder with mail' )
ok( $res->[2]->[0] =~ m%value="dwho\@badwolf.org" trplaceholder="user"%,
'Found trplaceholder with mail' )
or explain( $res->[2]->[0], 'trplaceholder with mail' );
count(3);
ok( $res->[2]->[0] =~ m%Auth-User: %, 'Found Auth-User' )
@ -348,6 +349,7 @@ ok(
IO::String->new($query),
cookie => "lemonldap=$id",
length => length($query),
#accept => 'text/html',
),
'POST checkuser'
@ -355,30 +357,19 @@ ok(
my $json;
ok( $json = eval { from_json( $res->[2]->[0] ) }, 'Response is JSON' )
or print STDERR "$@\n" . Dumper($res);
ok(
$json->{URL} eq 'http://test1.example.com/test-restricted_uri/rtyler/',
'Find well formated URL'
) or explain( $json, "Find expected URL" );
ok(
$json->{ALLOWED} eq 'allowed',
'Find "allowed"'
) or explain( $json, 'Find "allowed"' );
ok(
$json->{ALERTE} eq 'alert-info',
'Find "alert-info"'
) or explain( $json, "Find alert-info" );
ok(
$json->{ALERTE_AUTH} eq 'alert-success',
'Find "alert-success"'
) or explain( $json, 'Find "alert-success"' );
ok(
$json->{LOGIN} eq 'rtyler',
'Find "rtyler"'
) or explain( $json, 'Find login "rtyler"' );
ok(
$json->{MSG} eq 'checkUser',
'Find "checkUser"'
) or explain( $json, 'Find message "checkUser"' );
ok( $json->{URL} eq 'http://test1.example.com/test-restricted_uri/rtyler/',
'Find well formated URL' )
or explain( $json, "Find expected URL" );
ok( $json->{ALLOWED} eq 'allowed', 'Find "allowed"' )
or explain( $json, 'Find "allowed"' );
ok( $json->{ALERTE} eq 'alert-info', 'Find "alert-info"' )
or explain( $json, "Find alert-info" );
ok( $json->{ALERTE_AUTH} eq 'alert-success', 'Find "alert-success"' )
or explain( $json, 'Find "alert-success"' );
ok( $json->{LOGIN} eq 'rtyler', 'Find "rtyler"' )
or explain( $json, 'Find login "rtyler"' );
ok( $json->{MSG} eq 'checkUser', 'Find "checkUser"' )
or explain( $json, 'Find message "checkUser"' );
count(8);
# Request with good VH & user
@ -551,15 +542,6 @@ m%<div class="alert alert-warning alert"><div class="text-center"><span trspan="
) or explain( $res->[2]->[0], 'PE5 - Unvalid identity' );
count(2);
$client->logout($id);
clean_sessions();

View File

@ -107,9 +107,11 @@ ok(
),
'POST expired switchcontext'
);
ok( $res->[2]->[0] =~ m%<div class="message message-negative alert"><span trmsg="82"></span></div>%,
'Found "<span trmsg="82">"' )
or explain( $res->[2]->[0], '<span trmsg="82">' );
ok(
$res->[2]->[0] =~
m%<div class="message message-negative alert"><span trmsg="82"></span></div>%,
'Found "<span trmsg="82">"'
) or explain( $res->[2]->[0], '<span trmsg="82">' );
count(3);
# ContextSwitching form

View File

@ -61,10 +61,8 @@ ok(
$res->[2]->[0] =~ m%<span trspan="connectedAs">Connected as</span> rtyler%,
'Connected as rtyler'
) or print STDERR Dumper( $res->[2]->[0] );
ok(
$res->[2]->[0] =~ qr%<span id="languages"></span>%,
'Found language flags'
) or print STDERR Dumper( $res->[2]->[0] );
ok( $res->[2]->[0] =~ qr%<span id="languages"></span>%, 'Found language flags' )
or print STDERR Dumper( $res->[2]->[0] );
expectAuthenticatedAs( $res, 'rtyler' );
ok( $res->[2]->[0] !~ m%contextSwitching_ON%, 'Connected as dwho' )
or print STDERR Dumper( $res->[2]->[0] );
@ -377,8 +375,7 @@ ok(
);
count(6);
ok( $res->[2]->[0] =~ m%<span trmsg="1"></span>%,
'Found PE_SESSIONEXPIRED' )
ok( $res->[2]->[0] =~ m%<span trmsg="1"></span>%, 'Found PE_SESSIONEXPIRED' )
or explain( $res->[2]->[0], 'Sessuion expired' );
ok(
$res = $client->_get(

View File

@ -26,7 +26,8 @@ my $client = LLNG::Manager::Test->new( {
checkUserDisplayPersistentInfo => 0,
checkUserDisplayEmptyValues => 0,
impersonationMergeSSOgroups => 0,
checkUserHiddenAttributes => '_loginHistory hGroups _session_id _session_kind',
checkUserHiddenAttributes =>
'_loginHistory hGroups _session_id _session_kind',
macros => {
test_impersonation => '"$testPrefix__user/$_user"',
_whatToTrace =>

View File

@ -101,7 +101,8 @@ count(1);
( $host, $url, $query ) =
expectForm( $res, undef, '/checkuser', 'user', 'url' );
ok( $res->[2]->[0] =~ m%<span trspan="checkUserMerged">%, 'Found trspan="checkUser"' )
ok( $res->[2]->[0] =~ m%<span trspan="checkUserMerged">%,
'Found trspan="checkUser"' )
or explain( $res->[2]->[0], 'trspan="checkUserMerged"' );
ok(
$res->[2]->[0] =~

View File

@ -321,7 +321,8 @@ ok( $res->[2]->[0] =~ m%<td scope="row">rtyler/dwho</td>%, 'Found rtyler/dwo' )
or explain( $res->[2]->[0], 'Found rtyler/dwo' );
ok( $res->[2]->[0] =~ m%<td scope="row">_session_id</td>%, 'Found _session_id' )
or explain( $res->[2]->[0], 'Found _session_id' );
ok( $res->[2]->[0] =~ m%<td scope="row">_session_kind</td>%, 'Found _session_id' )
ok( $res->[2]->[0] =~ m%<td scope="row">_session_kind</td>%,
'Found _session_id' )
or explain( $res->[2]->[0], 'Found _session_kind' );
count(18);

View File

@ -65,7 +65,8 @@ ok( $res->[2]->[0] =~ qr%<img src="/static/common/logos/logo_llng_old.png"%,
count(1);
my ( $host, $url, $query ) =
expectForm( $res, undef, '/rest2fcheck?skin=bootstrap', 'token', 'code', 'checkLogins' );
expectForm( $res, undef, '/rest2fcheck?skin=bootstrap', 'token', 'code',
'checkLogins' );
$query =~ s/code=/code=1234/;
ok(

View File

@ -93,7 +93,8 @@ ok(
count(1);
my ( $host, $url, $query ) =
expectForm( $res, undef, '/ext2fcheck?skin=bootstrap', 'token', 'code', 'checkLogins' );
expectForm( $res, undef, '/ext2fcheck?skin=bootstrap', 'token', 'code',
'checkLogins' );
ok(
$res->[2]->[0] =~
@ -134,7 +135,8 @@ ok(
count(1);
( $host, $url, $query ) =
expectForm( $res, undef, '/ext2fcheck?skin=bootstrap', 'token', 'code', 'checkLogins' );
expectForm( $res, undef, '/ext2fcheck?skin=bootstrap', 'token', 'code',
'checkLogins' );
ok(
$res->[2]->[0] =~

View File

@ -77,7 +77,8 @@ ok(
);
( $host, $url, $query ) =
expectForm( $res, undef, '/ext2fcheck?skin=bootstrap', 'token', 'code', 'checkLogins' );
expectForm( $res, undef, '/ext2fcheck?skin=bootstrap', 'token', 'code',
'checkLogins' );
ok(
$res->[2]->[0] =~

View File

@ -27,6 +27,7 @@ my $ini = {
securedCookie => 0,
https => 0,
portalDisplayResetPassword => 1,
# portalDisplayCertificateResetByMail => 1, Missing dependencies
portalStatus => 1,
cda => 1,

View File

@ -502,7 +502,6 @@ sub tempdb {
return "$tmpDir/userdb.db";
}
my %handlerOR;
=head4 register
@ -864,5 +863,4 @@ sub _put {
return $self->_post( $path, $body, %args );
}
1;