protected function TokenBearerFunctionalTestBase::assertValidTokenResponse in Simple OAuth (OAuth2) & OpenID Connect 8.4
Same name and namespace in other branches
- 8.2 tests/src/Functional/TokenBearerFunctionalTestBase.php \Drupal\Tests\simple_oauth\Functional\TokenBearerFunctionalTestBase::assertValidTokenResponse()
- 8.3 tests/src/Functional/TokenBearerFunctionalTestBase.php \Drupal\Tests\simple_oauth\Functional\TokenBearerFunctionalTestBase::assertValidTokenResponse()
- 5.x tests/src/Functional/TokenBearerFunctionalTestBase.php \Drupal\Tests\simple_oauth\Functional\TokenBearerFunctionalTestBase::assertValidTokenResponse()
Validates a valid token response.
Parameters
\Psr\Http\Message\ResponseInterface $response: The response object.
bool $has_refresh: TRUE if the response should return a refresh token. FALSE otherwise.
Return value
array An array representing the response of "/oauth/token".
7 calls to TokenBearerFunctionalTestBase::assertValidTokenResponse()
- AuthCodeFunctionalTest::testAuthCodeGrant in tests/
src/ Functional/ AuthCodeFunctionalTest.php - Test the valid AuthCode grant.
- AuthCodeFunctionalTest::testClientAuthCodeGrantWithPkce in tests/
src/ Functional/ AuthCodeFunctionalTest.php - Test the AuthCode grant with PKCE.
- AuthCodeFunctionalTest::testNon3rdPartyClientAuthCodeGrant in tests/
src/ Functional/ AuthCodeFunctionalTest.php - Test the valid AuthCode grant if the client is non 3rd party.
- AuthCodeFunctionalTest::testRememberClient in tests/
src/ Functional/ AuthCodeFunctionalTest.php - Tests the remember client functionality.
- ClientCredentialsFunctionalTest::testClientCredentialsGrant in tests/
src/ Functional/ ClientCredentialsFunctionalTest.php - Test the valid ClientCredentials grant.
File
- tests/
src/ Functional/ TokenBearerFunctionalTestBase.php, line 166
Class
- TokenBearerFunctionalTestBase
- Class TokenBearerFunctionalTestBase.
Namespace
Drupal\Tests\simple_oauth\FunctionalCode
protected function assertValidTokenResponse(ResponseInterface $response, $has_refresh = FALSE) {
$this
->assertEquals(200, $response
->getStatusCode());
$parsed_response = Json::decode((string) $response
->getBody());
$this
->assertSame('Bearer', $parsed_response['token_type']);
$expiration = $this
->config('simple_oauth.settings')
->get('access_token_expiration');
$this
->assertLessThanOrEqual($expiration, $parsed_response['expires_in']);
$this
->assertGreaterThanOrEqual($expiration - 10, $parsed_response['expires_in']);
$this
->assertNotEmpty($parsed_response['access_token']);
if ($has_refresh) {
$this
->assertNotEmpty($parsed_response['refresh_token']);
}
else {
$this
->assertFalse(isset($parsed_response['refresh_token']));
}
return $parsed_response;
}