1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Facile\OpenIDClient\ConformanceTest\RpTest\IdToken; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\Assert; |
8
|
|
|
use Facile\OpenIDClient\ConformanceTest\RpTest\AbstractRpTest; |
9
|
|
|
use Facile\OpenIDClient\ConformanceTest\TestInfo; |
10
|
|
|
use Facile\OpenIDClient\Service\AuthorizationService; |
11
|
|
|
use function Facile\OpenIDClient\base64url_encode; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Request an signed ID Token. Verify the signature on the ID Token using the keys published by the Issuer. |
15
|
|
|
* |
16
|
|
|
* Accept the ID Token after doing ID Token validation. |
17
|
|
|
*/ |
18
|
|
|
class RpIdTokenSigRS256Test extends AbstractRpTest |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
public function getTestId(): string |
22
|
|
|
{ |
23
|
|
|
return 'rp-id_token-sig-rs256'; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function execute(TestInfo $testInfo): void |
27
|
|
|
{ |
28
|
|
|
$client = $this->registerClient($testInfo, ['id_token_signed_response_alg' => 'RS256']); |
29
|
|
|
|
30
|
|
|
Assert::assertSame('RS256', $client->getMetadata()->get('id_token_signed_response_alg')); |
31
|
|
|
|
32
|
|
|
// Get authorization redirect uri |
33
|
|
|
$authorizationService = new AuthorizationService(); |
|
|
|
|
34
|
|
|
$uri = $authorizationService->getAuthorizationUri($client, [ |
35
|
|
|
'response_type' => $testInfo->getResponseType(), |
36
|
|
|
'nonce' => base64url_encode(\random_bytes(32)), |
37
|
|
|
]); |
38
|
|
|
|
39
|
|
|
// Simulate a redirect and create the server request |
40
|
|
|
$serverRequest = $this->simulateAuthRedirect($uri); |
41
|
|
|
$params = $authorizationService->getCallbackParams($serverRequest, $client); |
42
|
|
|
|
43
|
|
|
$tokenSet = $authorizationService->callback($client, $params); |
44
|
|
|
|
45
|
|
|
Assert::assertNotNull($tokenSet->getIdToken()); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
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.