function DrupalKernelTest::providerTestTrustedHosts

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php \Drupal\Tests\Core\DrupalKernel\DrupalKernelTest::providerTestTrustedHosts()
  2. 10 core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php \Drupal\Tests\Core\DrupalKernel\DrupalKernelTest::providerTestTrustedHosts()
  3. 11.x core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php \Drupal\Tests\Core\DrupalKernel\DrupalKernelTest::providerTestTrustedHosts()

Provides test data for testTrustedHosts().

File

core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php, line 55

Class

DrupalKernelTest
@coversDefaultClass \Drupal\Core\DrupalKernel @group DrupalKernel

Namespace

Drupal\Tests\Core\DrupalKernel

Code

public function providerTestTrustedHosts() {
    $data = [];
    // Tests canonical URL.
    $data[] = [
        'www.example.com',
        'www.example.com',
        'canonical URL is trusted',
        TRUE,
    ];
    // Tests missing hostname for HTTP/1.0 compatibility where the Host
    // header is optional.
    $data[] = [
        NULL,
        'www.example.com',
        'empty Host is valid',
        TRUE,
    ];
    // Tests the additional patterns from the settings.
    $data[] = [
        'example.com',
        'www.example.com',
        'host from settings is trusted',
        TRUE,
    ];
    $data[] = [
        'subdomain.example.com',
        'www.example.com',
        'host from settings is trusted',
        TRUE,
    ];
    $data[] = [
        'www.example.org',
        'www.example.com',
        'host from settings is trusted',
        TRUE,
    ];
    $data[] = [
        'example.org',
        'www.example.com',
        'host from settings is trusted',
        TRUE,
    ];
    // Tests mismatch.
    $data[] = [
        'www.black_hat.com',
        'www.example.com',
        'unspecified host is untrusted',
        FALSE,
    ];
    return $data;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.