function BasicAuthTestTrait::getBasicAuthHeaders

Same name in this branch
  1. 8.9.x core/modules/basic_auth/tests/src/Traits/BasicAuthTestTrait.php \Drupal\Tests\basic_auth\Traits\BasicAuthTestTrait::getBasicAuthHeaders()
Same name in other branches
  1. 9 core/modules/basic_auth/tests/src/Traits/BasicAuthTestTrait.php \Drupal\Tests\basic_auth\Traits\BasicAuthTestTrait::getBasicAuthHeaders()
  2. 10 core/modules/basic_auth/tests/src/Traits/BasicAuthTestTrait.php \Drupal\Tests\basic_auth\Traits\BasicAuthTestTrait::getBasicAuthHeaders()
  3. 11.x core/modules/basic_auth/tests/src/Traits/BasicAuthTestTrait.php \Drupal\Tests\basic_auth\Traits\BasicAuthTestTrait::getBasicAuthHeaders()

Returns HTTP headers that can be used for basic authentication in Curl.

Parameters

string $username: The username to use for basic authentication.

string $password: The password to use for basic authentication.

Return value

array An array of raw request headers as used by curl_setopt().

2 calls to BasicAuthTestTrait::getBasicAuthHeaders()
BasicAuthTestTrait::basicAuthGet in core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php
Retrieves a Drupal path or an absolute path using basic authentication.
BasicAuthTestTrait::basicAuthPostForm in core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php
Executes a form submission using basic authentication.

File

core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php, line 76

Class

BasicAuthTestTrait
Provides common functionality for Basic Authentication test classes.

Namespace

Drupal\basic_auth\Tests

Code

protected function getBasicAuthHeaders($username, $password) {
    // Set up Curl to use basic authentication with the test user's credentials.
    return [
        'Authorization: Basic ' . base64_encode("{$username}:{$password}"),
    ];
}

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