You are here

protected function AuthCodeFunctionalTest::getAndValidateCodeFromResponse in Simple OAuth (OAuth2) & OpenID Connect 8.4

Same name and namespace in other branches
  1. 5.x tests/src/Functional/AuthCodeFunctionalTest.php \Drupal\Tests\simple_oauth\Functional\AuthCodeFunctionalTest::getAndValidateCodeFromResponse()

Get the code in the response after granting access to scopes.

Return value

mixed The code.

Throws

\Behat\Mink\Exception\ExpectationException

4 calls to AuthCodeFunctionalTest::getAndValidateCodeFromResponse()
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.

File

tests/src/Functional/AuthCodeFunctionalTest.php, line 316

Class

AuthCodeFunctionalTest
The auth code test.

Namespace

Drupal\Tests\simple_oauth\Functional

Code

protected function getAndValidateCodeFromResponse() {
  $assert_session = $this
    ->assertSession();
  $session = $this
    ->getSession();
  $assert_session
    ->statusCodeEquals(200);
  $parsed_url = parse_url($session
    ->getCurrentUrl());
  $parsed_query = \GuzzleHttp\Psr7\parse_query($parsed_url['query']);
  $this
    ->assertArrayHasKey('code', $parsed_query);
  return $parsed_query['code'];
}