|
12 | 12 | namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
| 15 | +use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension; |
15 | 16 | use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
|
16 | 17 | use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
17 | 18 | use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\DummyProvider;
|
@@ -343,6 +344,59 @@ public function testDoNotRegisterTheUserProviderAliasWithMultipleProviders()
|
343 | 344 | $this->assertFalse($container->has(UserProviderInterface::class));
|
344 | 345 | }
|
345 | 346 |
|
| 347 | + /** |
| 348 | + * @dataProvider sessionConfigurationProvider |
| 349 | + */ |
| 350 | + public function testRememberMeCookieInheritFrameworkSessionCookie($config, $samesite, $secure) |
| 351 | + { |
| 352 | + $container = $this->getRawContainer(); |
| 353 | + |
| 354 | + $container->registerExtension(new FrameworkExtension()); |
| 355 | + $container->setParameter('kernel.bundles_metadata', array()); |
| 356 | + $container->setParameter('kernel.project_dir', __DIR__); |
| 357 | + $container->setParameter('kernel.root_dir', __DIR__); |
| 358 | + $container->setParameter('kernel.cache_dir', __DIR__); |
| 359 | + |
| 360 | + $container->loadFromExtension('security', array( |
| 361 | + 'firewalls' => array( |
| 362 | + 'default' => array( |
| 363 | + 'form_login' => null, |
| 364 | + 'remember_me' => array('secret' => 'baz'), |
| 365 | + ), |
| 366 | + ), |
| 367 | + )); |
| 368 | + $container->loadFromExtension('framework', array( |
| 369 | + 'session' => $config, |
| 370 | + )); |
| 371 | + |
| 372 | + $container->compile(); |
| 373 | + |
| 374 | + $definition = $container->getDefinition('security.authentication.rememberme.services.simplehash.default'); |
| 375 | + |
| 376 | + $this->assertEquals($samesite, $definition->getArgument(3)['samesite']); |
| 377 | + $this->assertEquals($secure, $definition->getArgument(3)['secure']); |
| 378 | + } |
| 379 | + |
| 380 | + public function sessionConfigurationProvider() |
| 381 | + { |
| 382 | + return array( |
| 383 | + array( |
| 384 | + false, |
| 385 | + null, |
| 386 | + false, |
| 387 | + ), |
| 388 | + array( |
| 389 | + array( |
| 390 | + 'cookie_secure' => true, |
| 391 | + 'cookie_samesite' => 'lax', |
| 392 | + 'save_path' => null, |
| 393 | + ), |
| 394 | + 'lax', |
| 395 | + true, |
| 396 | + ), |
| 397 | + ); |
| 398 | + } |
| 399 | + |
346 | 400 | protected function getRawContainer()
|
347 | 401 | {
|
348 | 402 | $container = new ContainerBuilder();
|
|
0 commit comments