You are here

public function OpenIDConnectTest::dataProviderForCompleteAuthorization in OpenID Connect / OAuth client 2.x

Same name and namespace in other branches
  1. 8 tests/src/Unit/OpenIDConnectTest.php \Drupal\Tests\openid_connect\Unit\OpenIDConnectTest::dataProviderForCompleteAuthorization()

Data provider for the testCompleteAuthorization() method.

Return value

array|array[] Test parameters to pass to testCompleteAuthorization().

File

tests/src/Unit/OpenIDConnectTest.php, line 814

Class

OpenIDConnectTest
Provides tests for the OpenID Connect module.

Namespace

Drupal\Tests\openid_connect\Unit

Code

public function dataProviderForCompleteAuthorization() : array {
  $sub = $this
    ->randomMachineName();
  $user_data = [
    'sub' => $sub,
  ];
  $id_token = implode('.', [
    $this
      ->randomMachineName(),
    base64_encode(Json::encode($user_data)),
    $this
      ->randomMachineName(),
  ]);
  $tokens = [
    "id_token" => $id_token,
    "access_token" => $this
      ->randomMachineName(),
  ];
  return [
    [
      TRUE,
      '',
      [],
      [],
      [],
      FALSE,
      TRUE,
    ],
    [
      FALSE,
      '',
      $tokens,
      $user_data,
      [],
      FALSE,
      TRUE,
    ],
    [
      FALSE,
      '',
      $tokens,
      $user_data,
      [
        'email' => '',
      ],
      FALSE,
      TRUE,
    ],
    [
      FALSE,
      '',
      $tokens,
      $user_data,
      [
        'email' => 'test@test.com',
        'sub' => $sub,
      ],
      FALSE,
      TRUE,
    ],
    [
      FALSE,
      '',
      $tokens,
      $user_data,
      [
        'email' => 'test@test.com',
        'sub' => $sub,
      ],
      TRUE,
      TRUE,
    ],
    [
      FALSE,
      '',
      $tokens,
      $user_data,
      [
        'email' => 'invalid',
        'sub' => $sub,
      ],
      TRUE,
      FALSE,
    ],
    [
      FALSE,
      '',
      $tokens,
      $user_data,
      [
        'email' => 'duplicate@valid.com',
        'sub' => $sub,
      ],
      TRUE,
      FALSE,
    ],
  ];
}