Passed
Push — issue#777 ( da3d73...d2ae13 )
by Guilherme
05:16
created

ClientMetadataTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 56
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testEntity() 0 54 1
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\OpenIDBundle\Tests\Entity;
12
13
use Doctrine\Common\Collections\ArrayCollection;
14
use LoginCidadao\CoreBundle\Entity\Person;
15
use LoginCidadao\OAuthBundle\Entity\Client;
16
use LoginCidadao\OpenIDBundle\Entity\ClientMetadata;
17
18
class ClientMetadataTest extends \PHPUnit_Framework_TestCase
19
{
20
    public function testEntity()
21
    {
22
        $client = new Client();
23
        $client->getOwners()->add((new Person())->setEmail('[email protected]'));
24
25
        /** @var ClientMetadata $metadata */
26
        $metadata = (new ClientMetadata())
27
            ->setId($id = 'my id')
28
            ->setClientId($clientId = 'the.client.id')
29
            ->setClientSecret($clientSecret = 'super secret')
30
            ->setClient($client)
31
            ->setRedirectUris($uris = ['https://example.com/'])
32
            ->setContacts($contacts = ['[email protected]'])
33
            ->setLogoUri($logoUri = 'https://example.com/mylogo.png')
34
            ->setClientUri($clientUri = 'https://example.com')
35
            ->setPolicyUri($policyUri = 'https://example.com/policy')
36
            ->setTosUri($tosUri = 'https://example.com/tos')
37
            ->setJwksUri($jwksUri = 'https://example.com/jwks')
38
            ->setJwks($jwks = 'something')
39
            ->setSectorIdentifierUri($sectorIdentifierUri = 'https://example.com/sector')
40
            ->setIdTokenEncryptedResponseAlg('ALG')
41
            ->setIdTokenEncryptedResponseEnc('ENC')
42
            ->setUserinfoSignedResponseAlg('ALG')
43
            ->setUserinfoEncryptedResponseAlg('ALG')
44
            ->setUserinfoEncryptedResponseEnc('ENC')
45
            ->setRequestObjectSigningAlg('ALG')
46
            ->setRequestObjectEncryptionAlg('ALG')
47
            ->setRequestObjectEncryptionEnc('ENC')
48
            ->setTokenEndpointAuthSigningAlg('ALG')
49
            ->setDefaultMaxAge(12345)
50
            ->setDefaultAcrValues([])
51
            ->setInitiateLoginUri($loginUri = 'https://example.com/login')
52
            ->setRegistrationAccessToken($regAccessToken = 'accessToken')
53
            ->setPostLogoutRedirectUris($uris);
54
        $metadata->checkDefaults();
55
56
        $this->assertSame($clientId, $metadata->getClientId());
57
        $this->assertSame($clientSecret, $metadata->getClientSecret());
58
        $this->assertSame($client, $metadata->getClient());
59
        $this->assertSame($uris, $metadata->getRedirectUris());
60
        $this->assertContains('[email protected]', $metadata->getContacts());
61
        $this->assertSame($logoUri, $metadata->getLogoUri());
62
        $this->assertSame($clientUri, $metadata->getClientUri());
63
        $this->assertSame($policyUri, $metadata->getPolicyUri());
64
        $this->assertSame($tosUri, $metadata->getTosUri());
65
        $this->assertSame($jwksUri, $metadata->getJwksUri());
66
        $this->assertSame($jwks, $metadata->getJwks());
67
        $this->assertSame($sectorIdentifierUri, $metadata->getSectorIdentifierUri());
68
        $this->assertSame(12345, $metadata->getDefaultMaxAge());
69
        $this->assertSame($loginUri, $metadata->getInitiateLoginUri());
70
        $this->assertSame($regAccessToken, $metadata->getRegistrationAccessToken());
71
        $this->assertSame($uris, $metadata->getPostLogoutRedirectUris());
72
        $this->assertSame('pairwise', $metadata->getSubjectType());
73
        $this->assertSame('example.com', $metadata->getSectorIdentifier());
74
    }
75
}
76