RPDiscoveryWebFingerAcct   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTestId() 0 3 1
A execute() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClient\ConformanceTest\RpTest\Discovery;
6
7
use PHPUnit\Framework\Assert;
8
use Facile\OpenIDClient\ConformanceTest\RpTest\AbstractRpTest;
9
use Facile\OpenIDClient\ConformanceTest\TestInfo;
10
use Facile\OpenIDClient\Issuer\IssuerBuilder;
11
12
/**
13
 * Use WebFinger (RFC7033) and OpenID Provider Issuer Discovery to determine the location of the OpenID Provider.
14
 * The discovery should be done using acct URI syntax as user input identifier
15
 * Note that the local part of the acct value should adhere to the pattern.
16
 *
17
 * An issuer location should be returned.
18
 */
19
class RPDiscoveryWebFingerAcct extends AbstractRpTest
20
{
21
22
    public function getTestId(): string
23
    {
24
        return 'rp-discovery-webfinger-acct';
25
    }
26
27
    public function execute(TestInfo $testInfo): void
28
    {
29
        $parsed = \parse_url($testInfo->getRoot());
30
        $issuerHostAndPort = rtrim($parsed['host'] . ':' . ($parsed['port'] ?? ''), ':');
31
32
        $input = sprintf('acct:%s.%s@%s', $testInfo->getRpId(), $this->getTestId(), $issuerHostAndPort);
33
        $issuer = (new IssuerBuilder())
34
            ->build($input);
35
36
        $expected = sprintf('%s/%s/%s', $testInfo->getRoot(), $testInfo->getRpId(), $this->getTestId());
37
        Assert::assertSame($expected, $issuer->getMetadata()->getIssuer());
38
    }
39
}
40