From 2beacd08279e0a5d1bb110757f6862574defabea Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Mon, 23 Sep 2019 01:03:36 +0300 Subject: [PATCH] Add tests for the legacy tokens, fix some tests cases [skip ci] --- api/components/Tokens/TokensFactory.php | 4 ++-- common/tests/unit/tasks/ClearOauthSessionsTest.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/components/Tokens/TokensFactory.php b/api/components/Tokens/TokensFactory.php index 992c909..2af8142 100644 --- a/api/components/Tokens/TokensFactory.php +++ b/api/components/Tokens/TokensFactory.php @@ -35,9 +35,9 @@ class TokensFactory { public static function createForOAuthClient(AccessTokenEntityInterface $accessToken): Token { $payloads = [ '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(); - }, $accessToken->getScopes()), + }, $accessToken->getScopes())), 'exp' => $accessToken->getExpiryDateTime()->getTimestamp(), ]; if ($accessToken->getUserIdentifier() !== null) { diff --git a/common/tests/unit/tasks/ClearOauthSessionsTest.php b/common/tests/unit/tasks/ClearOauthSessionsTest.php index e962ba5..3246867 100644 --- a/common/tests/unit/tasks/ClearOauthSessionsTest.php +++ b/common/tests/unit/tasks/ClearOauthSessionsTest.php @@ -38,14 +38,14 @@ class ClearOauthSessionsTest extends TestCase { $task->notSince = 1519510065; $task->execute(mock(Queue::class)); - $this->assertFalse(OauthSession::find()->andWhere(['id' => 3])->exists()); - $this->assertTrue(OauthSession::find()->andWhere(['id' => 4])->exists()); + $this->assertFalse(OauthSession::find()->andWhere(['legacy_id' => 3])->exists()); + $this->assertTrue(OauthSession::find()->andWhere(['legacy_id' => 4])->exists()); $task = new ClearOauthSessions(); $task->clientId = 'deleted-oauth-client-with-sessions'; $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->clientId = 'some-not-exists-client-id';