From 1127b147c0cfe599226d3a9c53bce390430a43d1 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Tue, 1 Apr 2025 23:35:40 +0200 Subject: [PATCH] Replace AuthenticationEvents::AUTHENTICATION_FAILURE by LoginFailureEvent --- .../Listener/AuthenticationFailureListener.php | 4 ++-- .../AuthenticationFailureListenerTest.php | 17 +++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Event/Listener/AuthenticationFailureListener.php b/src/Event/Listener/AuthenticationFailureListener.php index 060325400..e1e2acc2e 100644 --- a/src/Event/Listener/AuthenticationFailureListener.php +++ b/src/Event/Listener/AuthenticationFailureListener.php @@ -5,7 +5,7 @@ namespace Wallabag\Event\Listener; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Security\Core\AuthenticationEvents; +use Symfony\Component\Security\Http\Event\LoginFailureEvent; class AuthenticationFailureListener implements EventSubscriberInterface { @@ -21,7 +21,7 @@ class AuthenticationFailureListener implements EventSubscriberInterface public static function getSubscribedEvents(): array { return [ - AuthenticationEvents::AUTHENTICATION_FAILURE => 'onAuthenticationFailure', + LoginFailureEvent::class => 'onAuthenticationFailure', ]; } diff --git a/tests/Event/Listener/AuthenticationFailureListenerTest.php b/tests/Event/Listener/AuthenticationFailureListenerTest.php index dd746817e..4ae4d9002 100644 --- a/tests/Event/Listener/AuthenticationFailureListenerTest.php +++ b/tests/Event/Listener/AuthenticationFailureListenerTest.php @@ -8,10 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\AuthenticationEvents; -use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent; use Symfony\Component\Security\Core\Exception\AuthenticationException; +use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface; +use Symfony\Component\Security\Http\Event\LoginFailureEvent; use Wallabag\Event\Listener\AuthenticationFailureListener; class AuthenticationFailureListenerTest extends TestCase @@ -43,7 +42,7 @@ class AuthenticationFailureListenerTest extends TestCase public function testOnAuthenticationFailure() { - $token = $this->getMockBuilder(TokenInterface::class) + $authenticator = $this->getMockBuilder(AuthenticatorInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -51,15 +50,9 @@ class AuthenticationFailureListenerTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $event = new AuthenticationFailureEvent( - $token, - $exception - ); + $event = new LoginFailureEvent($exception, $authenticator, $this->requestStack->getMainRequest(), null, 'main', null); - $this->dispatcher->dispatch( - $event, - AuthenticationEvents::AUTHENTICATION_FAILURE - ); + $this->dispatcher->dispatch($event); $records = $this->logHandler->getRecords();