1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Facile\OpenIDClient\ConformanceTest\RpTest\ResponseTypeAndResponseMode; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\Assert; |
8
|
|
|
use Facile\OpenIDClient\ConformanceTest\RpTest\AbstractRpTest; |
9
|
|
|
use Facile\OpenIDClient\ConformanceTest\TestInfo; |
10
|
|
|
use Facile\OpenIDClient\Session\AuthSession; |
11
|
|
|
use Facile\OpenIDClient\Service\AuthorizationService; |
12
|
|
|
use function Facile\OpenIDClient\base64url_encode; |
13
|
|
|
|
14
|
|
|
class RPResponseTypeIdTokenTokenTest extends AbstractRpTest |
15
|
|
|
{ |
16
|
|
|
public function getTestId(): string |
17
|
|
|
{ |
18
|
|
|
return 'rp-response_type-id_token+token'; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function execute(TestInfo $testInfo): void |
22
|
|
|
{ |
23
|
|
|
$client = $this->registerClient($testInfo); |
24
|
|
|
|
25
|
|
|
Assert::assertSame('id_token token', $testInfo->getResponseType()); |
26
|
|
|
|
27
|
|
|
// Get authorization redirect uri |
28
|
|
|
$authorizationService = new AuthorizationService(); |
|
|
|
|
29
|
|
|
|
30
|
|
|
$authSession = AuthSession::fromArray([ |
31
|
|
|
'nonce' => base64url_encode(\random_bytes(32)), |
32
|
|
|
]); |
33
|
|
|
$uri = $authorizationService->getAuthorizationUri($client, [ |
34
|
|
|
'response_type' => $testInfo->getResponseType(), |
35
|
|
|
'nonce' => $authSession->getNonce(), |
36
|
|
|
]); |
37
|
|
|
|
38
|
|
|
// Simulate a redirect and create the server request |
39
|
|
|
$serverRequest = $this->simulateAuthRedirect($uri); |
40
|
|
|
|
41
|
|
|
$params = $authorizationService->getCallbackParams($serverRequest, $client); |
42
|
|
|
Assert::assertArrayHasKey('id_token', $params); |
43
|
|
|
Assert::assertArrayHasKey('access_token', $params); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
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.