Description
Description
the PR #26244 broke flexible testing of domain specific routes for me. is there a way to do this after the PR or can we say we have a bug here?
it should be possible to access localhost but set HTTP_HOST
to simulate a different domain.
if you have a route which should only be accessible via a specific domain
admin:
resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
prefix: /admin
host: admin.example.com
it was easy to test this before, as all functional tests of symfony run against localhost without the need to set up a real webserver with all required vhost names. i simple have done this:
$client->request('GET', '/admin', [], [], ['HTTP_HOST' => 'example.com']);
// will return 404
$client->request('GET', '/admin', [], [], ['HTTP_HOST' => 'admin.example.com']);
// will return 200
now i cannot test that specific routes should be only accessible via a specific domain.
additional all functional tests to routes which require a domain need the route to be configured as
mybundle:
resource: "@MyBundle/Resources/config/routing.yml"
host: "{hostname}"
defaults: { hostname: example.com }
requirements:
hostname: example.com|localhost
if not adding localhost to all routes with domain requirements i will get a 404 for all that routes.
this change add unnecessary overhead and boilerplate to the whole testing and routing.
Possible Solution
please rething this change. at least give us a flag or a own method to get the old behavior back.
Additional context