$container =
$this->
createContainer(['cookie_domain' => '.symfony.com.', 'cookie_secure' => 'auto', '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, 'http://symfony.com/blog'
)->
isRedirect('http://symfony.com/blog'
));
$this->
assertTrue($utils->
createRedirectResponse($request, 'http://pirate.com/foo'
)->
isRedirect('http://localhost/'
));
$container->
get('router.request_context'
)->
setScheme('https'
);
$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, 'http://symfony.com/blog'
)->
isRedirect('http://localhost/'
));
$this->
assertTrue($utils->
createRedirectResponse($request, 'http://pirate.com/foo'
)->
isRedirect('http://localhost/'
));
} private function createContainer($sessionStorageOptions) { $container =
new ContainerBuilder();
$container->
setParameter('kernel.bundles_metadata',
[]);