Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Apr 22, 2024
1 parent c5e1f86 commit c1a2a7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/EventSubscriber/ApiExceptionSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Throwable;

/**
* @internal
Expand All @@ -42,7 +43,7 @@ public function onKernelException(ExceptionEvent $event): void
if(!$exception instanceof ApiExceptionInterface && !$this->isStudioApiCall($request->getPathInfo())) {
return;
}

/** @var ApiExceptionInterface $exception */
$response = new JsonResponse(
[
'message' => $exception->getMessage(),
Expand Down
7 changes: 5 additions & 2 deletions tests/Unit/Service/Security/SecurityServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Codeception\Test\Unit;
use Exception;
use Pimcore\Bundle\StaticResolverBundle\Models\Tool\TmpStoreResolverInterface;
use Pimcore\Bundle\StudioApiBundle\Exception\AccessDeniedException;
use Pimcore\Bundle\StudioApiBundle\Request\Credentials;
use Pimcore\Bundle\StudioApiBundle\Service\SecurityService;
use Pimcore\Bundle\StudioApiBundle\Service\SecurityServiceInterface;
Expand Down Expand Up @@ -49,7 +50,8 @@ public function testInvalidPassword(): void
{
$securityService = $this->mockSecurityService(false);

$this->expectExceptionMessage('Invalid credentials');
$this->expectException(AccessDeniedException::class);
$this->expectExceptionMessage('Bad credentials');
$securityService->authenticateUser(new Credentials('test', 'test'));
}

Expand All @@ -60,7 +62,8 @@ public function testUserNotFound(): void
{
$securityService = $this->mockSecurityService(false, false);

$this->expectExceptionMessage('Invalid credentials');
$this->expectException(AccessDeniedException::class);
$this->expectExceptionMessage('Bad credentials');
$securityService->authenticateUser(new Credentials('test', 'test'));
}

Expand Down

0 comments on commit c1a2a7a

Please sign in to comment.