You are here

protected function OAuth2ServerTestCase::authorizationCodeRequest in OAuth2 Server 7

Performs an authorization request and returns it.

Used to test authorization, the implicit flow, and the authorization_code grant type.

Return value

The return value of $this->httpRequest().

6 calls to OAuth2ServerTestCase::authorizationCodeRequest()
OAuth2ServerTestCase::testAuthorization in tests/oauth2_server.test
Tests the authorization part of the flow.
OAuth2ServerTestCase::testAuthorizationCodeGrantType in tests/oauth2_server.test
Tests the "Authorization code" grant type.
OAuth2ServerTestCase::testImplicitFlow in tests/oauth2_server.test
Tests the implicit flow.
OAuth2ServerTestCase::testOpenIdConnectAuthorizationCodeFlow in tests/oauth2_server.test
Tests the OpenID Connect authorization code flow.
OAuth2ServerTestCase::testOpenIdConnectImplicitFlow in tests/oauth2_server.test
Tests the OpenID Connect implicit flow.

... See full list

File

tests/oauth2_server.test, line 162
OAuth2 tests.

Class

OAuth2ServerTestCase
Test basic API.

Code

protected function authorizationCodeRequest($response_type, $scope = NULL) {
  $query = array(
    'response_type' => $response_type,
    'client_id' => $this->client_key,
    'state' => drupal_get_token($this->client_key),
    // The "authorized" url doesn't actually exist, but we don't need it.
    'redirect_uri' => url('authorized', array(
      'absolute' => TRUE,
    )),
    // OpenID Connect requests require a nonce. Others ignore it.
    'nonce' => 'test',
  );
  if ($scope) {
    $query['scope'] = $scope;
  }
  $authorize_url = url('oauth2/authorize', array(
    'absolute' => TRUE,
    'query' => $query,
  ));
  return $this
    ->httpRequest($authorize_url);
}