Skip to content

Commit 67def3c

Browse files
Merge branch '6.2' into 6.3
* 6.2: [Notifier] Document Notifier options in README files 5.4 fix exception wording [Security] Test `CsrfTokenClearingLogoutListener` with stateless logout
2 parents f444d1f + ef5d875 commit 67def3c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Security\Http\Tests\EventListener;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
16+
use Symfony\Component\HttpFoundation\Request;
17+
use Symfony\Component\HttpFoundation\RequestStack;
18+
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
19+
use Symfony\Component\Security\Http\Event\LogoutEvent;
20+
use Symfony\Component\Security\Http\EventListener\CsrfTokenClearingLogoutListener;
21+
22+
class CsrfTokenClearingLogoutListenerTest extends TestCase
23+
{
24+
public function testSkipsClearingSessionTokenStorageOnStatelessRequest()
25+
{
26+
try {
27+
(new CsrfTokenClearingLogoutListener(
28+
new SessionTokenStorage(new RequestStack())
29+
))->onLogout(new LogoutEvent(new Request(), null));
30+
} catch (SessionNotFoundException) {
31+
$this->fail('clear() must not be called if the request is not associated with a session instance');
32+
}
33+
34+
$this->addToAssertionCount(1);
35+
}
36+
}

0 commit comments

Comments
 (0)