You are here

public function TokenTest::testDeprecatedTestTokenGenerationDecode in Auth0 Single Sign On 8.2

Test the deprecated Auth0JWT::decode() method.

Return value

void

File

vendor/auth0/auth0-php/tests/API/Helpers/TokenGeneratorTest.php, line 431

Class

TokenTest
Class TokenTest

Namespace

Auth0\Tests\Api\Helpers

Code

public function testDeprecatedTestTokenGenerationDecode() {
  $token_generator = new TokenGenerator(self::CLIENT_ID, self::CLIENT_SECRET);
  $jwt = $token_generator
    ->generate([
    'users' => [
      'actions' => [
        'read',
      ],
    ],
  ]);
  $decoded = Auth0JWT::decode($jwt, self::CLIENT_ID, self::CLIENT_SECRET);
  $this
    ->assertObjectHasAttribute('aud', $decoded);
  $this
    ->assertEquals(self::CLIENT_ID, $decoded->aud);
  $this
    ->assertObjectHasAttribute('scopes', $decoded);
  $this
    ->assertObjectHasAttribute('users', $decoded->scopes);
  $this
    ->assertObjectHasAttribute('actions', $decoded->scopes->users);
  $this
    ->assertArraySubset([
    'read',
  ], $decoded->scopes->users->actions);
}