public function OAuth2ServerTest::testOpenIdConnectNonDefaultSub in OAuth2 Server 2.0.x
Same name and namespace in other branches
- 8 tests/src/Functional/OAuth2ServerTest.php \Drupal\Tests\oauth2_server\Functional\OAuth2ServerTest::testOpenIdConnectNonDefaultSub()
Tests that the OpenID Connect 'sub' property affects user info 'sub' claim.
File
- tests/
src/ Functional/ OAuth2ServerTest.php, line 481
Class
- OAuth2ServerTest
- The OAuth2 Server admin test case.
Namespace
Drupal\Tests\oauth2_server\FunctionalCode
public function testOpenIdConnectNonDefaultSub() {
$this
->config('oauth2_server.oauth')
->set('user_sub_property', 'name')
->save();
$response = $this
->passwordGrantRequest('openid');
$payload = json_decode($response
->getBody());
$access_token = $payload->access_token;
$query = [
'access_token' => $access_token,
];
$info_url = $this
->buildUrl(new Url('oauth2_server.userinfo'), [
'query' => $query,
]);
$response = $this
->httpGetRequest($info_url);
$payload = json_decode($response
->getBody(), TRUE);
$this
->assertEqual($this->loggedInUser->name->value, $payload['sub'], 'The UserInfo "sub" is now the user\'s name.');
}