DerivedKeyTest::valuesProvider()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
rs 10
c 1
b 0
f 0
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