Passed
Push — master ( f75ef5...782b7a )
by Matthieu
05:01
created

AbstractWebTestCase::getTenantJWTCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AtlassianConnectBundle\Tests\Functional;
6
7
use AtlassianConnectBundle\Service\QSHGenerator;
8
use Firebase\JWT\JWT;
9
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
10
use Symfony\Component\DependencyInjection\ContainerInterface;
11
12
abstract class AbstractWebTestCase extends WebTestCase
13
{
14
    public static function getParentContainer(): ContainerInterface
15
    {
16
        if (method_exists(self::class, 'getContainer')) {
17
            return self::getContainer();
18
        }
19
20
        return self::$container;
21
    }
22
23
    protected static function getKernelClass(): string
24
    {
25
        return App\Kernel::class;
26
    }
27
28
    public function getTenantJWTCode(string $iss = 'client_key'): string
29
    {
30
        return JWT::encode([
31
            'iss' => $iss,
32
            'iat' => time(),
33
            'exp' => strtotime('+1 day'),
34
            'qsh' => QSHGenerator::generate('/protected_route', 'GET'),
35
            'sub' => 'admin',
36
        ], 'shared_secret');
37
    }
38
}
39