You are here

protected function BasicAuthTestTrait::getBasicAuthHeaders in Drupal 9

Same name and namespace in other branches
  1. 8 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().

1 call to BasicAuthTestTrait::getBasicAuthHeaders()
BasicAuthTestTrait::basicAuthGet in core/modules/basic_auth/tests/src/Traits/BasicAuthTestTrait.php
Retrieves a Drupal path or an absolute path using basic authentication.

File

core/modules/basic_auth/tests/src/Traits/BasicAuthTestTrait.php, line 40

Class

BasicAuthTestTrait
Provides common functionality for Basic Authentication test classes.

Namespace

Drupal\Tests\basic_auth\Traits

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}"),
  ];
}