You are here

public function SimpleOauthAuthenticationTest::hasTokenValueProvider in Simple OAuth (OAuth2) & OpenID Connect 8.2

Same name and namespace in other branches
  1. 8.4 tests/src/Unit/Authentication/Provider/SimpleOauthAuthenticationTest.php \Drupal\Tests\simple_oauth\Unit\Authentication\Provider\SimpleOauthAuthenticationTest::hasTokenValueProvider()
  2. 8.3 tests/src/Unit/Authentication/Provider/SimpleOauthAuthenticationTest.php \Drupal\Tests\simple_oauth\Unit\Authentication\Provider\SimpleOauthAuthenticationTest::hasTokenValueProvider()
  3. 5.x tests/src/Unit/Authentication/Provider/SimpleOauthAuthenticationTest.php \Drupal\Tests\simple_oauth\Unit\Authentication\Provider\SimpleOauthAuthenticationTest::hasTokenValueProvider()

File

tests/src/Unit/Authentication/Provider/SimpleOauthAuthenticationTest.php, line 48

Class

SimpleOauthAuthenticationTest
@coversDefaultClass \Drupal\simple_oauth\Authentication\Provider\SimpleOauthAuthenticationProvider @group simple_oauth

Namespace

Drupal\Tests\simple_oauth\Unit\Authentication\Provider

Code

public function hasTokenValueProvider() {
  $data = [];

  // 1. Authentication header.
  $token = $this
    ->getRandomGenerator()
    ->name();
  $request = new Request();
  $request->headers
    ->set('Authorization', 'Bearer ' . $token);
  $data[] = [
    $request,
    TRUE,
  ];

  // 2. Authentication header. Trailing white spaces.
  $token = $this
    ->getRandomGenerator()
    ->name();
  $request = new Request();
  $request->headers
    ->set('Authorization', '  Bearer ' . $token);
  $data[] = [
    $request,
    TRUE,
  ];

  // 3. Authentication header. No white spaces.
  $token = $this
    ->getRandomGenerator()
    ->name();
  $request = new Request();
  $request->headers
    ->set('Authorization', 'Foo' . $token);
  $data[] = [
    $request,
    FALSE,
  ];

  // 4. Authentication header. Fail: no token.
  $request = new Request();
  $data[] = [
    $request,
    FALSE,
  ];
  return $data;
}