Passed
Push — master ( f80f70...56399a )
by Thomas Mauro
03:05 queued 10s
created

RpIdTokenSigEncA128KWTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 35
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 27 1
A getTestId() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClient\ConformanceTest\RpTest\IdToken;
6
7
use Jose\Component\Core\JWK;
8
use Jose\Component\Core\JWKSet;
9
use Jose\Component\KeyManagement\JWKFactory;
10
use PHPUnit\Framework\Assert;
11
use Facile\OpenIDClient\ConformanceTest\RpTest\AbstractRpTest;
12
use Facile\OpenIDClient\ConformanceTest\TestInfo;
13
use Facile\OpenIDClient\Service\AuthorizationService;
14
use function Facile\OpenIDClient\base64url_encode;
15
16
/**
17
 * Request an signed ID Token. Verify the signature on the ID Token using the keys published by the Issuer.
18
 *
19
 * Accept the ID Token after doing ID Token validation.
20
 */
21
class RpIdTokenSigEncA128KWTest extends AbstractRpTest
22
{
23
24
    public function getTestId(): string
25
    {
26
        return 'rp-id_token-sig+enc-a128kw';
27
    }
28
29
    public function execute(TestInfo $testInfo): void
30
    {
31
        $client = $this->registerClient($testInfo, [
32
            'id_token_signed_response_alg' => 'RS256',
33
            'id_token_encrypted_response_alg' => 'A128KW',
34
            'id_token_encrypted_response_enc' => 'A256CBC-HS512',
35
        ]);
36
37
        Assert::assertSame('RS256', $client->getMetadata()->get('id_token_signed_response_alg'));
38
        Assert::assertSame('A128KW', $client->getMetadata()->get('id_token_encrypted_response_alg'));
39
        Assert::assertSame('A256CBC-HS512', $client->getMetadata()->get('id_token_encrypted_response_enc'));
40
41
        // Get authorization redirect uri
42
        $authorizationService = new AuthorizationService();
0 ignored issues
show
Bug introduced by
The call to Facile\OpenIDClient\Serv...nService::__construct() has too few arguments starting with tokenSetFactory. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        $authorizationService = /** @scrutinizer ignore-call */ new AuthorizationService();

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.

Loading history...
43
        $uri = $authorizationService->getAuthorizationUri($client, [
44
            'response_type' => $testInfo->getResponseType(),
45
            'nonce' => base64url_encode(\random_bytes(32)),
46
        ]);
47
48
        // Simulate a redirect and create the server request
49
        $serverRequest = $this->simulateAuthRedirect($uri);
50
        $params = $authorizationService->getCallbackParams($serverRequest, $client);
51
52
        $tokenSet = $authorizationService->callback($client, $params);
53
54
        Assert::assertNotNull($tokenSet->getIdToken());
55
        Assert::arrayHasKey('email', $tokenSet->claims());
0 ignored issues
show
Unused Code introduced by
The call to PHPUnit\Framework\Assert::arrayHasKey() has too many arguments starting with $tokenSet->claims(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
        Assert::/** @scrutinizer ignore-call */ 
56
                arrayHasKey('email', $tokenSet->claims());

This check compares calls to functions or methods with their respective definitions. If the call has more 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.

Loading history...
56
    }
57
}
58