-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security] Test
CsrfTokenClearingLogoutListener
with stateless logout
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
Tests/EventListener/CsrfTokenClearingLogoutListenerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Security\Http\Tests\EventListener; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage; | ||
use Symfony\Component\Security\Http\Event\LogoutEvent; | ||
use Symfony\Component\Security\Http\EventListener\CsrfTokenClearingLogoutListener; | ||
|
||
class CsrfTokenClearingLogoutListenerTest extends TestCase | ||
{ | ||
public function testSkipsClearingSessionTokenStorageOnStatelessRequest() | ||
{ | ||
try { | ||
(new CsrfTokenClearingLogoutListener( | ||
new SessionTokenStorage(new RequestStack()) | ||
))->onLogout(new LogoutEvent(new Request(), null)); | ||
} catch (SessionNotFoundException) { | ||
$this->fail('clear() must not be called if the request is not associated with a session instance'); | ||
} | ||
|
||
$this->addToAssertionCount(1); | ||
} | ||
} |