Closed
Description
Symfony version(s) affected: 5.3
Description
Generating a CSRF token in a test and check if it is valid doesn't work.
Test
$client = self::createClient();
$token = self::getContainer()->get('security.csrf.token_manager')->getToken('id')->getValue();
$client->request('POST', '/test', ['token' => $token]);
self::assertSame('valid', $client->getResponse()->getContent());
Controller
/**
* @Route("/test")
*/
public function __invoke(Request $request): Response
{
$tokenValid = $this->isCsrfTokenValid('id', $request->request->get('token'));
return new Response($tokenValid ? 'valid' : 'invalid');
}
How to reproduce
Possible Solution
I will search one and open a PR if needed
Additional context
Is related to #41046