You are here

public function ReverseProxyMiddlewareTest::testReverseProxyEnabledLegacy in Drupal 8

Tests that subscriber sets trusted headers when reverse proxy is set.

@dataProvider reverseProxyEnabledProviderLegacy @group legacy

File

core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php, line 93

Class

ReverseProxyMiddlewareTest
Unit test the reverse proxy stack middleware.

Namespace

Drupal\Tests\Core\StackMiddleware

Code

public function testReverseProxyEnabledLegacy($provided_settings, $expected_trusted_header_set, array $expected_deprecations) {
  if (!method_exists(Request::class, 'setTrustedHeaderName')) {
    $this
      ->markTestSkipped('The method \\Symfony\\Component\\HttpFoundation\\Request::setTrustedHeaderName() does not exist therefore testing on Symfony 4 or greater.');
  }
  $this
    ->expectedDeprecations($expected_deprecations);

  // Enable reverse proxy and add test values.
  $settings = new Settings([
    'reverse_proxy' => 1,
  ] + $provided_settings);
  $this
    ->trustedHeadersAreSet($settings, $expected_trusted_header_set);
}