Skip to content

Commit

Permalink
[Tests] Aligned RepositoryUserAuthenticationSubscriberTest with Symfo…
Browse files Browse the repository at this point in the history
…ny 6
  • Loading branch information
alongosz committed Oct 31, 2024
1 parent df912c9 commit 55043b4
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
use Ibexa\Contracts\Core\Repository\UserService;
use Ibexa\Core\MVC\Symfony\Security\Authentication\EventSubscriber\RepositoryUserAuthenticationSubscriber;
use Ibexa\Core\MVC\Symfony\Security\User;
use Ibexa\Core\MVC\Symfony\Security\UserInterface as IbexaUserInterface;
use Ibexa\Core\Repository\User\Exception\UnsupportedPasswordHashType;
use Ibexa\Core\Repository\Values\User\User as APIUser;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
Expand Down Expand Up @@ -148,7 +148,7 @@ private function getSubscriber(
}

private function getCheckPassportEvent(
?UserInterface $user = null,
?User $user = null,
?Passport $passport = null,
): CheckPassportEvent {
$authenticator = $this->createMock(AuthenticatorInterface::class);
Expand All @@ -158,12 +158,15 @@ private function getCheckPassportEvent(
$userProvider = $this->createMock(User\APIUserProviderInterface::class);
$userProvider
->expects(self::once())
->method('loadUserByUsername')
->method('loadUserByIdentifier')
->willReturn($user);

$passport = new Passport(
new UserBadge($user->getUsername(), [$userProvider, 'loadUserByUsername']),
new PasswordCredentials($user->getPassword() ?? '')
new UserBadge(
$user->getUserIdentifier(),
static fn (string $userIdentifier): IbexaUserInterface => $userProvider->loadUserByIdentifier($userIdentifier)
),
new PasswordCredentials($user->getPassword())
);
}

Expand Down

0 comments on commit 55043b4

Please sign in to comment.