Commit 7b499f9b authored by Christophe Maudoux's avatar Christophe Maudoux 🐛

Fix wrong message & Improve unit test (#2050)

parent 3317ab9f
...@@ -9,7 +9,7 @@ use Lemonldap::NG::Portal::Main::Constants qw( ...@@ -9,7 +9,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(
PE_MALFORMEDUSER PE_MALFORMEDUSER
); );
our $VERSION = '2.0.7'; our $VERSION = '2.0.8';
extends qw( extends qw(
Lemonldap::NG::Portal::Main::Plugin Lemonldap::NG::Portal::Main::Plugin
...@@ -31,6 +31,7 @@ has ott => ( ...@@ -31,6 +31,7 @@ has ott => (
); );
has idRule => ( is => 'rw', default => sub { 1 } ); has idRule => ( is => 'rw', default => sub { 1 } );
has sorted => ( is => 'rw', default => sub { 0 } ); has sorted => ( is => 'rw', default => sub { 0 } );
has merged => ( is => 'rw', default => '' );
sub hAttr { sub hAttr {
$_[0]->{conf}->{checkUserHiddenAttributes} . ' ' $_[0]->{conf}->{checkUserHiddenAttributes} . ' '
...@@ -56,6 +57,8 @@ sub init { ...@@ -56,6 +57,8 @@ sub init {
$self->idRule($rule); $self->idRule($rule);
$self->sorted( $self->conf->{impersonationRule} $self->sorted( $self->conf->{impersonationRule}
|| $self->conf->{contextSwitchingRule} ); || $self->conf->{contextSwitchingRule} );
$self->merged( $self->conf->{impersonationMergeSSOgroups}
&& $self->conf->{impersonationRule} ? 'Merged' : '' );
return 1; return 1;
} }
...@@ -93,24 +96,19 @@ sub display { ...@@ -93,24 +96,19 @@ sub display {
# Display form # Display form
my $params = { my $params = {
PORTAL => $self->conf->{portal}, PORTAL => $self->conf->{portal},
MAIN_LOGO => $self->conf->{portalMainLogo}, MAIN_LOGO => $self->conf->{portalMainLogo},
SKIN => $self->p->getSkin($req), SKIN => $self->p->getSkin($req),
LANGS => $self->conf->{showLanguages}, LANGS => $self->conf->{showLanguages},
MSG => ( MSG => 'checkUser' . $self->merged,
$self->{conf}->{impersonationMergeSSOgroups} ? 'checkUserMerged' ALERTE => ( $self->merged ? 'alert-warning' : 'alert-info' ),
: 'checkUser'
),
ALERTE => (
$self->{conf}->{impersonationMergeSSOgroups} ? 'alert-warning'
: 'alert-info'
),
LOGIN => $req->{userData}->{ $self->conf->{whatToTrace} }, LOGIN => $req->{userData}->{ $self->conf->{whatToTrace} },
ATTRIBUTES => $array_attrs->[2], ATTRIBUTES => $array_attrs->[2],
MACROS => $array_attrs->[1], MACROS => $array_attrs->[1],
GROUPS => $array_attrs->[0], GROUPS => $array_attrs->[0],
TOKEN => ( TOKEN => (
$self->ottRule->( $req, {} ) ? $self->ott->createToken() $self->ottRule->( $req, {} )
? $self->ott->createToken()
: '' : ''
) )
}; };
...@@ -123,7 +121,7 @@ sub display { ...@@ -123,7 +121,7 @@ sub display {
sub check { sub check {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
my ( $attrs, $array_attrs, $array_hdrs ) = ( {}, [], [] ); my ( $attrs, $array_attrs, $array_hdrs ) = ( {}, [], [] );
my $msg = my $auth = my $compute = ''; my $msg = my $auth = my $compute = '';
my $authLevel = $req->userData->{authenticationLevel}; my $authLevel = $req->userData->{authenticationLevel};
my $authMode = $req->userData->{_auth}; my $authMode = $req->userData->{_auth};
...@@ -241,10 +239,7 @@ sub check { ...@@ -241,10 +239,7 @@ sub check {
$attrs = {}; $attrs = {};
} }
else { else {
$msg = $msg = 'checkUser' . $self->merged;
$self->{conf}->{impersonationMergeSSOgroups} eq 1
? 'checkUserMerged'
: 'checkUser';
if ($compute) { if ($compute) {
$msg = 'checkUserComputeSession'; $msg = 'checkUserComputeSession';
$attrs->{authenticationLevel} = $authLevel; $attrs->{authenticationLevel} = $authLevel;
...@@ -442,7 +437,7 @@ sub _splitAttributes { ...@@ -442,7 +437,7 @@ sub _splitAttributes {
if ( $element->{key} eq 'groups' ) { if ( $element->{key} eq 'groups' ) {
$self->logger->debug('Key "groups" found'); $self->logger->debug('Key "groups" found');
my $separator = $self->{conf}->{multiValuesSeparator}; my $separator = $self->{conf}->{multiValuesSeparator};
my @tmp = split /\Q$separator/, $element->{value}; my @tmp = split /\Q$separator/, $element->{value};
$grps = [ map { { value => $_ } } sort @tmp ]; $grps = [ map { { value => $_ } } sort @tmp ];
next; next;
} }
......
...@@ -21,6 +21,7 @@ my $client = LLNG::Manager::Test->new( { ...@@ -21,6 +21,7 @@ my $client = LLNG::Manager::Test->new( {
formTimeout => 120, formTimeout => 120,
checkUserDisplayPersistentInfo => 1, checkUserDisplayPersistentInfo => 1,
checkUserDisplayEmptyValues => 1, checkUserDisplayEmptyValues => 1,
impersonationMergeSSOgroups => 1,
} }
} }
); );
......
...@@ -101,8 +101,8 @@ count(1); ...@@ -101,8 +101,8 @@ count(1);
( $host, $url, $query ) = ( $host, $url, $query ) =
expectForm( $res, undef, '/checkuser', 'user', 'url' ); expectForm( $res, undef, '/checkuser', 'user', 'url' );
ok( $res->[2]->[0] =~ m%<span trspan="checkUser">%, 'Found trspan="checkUser"' ) ok( $res->[2]->[0] =~ m%<span trspan="checkUserMerged">%, 'Found trspan="checkUser"' )
or explain( $res->[2]->[0], 'trspan="checkUser"' ); or explain( $res->[2]->[0], 'trspan="checkUserMerged"' );
ok( ok(
$res->[2]->[0] =~ $res->[2]->[0] =~
m%<div class="alert alert-success"><div class="text-center"><b><span trspan="allowed"></span></b></div></div>%, m%<div class="alert alert-success"><div class="text-center"><b><span trspan="allowed"></span></b></div></div>%,
......
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