protected function ReverseProxyMiddlewareTest::trustedHeadersAreSet in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\ReverseProxyMiddlewareTest::trustedHeadersAreSet()
Tests that trusted header methods are called.
\Symfony\Component\HttpFoundation\Request::setTrustedHeaderName() and \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.
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 90 - Contains \Drupal\Tests\Core\StackMiddleware\ReverseProxyMiddlewareTest.
Class
- ReverseProxyMiddlewareTest
- Unit test the reverse proxy stack middleware.
Namespace
Drupal\Tests\Core\StackMiddlewareCode
protected function trustedHeadersAreSet(Settings $settings) {
$middleware = new ReverseProxyMiddleware($this->mockHttpKernel, $settings);
$request = new Request();
$middleware
->handle($request);
$this
->assertSame($settings
->get('reverse_proxy_header'), $request
->getTrustedHeaderName($request::HEADER_CLIENT_IP));
$this
->assertSame($settings
->get('reverse_proxy_proto_header'), $request
->getTrustedHeaderName($request::HEADER_CLIENT_PROTO));
$this
->assertSame($settings
->get('reverse_proxy_host_header'), $request
->getTrustedHeaderName($request::HEADER_CLIENT_HOST));
$this
->assertSame($settings
->get('reverse_proxy_port_header'), $request
->getTrustedHeaderName($request::HEADER_CLIENT_PORT));
$this
->assertSame($settings
->get('reverse_proxy_forwarded_header'), $request
->getTrustedHeaderName($request::HEADER_FORWARDED));
$this
->assertSame($settings
->get('reverse_proxy_addresses'), $request
->getTrustedProxies());
}