Skip to content

Commit 7c2af42

Browse files
committed
mock the public key
1 parent 7a7a1ed commit 7c2af42

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Config/KeysInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Pdsinterop\Solid\Auth\Config;
44

55
use Defuse\Crypto\Key as CryptoKey;
6-
use Lcobucci\JWT\Signer\Key\InMemory as Key;
6+
use Lcobucci\JWT\Signer\Key as Key;
77
use League\OAuth2\Server\CryptKey;
88

99
interface KeysInterface

tests/unit/TokenGeneratorTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,22 @@ final public function testIdTokenGenerationWithoutDpopKey(): void
305305
->willReturn('mock issuer')
306306
;
307307

308+
$publicKey = file_get_contents(__DIR__.'/../fixtures/keys/public.key');
309+
310+
$mockPublicKey = $this->getMockBuilder(\Lcobucci\JWT\Signer\Key::class)
311+
->getMock()
312+
;
313+
314+
$mockPublicKey->expects($this->once())
315+
->method('contents')
316+
->willReturn($publicKey)
317+
;
318+
319+
$this->mockKeys->expects($this->once())
320+
->method('getPublicKey')
321+
->willReturn($this->mockPublicKey)
322+
;
323+
308324
$privateKey = file_get_contents(__DIR__.'/../fixtures/keys/private.key');
309325

310326
$now = new \DateTimeImmutable('1234-01-01 12:34:56.789');
@@ -323,6 +339,7 @@ final public function testIdTokenGenerationWithoutDpopKey(): void
323339
[
324340
'typ' => 'JWT',
325341
'alg' => 'RS256',
342+
'kid' => '0c3932ca20f3a00ad2eb72035f6cc9cb'
326343
],
327344
[
328345
'at_hash' => '1EZBnvsFWlK8ESkgHQsrIQ',

0 commit comments

Comments
 (0)