From 9a6b604f5ca0cb764f93a78d8451f5feeeca1827 Mon Sep 17 00:00:00 2001 From: Christophe Maudoux Date: Sat, 22 Feb 2020 21:59:07 +0100 Subject: [PATCH] Skip bad rule & improve unit test (#2102) --- .../lib/Lemonldap/NG/Portal/Plugins/AutoSignin.pm | 10 +++++++--- lemonldap-ng-portal/t/65-AutoSignin.t | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/AutoSignin.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/AutoSignin.pm index 71963542d..5cfdebdc4 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/AutoSignin.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/AutoSignin.pm @@ -7,7 +7,7 @@ use Lemonldap::NG::Portal::Main::Constants qw( PE_OK ); -our $VERSION = '2.0.0'; +our $VERSION = '2.0.8'; extends 'Lemonldap::NG::Portal::Main::Plugin'; @@ -27,9 +27,13 @@ sub init { my $sub = $safe->reval( 'sub{my($env)=@_;return (' . $rules->{$id} . ')}' ); if ($@) { - $self->error( 'Bad Autologin rule "' . $rules->{$id} . ': $@' ); - return 0; + $self->logger->error( + 'Bad Autologin rule "' . $rules->{$id} . ": $@" ); + $self->logger->debug( + "Skipping Autologin rule for user \"$id\""); + next; } + $self->logger->debug("Autologin rule for user \"$id\" appended"); $id =~ s/^\s*([\w\-\@]+)\s*/$1/; push @{ $self->rules }, [ $sub, $id ]; } diff --git a/lemonldap-ng-portal/t/65-AutoSignin.t b/lemonldap-ng-portal/t/65-AutoSignin.t index 06fc61502..048dfdd3b 100644 --- a/lemonldap-ng-portal/t/65-AutoSignin.t +++ b/lemonldap-ng-portal/t/65-AutoSignin.t @@ -11,7 +11,9 @@ my $client = LLNG::Manager::Test->new( { authentication => 'Demo', userDB => 'Same', autoSigninRules => { - dwho => '$env->{REMOTE_ADDR} =~ /^127/', + rtyler => '$env->{REMOTE_ADDR} =~ /^127', + dwho => '$env->{REMOTE_ADDR =~ /^127/', + msmith => '$env->{REMOTE_ADDR} =~ /^127/', }, } }