You are here

public function OAuth2ClientTest::userPasswordFlow in OAuth2 Client 8

Test the user-password flow.

1 call to OAuth2ClientTest::userPasswordFlow()
OAuth2ClientTest::testGetAccessToken in tests/src/Functional/OAuth2ClientTest.php

File

tests/src/Functional/OAuth2ClientTest.php, line 74

Class

OAuth2ClientTest
Test OAuth2 Client.

Namespace

Drupal\Tests\oauth2_client\Functional

Code

public function userPasswordFlow() {
  $token1 = $this
    ->getToken('user-password');
  $token2 = $this
    ->getToken('user-password');
  $this
    ->assertEquals($token2, $token1, 'The same cached token is used, while it has not expired yet.');

  // Wait for the token to expire.
  sleep(10);
  $token3 = $this
    ->getToken('user-password');
  $this
    ->assertNotEquals($token3, $token1, 'Getting a new token from refresh_token.');

  // Wait for the refresh_token to expire.
  sleep(30);
  $token4 = $this
    ->getToken('user-password');
}