DerivedKeyTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testDerivedKey() 0 5 1
A valuesProvider() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClientTest\functions;
6
7
use function Facile\OpenIDClient\derived_key;
8
use Facile\OpenIDClientTest\TestCase;
9
10
class DerivedKeyTest extends TestCase
11
{
12
    /**
13
     * @dataProvider valuesProvider
14
     *
15
     * @param string $secret
16
     * @param int $length
17
     * @param string $expected
18
     */
19
    public function testDerivedKey(string $secret, int $length, string $expected): void
20
    {
21
        $jwk = derived_key($secret, $length);
22
        static::assertSame('oct', $jwk->get('kty'));
23
        static::assertSame($expected, $jwk->get('k'));
24
    }
25
26
    public function valuesProvider(): array
27
    {
28
        $string = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
29
30
        return [
31
            [$string, 128, 'zwBxoIOtPkc0nS4_vIltBw'],
32
            [$string, 192, 'zwBxoIOtPkc0nS4_vIltB6DVBYCzNcN-'],
33
            [$string, 256, 'zwBxoIOtPkc0nS4_vIltB6DVBYCzNcN-OX1Akb-OcTs'],
34
            [$string, 384, 'zwBxoIOtPkc0nS4_vIltB6DVBYCzNcN-OX1Akb-OcTs'],
35
        ];
36
    }
37
}
38