From 22982b319b36aa097eb96423d92122f2f44b754b Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Tue, 24 Sep 2019 01:56:32 +0300 Subject: [PATCH] Fix all tests --- .../OAuth2/Repositories/InternalScopeRepository.php | 9 +++++++++ api/tests/functional/_steps/OauthSteps.php | 2 +- api/tests/unit/models/authentication/LoginFormTest.php | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/api/components/OAuth2/Repositories/InternalScopeRepository.php b/api/components/OAuth2/Repositories/InternalScopeRepository.php index ef0ca87..c5f46d6 100644 --- a/api/components/OAuth2/Repositories/InternalScopeRepository.php +++ b/api/components/OAuth2/Repositories/InternalScopeRepository.php @@ -22,7 +22,12 @@ class InternalScopeRepository implements ScopeRepositoryInterface { P::ESCAPE_IDENTITY_VERIFICATION, ]; + private const PUBLIC_SCOPES_TO_INTERNAL_PERMISSIONS = [ + 'internal_account_info' => P::OBTAIN_EXTENDED_ACCOUNT_INFO, + ]; + public function getScopeEntityByIdentifier($identifier): ?ScopeEntityInterface { + $identifier = $this->convertToInternalPermission($identifier); if (!in_array($identifier, self::ALLOWED_SCOPES, true)) { return null; } @@ -51,4 +56,8 @@ class InternalScopeRepository implements ScopeRepositoryInterface { return $scopes; } + private function convertToInternalPermission(string $publicScope): string { + return self::PUBLIC_SCOPES_TO_INTERNAL_PERMISSIONS[$publicScope] ?? $publicScope; + } + } diff --git a/api/tests/functional/_steps/OauthSteps.php b/api/tests/functional/_steps/OauthSteps.php index 8d7d2bd..c6cffc4 100644 --- a/api/tests/functional/_steps/OauthSteps.php +++ b/api/tests/functional/_steps/OauthSteps.php @@ -54,7 +54,7 @@ class OauthSteps extends FunctionalTester { 'grant_type' => 'client_credentials', 'client_id' => $useTrusted ? 'trusted-client' : 'default-client', 'client_secret' => $useTrusted ? 'tXBbyvMcyaOgHMOAXBpN2EC7uFoJAaL9' : 'AzWRy7ZjS1yRQUk2vRBDic8fprOKDB1W', - 'scope' => implode(',', $permissions), + 'scope' => implode(' ', $permissions), ]); $response = json_decode($this->grabResponse(), true); diff --git a/api/tests/unit/models/authentication/LoginFormTest.php b/api/tests/unit/models/authentication/LoginFormTest.php index 384e63a..f299e40 100644 --- a/api/tests/unit/models/authentication/LoginFormTest.php +++ b/api/tests/unit/models/authentication/LoginFormTest.php @@ -131,6 +131,7 @@ class LoginFormTest extends TestCase { 'login' => 'erickskrauch', 'password' => '12345678', 'account' => new Account([ + 'id' => 1, 'username' => 'erickskrauch', 'password' => '12345678', 'status' => Account::STATUS_ACTIVE,