You are here

public function OAuth2ClientTestCase::clientCredentialsFlow in OAuth2 Client 7

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

Test the client-credentials flow.

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

File

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

Class

OAuth2ClientTestCase
Test OAuth2 Client.

Code

public function clientCredentialsFlow() {
  $token1 = $this
    ->getToken('client-credentials');
  $token2 = $this
    ->getToken('client-credentials');
  $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('client-credentials');
  $this
    ->assertNotEqual($token1, $token3, 'Getting a new token, client-credential flow has no refresh token.');
}