OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
firebase
/
vendor
/
kreait
/
firebase-tokens
/
tests
/
JWT
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/12/2024 10:36:29 AM
rwxr-xr-x
📁
Action
-
08/12/2024 10:36:30 AM
rwxr-xr-x
📁
Cache
-
08/12/2024 10:35:47 AM
rwxr-xr-x
📄
CustomTokenGeneratorTest.php
2.42 KB
08/12/2024 10:34:15 AM
rw-r--r--
📄
GooglePublicKeysTest.php
2.27 KB
08/12/2024 10:34:15 AM
rw-r--r--
📄
IdTokenVerifierTest.php
2.17 KB
08/12/2024 10:34:15 AM
rw-r--r--
📁
Util
-
08/12/2024 10:35:47 AM
rwxr-xr-x
📁
Value
-
08/12/2024 10:35:47 AM
rwxr-xr-x
Editing: GooglePublicKeysTest.php
Close
<?php declare(strict_types=1); namespace Kreait\Firebase\JWT\Tests; use DateInterval; use DateTimeImmutable; use Kreait\Clock\FrozenClock; use Kreait\Firebase\JWT\Action\FetchGooglePublicKeys\Handler; use Kreait\Firebase\JWT\GooglePublicKeys; use Kreait\Firebase\JWT\Keys\ExpiringKeys; use Kreait\Firebase\JWT\Keys\StaticKeys; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; /** * @internal */ final class GooglePublicKeysTest extends TestCase { /** @var Handler|MockObject */ private $handler; private FrozenClock $clock; private GooglePublicKeys $keys; private ExpiringKeys $expiringResult; private StaticKeys $staticResult; protected function setUp(): void { $now = new DateTimeImmutable(); $now = $now->setTimestamp($now->getTimestamp()); // Trim microseconds, just to be sure $this->clock = new FrozenClock($now); $this->handler = $this->createMock(Handler::class); $this->expiringResult = ExpiringKeys::withValuesAndExpirationTime(['ir' => 'relevant'], $this->clock->now()->modify('+1 hour')); $this->staticResult = StaticKeys::withValues(['ir' => 'relevant']); $this->keys = new GooglePublicKeys($this->handler, $this->clock); } public function testItFetchesKeysOnlyTheFirstTime(): void { $this->handler->expects($this->once())->method('handle')->willReturn($this->expiringResult); $this->assertSame($this->expiringResult->all(), $this->keys->all()); $this->assertSame($this->expiringResult->all(), $this->keys->all()); } public function testItReFetchesKeysWhenTheyAreExpired(): void { $this->handler->expects($this->exactly(2))->method('handle')->willReturn($this->expiringResult); $this->keys->all(); $this->clock->setTo($this->clock->now()->add(new DateInterval('PT2H'))); $this->keys->all(); } public function testItUsesNonExpiringKeysForever(): void { $this->handler->expects($this->once())->method('handle')->willReturn($this->staticResult); $this->assertSame($this->staticResult->all(), $this->keys->all()); $this->assertSame($this->staticResult->all(), $this->keys->all()); } }