protected function ReverseProxySubscriberUnitTest::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\Component\Utility\Settings $settings: The settings object that holds reverse proxy configuration.

1 call to ReverseProxySubscriberUnitTest::trustedHeadersAreSet()
ReverseProxySubscriberUnitTest::testReverseProxyEnabled in drupal/core/tests/Drupal/Tests/Core/EventSubscriber/ReverseProxySubscriberUnitTest.php
Tests that subscriber sets trusted headers when reverse proxy is set.

File

drupal/core/tests/Drupal/Tests/Core/EventSubscriber/ReverseProxySubscriberUnitTest.php, line 79
Contains \Drupal\Core\EventSubscriber\ReverseProxySubscriberUnitTest.

Class

ReverseProxySubscriberUnitTest
Tests the ReverseProxySubscriber.

Namespace

Drupal\Tests\Core\EventSubscriber

Code

protected function trustedHeadersAreSet(Settings $settings) {
  $subscriber = new ReverseProxySubscriber($settings);
  $request = $this
    ->getMock('Symfony\\Component\\HttpFoundation\\Request', array(
    'setTrustedHeaderName',
    'setTrustedProxies',
  ));
  $request
    ->staticExpects($this
    ->at(0))
    ->method('setTrustedHeaderName')
    ->with($this
    ->equalTo($request::HEADER_CLIENT_IP), $this
    ->equalTo($settings
    ->get('reverse_proxy_header')));
  $request
    ->staticExpects($this
    ->at(1))
    ->method('setTrustedProxies')
    ->with($this
    ->equalTo($settings
    ->get('reverse_proxy_addresses')));
  $event = $this
    ->getMockedEvent($request);
  $subscriber
    ->onKernelRequestReverseProxyCheck($event);
}