mirror of
https://github.com/elyby/accounts.git
synced 2024-12-28 16:10:40 +05:30
Add tests for the legacy tokens, fix some tests cases [skip ci]
This commit is contained in:
parent
a148da2ecf
commit
2beacd0827
@ -35,9 +35,9 @@ class TokensFactory {
|
|||||||
public static function createForOAuthClient(AccessTokenEntityInterface $accessToken): Token {
|
public static function createForOAuthClient(AccessTokenEntityInterface $accessToken): Token {
|
||||||
$payloads = [
|
$payloads = [
|
||||||
'aud' => self::buildAud($accessToken->getClient()->getIdentifier()),
|
'aud' => self::buildAud($accessToken->getClient()->getIdentifier()),
|
||||||
'ely-scopes' => array_map(static function(ScopeEntityInterface $scope): string {
|
'ely-scopes' => implode(',', array_map(static function(ScopeEntityInterface $scope): string {
|
||||||
return $scope->getIdentifier();
|
return $scope->getIdentifier();
|
||||||
}, $accessToken->getScopes()),
|
}, $accessToken->getScopes())),
|
||||||
'exp' => $accessToken->getExpiryDateTime()->getTimestamp(),
|
'exp' => $accessToken->getExpiryDateTime()->getTimestamp(),
|
||||||
];
|
];
|
||||||
if ($accessToken->getUserIdentifier() !== null) {
|
if ($accessToken->getUserIdentifier() !== null) {
|
||||||
|
@ -38,14 +38,14 @@ class ClearOauthSessionsTest extends TestCase {
|
|||||||
$task->notSince = 1519510065;
|
$task->notSince = 1519510065;
|
||||||
$task->execute(mock(Queue::class));
|
$task->execute(mock(Queue::class));
|
||||||
|
|
||||||
$this->assertFalse(OauthSession::find()->andWhere(['id' => 3])->exists());
|
$this->assertFalse(OauthSession::find()->andWhere(['legacy_id' => 3])->exists());
|
||||||
$this->assertTrue(OauthSession::find()->andWhere(['id' => 4])->exists());
|
$this->assertTrue(OauthSession::find()->andWhere(['legacy_id' => 4])->exists());
|
||||||
|
|
||||||
$task = new ClearOauthSessions();
|
$task = new ClearOauthSessions();
|
||||||
$task->clientId = 'deleted-oauth-client-with-sessions';
|
$task->clientId = 'deleted-oauth-client-with-sessions';
|
||||||
$task->execute(mock(Queue::class));
|
$task->execute(mock(Queue::class));
|
||||||
|
|
||||||
$this->assertFalse(OauthSession::find()->andWhere(['id' => 4])->exists());
|
$this->assertFalse(OauthSession::find()->andWhere(['legacy_id' => 4])->exists());
|
||||||
|
|
||||||
$task = new ClearOauthSessions();
|
$task = new ClearOauthSessions();
|
||||||
$task->clientId = 'some-not-exists-client-id';
|
$task->clientId = 'some-not-exists-client-id';
|
||||||
|
Loading…
Reference in New Issue
Block a user