public function Auth0Test::testThatExchangeSucceedsWithIdToken in Auth0 Single Sign On 8.2
Test that the exchanges succeeds when there is both and access token and an ID token present.
Throws
File
- vendor/
auth0/ auth0-php/ tests/ Auth0Test.php, line 74
Class
- Auth0Test
- Class Auth0Test
Namespace
Auth0\TestsCode
public function testThatExchangeSucceedsWithIdToken() {
$id_token_payload = [
'sub' => '123',
];
$id_token = JWT::encode($id_token_payload, '__test_client_secret__');
$response_body = '{"access_token":"1.2.3","id_token":"' . $id_token . '","refresh_token":"4.5.6"}';
$mock = new MockHandler([
// Code exchange response.
new Response(200, self::$headers, $response_body),
// Userinfo response.
new Response(200, self::$headers, json_encode($id_token_payload)),
]);
$add_config = [
'guzzle_options' => [
'handler' => HandlerStack::create($mock),
],
];
$auth0 = new Auth0(self::$baseConfig + $add_config);
$_GET['code'] = uniqid();
$this
->assertTrue($auth0
->exchange());
$this
->assertEquals($id_token_payload, $auth0
->getUser());
$this
->assertEquals($id_token, $auth0
->getIdToken());
$this
->assertEquals('1.2.3', $auth0
->getAccessToken());
$this
->assertEquals('4.5.6', $auth0
->getRefreshToken());
}