mirror of
https://github.com/elyby/accounts.git
synced 2024-12-27 23:50:19 +05:30
57d492da8a
* start updating to PHP 8.3
* taking off!
Co-authored-by: ErickSkrauch <erickskrauch@yandex.ru>
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* dropped this
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* migrate to symfonymailer
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* this is so stupid 😭
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* ah, free, at last.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* oh, Gabriel.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* now dawns thy reckoning.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* and thy gore shall GLISTEN before the temples of man.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* creature of steel.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* my gratitude upon thee for my freedom.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* but the crimes thy kind has committed against humanity
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* Upgrade PHP-CS-Fixer and do fix the codebase
* First review round (maybe I have broken something)
* are NOT forgotten.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* Enable parallel PHP-CS-Fixer runner
* PHPStan level 1
* PHPStan level 2
* PHPStan level 3
* PHPStan level 4
* PHPStan level 5
* Levels 6 and 7 takes too much effort. Generate a baseline and fix them eventually
* Resolve TODO's related to the php-mock
* Drastically reduce baseline size with the Rector
* More code modernization with help of the Rector
* Update GitLab CI
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Co-authored-by: ErickSkrauch <erickskrauch@yandex.ru>
50 lines
1.7 KiB
PHP
50 lines
1.7 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace api\tests\unit\components\User;
|
|
|
|
use api\components\User\IdentityFactory;
|
|
use api\components\User\JwtIdentity;
|
|
use api\components\User\LegacyOAuth2Identity;
|
|
use api\tests\unit\TestCase;
|
|
use Carbon\Carbon;
|
|
use common\tests\fixtures;
|
|
use yii\web\UnauthorizedHttpException;
|
|
|
|
class IdentityFactoryTest extends TestCase {
|
|
|
|
public function _fixtures(): array {
|
|
return [
|
|
fixtures\LegacyOauthAccessTokenFixture::class,
|
|
fixtures\LegacyOauthAccessTokenScopeFixture::class,
|
|
];
|
|
}
|
|
|
|
public function testFindIdentityByAccessToken(): void {
|
|
// Find identity by the JWT
|
|
$identity = IdentityFactory::findIdentityByAccessToken('eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJlbHktc2NvcGVzIjoiYWNjb3VudHNfd2ViX3VzZXIiLCJpYXQiOjE1NjQ2MTA1NDIsImV4cCI6MTU2NDYxNDE0Miwic3ViIjoiZWx5fDEifQ.4Oidvuo4spvUf9hkpHR72eeqZUh2Zbxh_L8Od3vcgTj--0iOrcOEp6zwmEW6vF7BTHtjz2b3mXce61bqsCjXjQ');
|
|
$this->assertInstanceOf(JwtIdentity::class, $identity);
|
|
|
|
// Find identity by the legacy OAuth2 token
|
|
$identity = IdentityFactory::findIdentityByAccessToken('ZZQP8sS9urzriy8N9h6FwFNMOH3PkZ5T5PLqS6SX');
|
|
$this->assertInstanceOf(LegacyOAuth2Identity::class, $identity);
|
|
}
|
|
|
|
public function testFindIdentityByAccessTokenWithEmptyValue(): void {
|
|
$this->expectException(UnauthorizedHttpException::class);
|
|
$this->expectExceptionMessage('Incorrect token');
|
|
IdentityFactory::findIdentityByAccessToken('');
|
|
}
|
|
|
|
protected function _setUp() {
|
|
parent::_setUp();
|
|
Carbon::setTestNow(Carbon::create(2019, 8, 1, 1, 2, 22, 'Europe/Minsk'));
|
|
}
|
|
|
|
protected function _tearDown() {
|
|
parent::_tearDown();
|
|
Carbon::setTestNow();
|
|
}
|
|
|
|
}
|