public function OAuth2ServerTestCase::testOpenIdConnectNonDefaultSub in OAuth2 Server 7
Tests that the OpenID Connect 'sub' property affects user info 'sub' claim.
File
- tests/
oauth2_server.test, line 532 - OAuth2 tests.
Class
- OAuth2ServerTestCase
- Test basic API.
Code
public function testOpenIdConnectNonDefaultSub() {
variable_set('oauth2_server_user_sub_property', 'name');
$result = $this
->passwordGrantRequest('openid');
$response = json_decode($result->data);
$access_token = $response->access_token;
$query = array(
'access_token' => $access_token,
);
$info_url = url('oauth2/UserInfo', array(
'absolute' => TRUE,
'query' => $query,
));
$result = $this
->httpRequest($info_url);
$response = json_decode($result->data, TRUE);
$this
->assertEqual($this->loggedInUser->name, $response['sub'], 'The UserInfo "sub" is now the user\'s name.');
}