You are here

public function RefreshTokenTest::testThatRefreshTokenRequestIsMadeCorrectly in Auth0 Single Sign On 8.2

Test that the refresh token request is made successfully.

File

vendor/auth0/auth0-php/tests/API/Authentication/RefreshTokenTest.php, line 101

Class

RefreshTokenTest
Class RefreshTokenTest. Tests the \Auth0\SDK\API\Authentication::refresh_token() method.

Namespace

Auth0\Tests\API\Authentication

Code

public function testThatRefreshTokenRequestIsMadeCorrectly() {
  $api = new MockAuthenticationApi([
    new Response(200, self::$headers),
  ]);
  $refresh_token = uniqid();
  $api
    ->call()
    ->refresh_token($refresh_token);
  $this
    ->assertEquals('POST', $api
    ->getHistoryMethod());
  $this
    ->assertEquals('https://test-domain.auth0.com/oauth/token', $api
    ->getHistoryUrl());
  $this
    ->assertEmpty($api
    ->getHistoryQuery());
  $headers = $api
    ->getHistoryHeaders();
  $this
    ->assertEquals(self::$expectedTelemetry, $headers['Auth0-Client'][0]);
  $request_body = $api
    ->getHistoryBody();
  $this
    ->assertEquals('refresh_token', $request_body['grant_type']);
  $this
    ->assertEquals('__test_client_id__', $request_body['client_id']);
  $this
    ->assertEquals('__test_client_secret__', $request_body['client_secret']);
  $this
    ->assertEquals($refresh_token, $request_body['refresh_token']);
}