New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KernelBrowser::loginUser does not work when called multiple times #41590
Comments
I think an issue that I discovered in our tests is related to this. We have two helper methods in our integration tests to check authentication, which we use around public function testSessionContainsSecurityToken(): void
{
$client = self::createClient();
self::assertUserIsNotAuthenticated();
$client->loginUser(new InMemoryUser('admin', 'password', ['ROLE_ADMIN']));
self::assertUserIsAuthenticated();
}
private static function session(): SessionInterface
{
return static::getContainer()->get(SessionInterface::class);
}
protected static function assertUserIsNotAuthenticated(): void
{
$token = self::session()->get('_security_main');
self::assertNull($token, 'The user is authenticated');
}
protected static function assertUserIsAuthenticated(): void
{
$token = self::session()->get('_security_main');
self::assertIsString($token, 'The user is not authenticated');
} In 5.2.9 both work fine. In 5.3.1 with the new session configuration, Authentication still works, but its not possible to access the token. I guess thats why changing the logged in user is not possible either. I added the tests in @guillaumesmo's reproducer here because I think it is related: guillaumesmo/symfony-login-user-issue#1, but I can also open a separate issue if you think it makes sense. |
/cc @jderusse |
fixed by #41505 |
Tested with thanks |
@guillaumesmo could you try to check if it still works for you with SF 5.3.9? I have an issue with multiple |
Symfony version(s) affected: 5.3.1
Description
Since the introduction of
storage_factory_id
to replacestorage_id
, it's not possible to switch to another user in the tests any moreI have pushed a sample project which reproduces the issue here: https://github.com/guillaumesmo/symfony-login-user-issue
How to reproduce
in a controller:
in a WebTestCase:
run bin/phpunit:
Now in config/packages/framework.yaml, revert to the Symfony 5.2 default config:
storage_factory_id: session.storage.factory.native
storage_factory_id: session.storage.factory.mock_file
tostorage_id: session.storage.mock_file
run bin/phpunit:
The text was updated successfully, but these errors were encountered: