You are here

protected function LTIAuthTest::request in LTI Tool Provider 2.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/LTIAuthTest.php \Drupal\Tests\lti_tool_provider\Functional\LTIAuthTest::request()

Performs a HTTP request. Wraps the Guzzle HTTP client.

Why wrap the Guzzle HTTP client? Because we want to keep the actual test code as simple as possible, and hence not require them to specify the 'http_errors = FALSE' request option, nor do we want them to have to convert Drupal Url objects to strings.

We also don't want to follow redirects automatically, to ensure these tests are able to detect when redirects are added or removed.

Parameters

string $method: HTTP method.

Url $url: URL to request.

array $request_options: Request options to apply.

Return value

ResponseInterface The response.

Throws

Exception

See also

\GuzzleHttp\ClientInterface::request()

6 calls to LTIAuthTest::request()
LTIAuthTest::testDuplicateNonce in tests/src/Functional/LTIAuthTest.php
Test authentication with duplicate nonce.
LTIAuthTest::testMissingOauthSignature in tests/src/Functional/LTIAuthTest.php
Test authentication with a missing signature.
LTIAuthTest::testOutdatedTimestamp in tests/src/Functional/LTIAuthTest.php
Test authentication with outdated timestamp.
LTIAuthTest::testSuccessfulAuthenticationExistingUser in tests/src/Functional/LTIAuthTest.php
Test successful authentication with existing user.
LTIAuthTest::testSuccessfulAuthenticationLtiUser in tests/src/Functional/LTIAuthTest.php
Test successful authentication with ltiuser (no email).

... See full list

File

tests/src/Functional/LTIAuthTest.php, line 123

Class

LTIAuthTest
Functional tests for LTI authentication.

Namespace

Drupal\Tests\lti_tool_provider\Functional

Code

protected function request(string $method, Url $url, array $request_options) : ResponseInterface {
  $request_options[RequestOptions::HTTP_ERRORS] = FALSE;

  // $request_options[RequestOptions::ALLOW_REDIRECTS] = FALSE;.
  $request_options = $this
    ->decorateWithXdebugCookie($request_options);
  $driver = $this
    ->getSession()
    ->getDriver();
  if ($driver instanceof GoutteDriver) {
    return $driver
      ->getClient()
      ->getClient()
      ->request($method, $url
      ->setAbsolute(TRUE)
      ->toString(), $request_options);
  }
  throw new Exception('Goutte driver missing.');
}