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

RPDiscoveryIssuerNotMatchingConfig   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 20
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 12 2
A getTestId() 0 3 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 PHPUnit\Framework\AssertionFailedError;
9
use Facile\OpenIDClient\ConformanceTest\RpTest\AbstractRpTest;
10
use Facile\OpenIDClient\ConformanceTest\TestInfo;
11
use Facile\OpenIDClient\Issuer\IssuerBuilder;
12
13
/**
14
 * Retrieve OpenID Provider Configuration Information for OpenID Provider from the .well-known/openid-configuration path.
15
 * Verify that the issuer in the provider configuration matches the one returned by WebFinger.
16
 *
17
 * Identify that the issuers are not matching and reject the provider configuration.
18
 */
19
class RPDiscoveryIssuerNotMatchingConfig extends AbstractRpTest
20
{
21
22
    public function getTestId(): string
23
    {
24
        return 'rp-discovery-issuer-not-matching-config';
25
    }
26
27
    public function execute(TestInfo $testInfo): void
28
    {
29
        $input = $testInfo->getRoot() . '/' . $testInfo->getRpId() . '/' . $this->getTestId() . '/joe';
30
31
        try {
32
            $issuer = (new IssuerBuilder())
0 ignored issues
show
Unused Code introduced by
The assignment to $issuer is dead and can be removed.
Loading history...
33
                ->build($input);
34
35
            throw new AssertionFailedError('No assertions');
36
        } catch (\Throwable $e) {
37
            Assert::assertSame('Unable to fetch issuer metadata', $e->getMessage());
38
            Assert::assertRegExp('/Discovered issuer mismatch/', $e->getPrevious()->getMessage());
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertRegExp() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/4086 ( Ignorable by Annotation )

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

38
            /** @scrutinizer ignore-deprecated */ Assert::assertRegExp('/Discovered issuer mismatch/', $e->getPrevious()->getMessage());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
39
        }
40
    }
41
}
42