You are here

public function Auth0Test::testThatRenewTokensFailsIfThereIsNoRefreshToken in Auth0 Single Sign On 8.2

Test that renewTokens fails if there is no refresh_token stored.

Throws

ApiException Should not be thrown in this test.

CoreException Should not be thrown in this test.

File

vendor/auth0/auth0-php/tests/Auth0Test.php, line 183

Class

Auth0Test
Class Auth0Test

Namespace

Auth0\Tests

Code

public function testThatRenewTokensFailsIfThereIsNoRefreshToken() {
  $mock = new MockHandler([
    // Code exchange response.
    new Response(200, self::$headers, '{"access_token":"1.2.3"}'),
  ]);
  $add_config = [
    'skip_userinfo' => true,
    'persist_access_token' => true,
    'guzzle_options' => [
      'handler' => HandlerStack::create($mock),
    ],
  ];
  $auth0 = new Auth0(self::$baseConfig + $add_config);
  $_GET['code'] = uniqid();
  $this
    ->assertTrue($auth0
    ->exchange());
  try {
    $caught_exception = false;
    $auth0
      ->renewTokens();
  } catch (CoreException $e) {
    $caught_exception = $this
      ->errorHasString($e, "Can't renew the access token if there isn't a refresh token available");
  }
  $this
    ->assertTrue($caught_exception);
}