Tried both in local and remote hosts. If you don't set the trusted_host_patterns settings and get the warning on the reports page, test will pass just fine. If you add the expected regex and then get the warning message to disappear because it detects you've set things up correctly, then \Drupal\node\Tests\Views\FrontPageTest will fail with the below error:
UnexpectedValueException: Untrusted Host "" in Symfony\Component\HttpFoundation\Request->getHost() (line 1309 of /mnt/www/html/d8ftzcrcvdxcza/docroot/core/vendor/symfony/http-foundation/Request.php).
Symfony\Component\HttpFoundation\Request->getHost()
Symfony\Component\HttpFoundation\Request->getHttpHost()
Symfony\Component\HttpFoundation\Request->getSchemeAndHttpHost()
Drupal\Core\Cache\Context\SiteCacheContext->getContext(NULL)
Drupal\Core\Cache\Context\CacheContextsManager->convertTokensToKeys(Array)
Drupal\Core\Render\RenderCache->createCacheID(Array)
Drupal\Core\Render\RenderCache->set(Array, Array)
Drupal\Core\Render\Renderer->doRender(Array, 1)
Drupal\Core\Render\Renderer->render(Array, 1)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\Render\Renderer->renderRoot(Array)
Drupal\node\Tests\Views\FrontPageTest->assertViewsCacheTags(Object, Array, 1, Array)
Drupal\node\Tests\Views\FrontPageTest->doTestFrontPageViewCacheTags(1)
Drupal\node\Tests\Views\FrontPageTest->testCacheTagsWithCachePluginTime()
Drupal\simpletest\TestBase->run()
_simpletest_batch_operation(Array, '6', Array)
call_user_func_array('_simpletest_batch_operation', Array)
_batch_process()
_batch_do()
_batch_page(Object)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)
What's not obvious to me is why it would make test pass just fine on the test bot and not in my testing? Sanity check, here are my regex variations:
Local
$settings['trusted_host_patterns'] = array(
'^head\.local$',
);Remote (Acquia Cloud Free)
$settings['trusted_host_patterns'] = array(
'^.+\.acquia-sites\.com$',
);
Comments
Comment #2
anavarreComment #3
anavarreComment #4
anavarreComment #13
quietone commentedSimpletest has been removed from core so I can't test with the simpletest UI.
I wonder if the failure happens from the command line. On Drupal 9.3.x I ran the test from the command line with valid and invalid trusted_host_patterns and it always passed.
Just in case this still happens with the UI moving to the simpletest project.