Skip to content

Commit

Permalink
mock the public key
Browse files Browse the repository at this point in the history
  • Loading branch information
ylebre committed Jan 17, 2024
1 parent 7a7a1ed commit 7c2af42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Config/KeysInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Pdsinterop\Solid\Auth\Config;

use Defuse\Crypto\Key as CryptoKey;
use Lcobucci\JWT\Signer\Key\InMemory as Key;
use Lcobucci\JWT\Signer\Key as Key;
use League\OAuth2\Server\CryptKey;

interface KeysInterface
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/TokenGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,22 @@ final public function testIdTokenGenerationWithoutDpopKey(): void
->willReturn('mock issuer')
;

$publicKey = file_get_contents(__DIR__.'/../fixtures/keys/public.key');

$mockPublicKey = $this->getMockBuilder(\Lcobucci\JWT\Signer\Key::class)
->getMock()
;

$mockPublicKey->expects($this->once())
->method('contents')
->willReturn($publicKey)
;

$this->mockKeys->expects($this->once())
->method('getPublicKey')
->willReturn($this->mockPublicKey)
;

$privateKey = file_get_contents(__DIR__.'/../fixtures/keys/private.key');

$now = new \DateTimeImmutable('1234-01-01 12:34:56.789');
Expand All @@ -323,6 +339,7 @@ final public function testIdTokenGenerationWithoutDpopKey(): void
[
'typ' => 'JWT',
'alg' => 'RS256',
'kid' => '0c3932ca20f3a00ad2eb72035f6cc9cb'
],
[
'at_hash' => '1EZBnvsFWlK8ESkgHQsrIQ',
Expand Down

0 comments on commit 7c2af42

Please sign in to comment.