use Symfony\Component\HttpFoundation\Request;
class AddSessionDomainConstraintPassTest extends TestCase
{ public function testSessionCookie() { $container =
$this->
createContainer(['cookie_domain' => '.symfony.com.', 'cookie_secure' => true, 'cookie_samesite' => 'lax'
]);
$utils =
$container->
get('security.http_utils'
);
$request = Request::
create('/', 'get'
);
$this->
assertTrue($utils->
createRedirectResponse($request, 'https://symfony.com/blog'
)->
isRedirect('https://symfony.com/blog'
));
$this->
assertTrue($utils->
createRedirectResponse($request, 'https://www.symfony.com/blog'
)->
isRedirect('https://www.symfony.com/blog'
));
$this->
assertTrue($utils->
createRedirectResponse($request, 'https://localhost/foo'
)->
isRedirect('https://localhost/foo'
));
$this->
assertTrue($utils->
createRedirectResponse($request, 'https://www.localhost/foo'
)->
isRedirect('http://localhost/'
));
$this->
assertTrue($utils->
createRedirectResponse($request, 'http://symfony.com/blog'
)->
isRedirect('http://localhost/'
));
$this->
assertTrue($utils->
createRedirectResponse($request, 'http://pirate.com/foo'
)->
isRedirect('http://localhost/'
));
} public function testSessionNoDomain() { $container =
$this->
createContainer(['cookie_secure' => true, 'cookie_samesite' => 'lax'
]);