aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/bshaffer/oauth2-server-php/test/OAuth2/OpenID/Storage/UserClaimsTest.php
blob: 840f6c566fb176b215cab34f55b123fc1a263018 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

namespace OAuth2\OpenID\Storage;

use OAuth2\Storage\BaseTest;
use OAuth2\Storage\NullStorage;

class UserClaimsTest extends BaseTest
{
    /** @dataProvider provideStorage */
    public function testGetUserClaims($storage)
    {
        if ($storage instanceof NullStorage) {
            $this->markTestSkipped('Skipped Storage: ' . $storage->getMessage());

            return;
        }

        if (!$storage instanceof UserClaimsInterface) {
            // incompatible storage
            return;
        }

        // invalid user
        $claims = $storage->getUserClaims('fake-user', '');
        $this->assertFalse($claims);

        // valid user (no scope)
        $claims = $storage->getUserClaims('testuser', '');

        /* assert the decoded token is the same */
        $this->assertFalse(isset($claims['email']));

        // valid user
        $claims = $storage->getUserClaims('testuser', 'email');

        /* assert the decoded token is the same */
        $this->assertEquals($claims['email'], "testuser@test.com");
        $this->assertEquals($claims['email_verified'], true);
    }
}