1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Facile\OpenIDClient\ConformanceTest\RpTest\ClaimsTypes; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\Assert; |
8
|
|
|
use Facile\OpenIDClient\Claims\DistributedParser; |
9
|
|
|
use Facile\OpenIDClient\ConformanceTest\RpTest\AbstractRpTest; |
10
|
|
|
use Facile\OpenIDClient\ConformanceTest\TestInfo; |
11
|
|
|
use Facile\OpenIDClient\Session\AuthSession; |
12
|
|
|
use Facile\OpenIDClient\Service\AuthorizationService; |
13
|
|
|
use Facile\OpenIDClient\Service\UserInfoService; |
14
|
|
|
use function Facile\OpenIDClient\base64url_encode; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Make a UserInfo Request and read the Distributed Claims. |
18
|
|
|
* |
19
|
|
|
* Understand the distributed claims in the UserInfo Response. |
20
|
|
|
*/ |
21
|
|
|
class RPClaimsDistributedTest extends AbstractRpTest |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
public function getTestId(): string |
25
|
|
|
{ |
26
|
|
|
return 'rp-claims-distributed'; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function execute(TestInfo $testInfo): void |
30
|
|
|
{ |
31
|
|
|
$client = $this->registerClient($testInfo); |
32
|
|
|
|
33
|
|
|
$authorizationService = new AuthorizationService(); |
|
|
|
|
34
|
|
|
$userInfoService = new UserInfoService(); |
|
|
|
|
35
|
|
|
$distributedClaims = new DistributedParser(); |
36
|
|
|
|
37
|
|
|
$authSession = AuthSession::fromArray([ |
38
|
|
|
'nonce' => base64url_encode(\random_bytes(32)), |
39
|
|
|
]); |
40
|
|
|
$uri = $authorizationService->getAuthorizationUri($client, [ |
41
|
|
|
'response_type' => $testInfo->getResponseType(), |
42
|
|
|
'nonce' => $authSession->getNonce(), |
43
|
|
|
]); |
44
|
|
|
|
45
|
|
|
// Simulate a redirect and create the server request |
46
|
|
|
$serverRequest = $this->simulateAuthRedirect($uri); |
47
|
|
|
|
48
|
|
|
$params = $authorizationService->getCallbackParams($serverRequest, $client); |
49
|
|
|
$tokenSet = $authorizationService->callback($client, $params, null, $authSession); |
50
|
|
|
|
51
|
|
|
$userInfo = $userInfoService->getUserInfo($client, $tokenSet); |
52
|
|
|
$distributed = $distributedClaims->fetch($client, $userInfo); |
53
|
|
|
|
54
|
|
|
Assert::assertArrayHasKey('age', $distributed); |
55
|
|
|
Assert::assertSame(30, $distributed['age']); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.