protected function ReverseProxyMiddlewareTest::trustedHeadersAreSet in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\ReverseProxyMiddlewareTest::trustedHeadersAreSet()
- 9 core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\ReverseProxyMiddlewareTest::trustedHeadersAreSet()
Tests that trusted headers are set correctly.
\Symfony\Component\HttpFoundation\Request::setTrustedProxies() should always be called when reverse proxy settings are enabled.
Parameters
\Drupal\Core\Site\Settings $settings: The settings object that holds reverse proxy configuration.
int $expected_trusted_header_set: The expected bit value returned by \Symfony\Component\HttpFoundation\Request::getTrustedHeaderSet()
1 call to ReverseProxyMiddlewareTest::trustedHeadersAreSet()
- ReverseProxyMiddlewareTest::testReverseProxyEnabled in core/
tests/ Drupal/ Tests/ Core/ StackMiddleware/ ReverseProxyMiddlewareTest.php - Tests that subscriber sets trusted headers when reverse proxy is set.
File
- core/
tests/ Drupal/ Tests/ Core/ StackMiddleware/ ReverseProxyMiddlewareTest.php, line 102
Class
- ReverseProxyMiddlewareTest
- Unit test the reverse proxy stack middleware.
Namespace
Drupal\Tests\Core\StackMiddlewareCode
protected function trustedHeadersAreSet(Settings $settings, $expected_trusted_header_set) {
$middleware = new ReverseProxyMiddleware($this->mockHttpKernel, $settings);
$request = new Request();
$middleware
->handle($request);
$this
->assertSame($settings
->get('reverse_proxy_addresses'), $request
->getTrustedProxies());
$this
->assertSame($expected_trusted_header_set, $request
->getTrustedHeaderSet());
}