You are here

public function OAuth2ClientTestCase::userPasswordFlow in OAuth2 Client 7

Same name and namespace in other branches
  1. 7.2 tests/oauth2_client.test \OAuth2ClientTestCase::userPasswordFlow()

Test the user-password flow.

1 call to OAuth2ClientTestCase::userPasswordFlow()
OAuth2ClientTestCase::testGetAccessToken in tests/oauth2_client.test

File

tests/oauth2_client.test, line 62
OAuth2 Client tests.

Class

OAuth2ClientTestCase
Test OAuth2 Client.

Code

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

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

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