OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
firebase
/
vendor
/
kreait
/
firebase-php
/
tests
/
Integration
/
Auth
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
๐
..
-
08/12/2024 10:35:40 AM
rwxr-xr-x
๐
CustomTokenViaGoogleIamTest.php
2.08 KB
08/12/2024 10:35:40 AM
rw-r--r--
Editing: CustomTokenViaGoogleIamTest.php
Close
<?php declare(strict_types=1); namespace Kreait\Firebase\Tests\Integration\Auth; use Kreait\Firebase\Auth\CustomTokenViaGoogleIam; use Kreait\Firebase\Auth\TenantId; use Kreait\Firebase\Exception\AuthException; use Kreait\Firebase\Tests\IntegrationTestCase; use Lcobucci\JWT\Token\Plain; use PHPUnit\Framework\AssertionFailedError; use Throwable; /** * @internal */ final class CustomTokenViaGoogleIamTest extends IntegrationTestCase { private CustomTokenViaGoogleIam $generator; protected function setUp(): void { $this->generator = new CustomTokenViaGoogleIam( self::$serviceAccount->getClientEmail(), self::$factory->createApiClient() ); } public function testCreateCustomToken(): void { $this->generator->createCustomToken('some-uid', ['a-claim' => 'a-value']); $this->addToAssertionCount(1); } public function testCreateCustomTokenWithAnInvalidClientEmail(): void { $generator = new CustomTokenViaGoogleIam(self::randomEmail(__FUNCTION__), self::$factory->createApiClient()); try { $generator->createCustomToken('some-uid', ['kid' => '$&ยง']); $this->fail('An exception should have been thrown'); } catch (AuthException $e) { $this->addToAssertionCount(1); } catch (AssertionFailedError $e) { $this->fail($e->getMessage()); } catch (Throwable $e) { $this->fail('An '.AuthException::class.' should have been thrown'); } } public function testCreateCustomTokenWithATenantId(): void { $generator = new CustomTokenViaGoogleIam( self::$serviceAccount->getClientEmail(), self::$factory->createApiClient(), TenantId::fromString($tenantId = IntegrationTestCase::TENANT_ID) ); $customToken = $generator->createCustomToken('some-uid'); $this->assertInstanceOf(Plain::class, $customToken); $this->assertSame($tenantId, $customToken->claims()->get('tenantId')); } }