Skip to content

Commit b8ef1f1

Browse files
committed
Rename oauth-api endpoint into admin-api
1 parent a8f08c2 commit b8ef1f1

File tree

32 files changed

+50
-38
lines changed

32 files changed

+50
-38
lines changed

.github/workflows/symfony-console.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
symfony-console:
1313
strategy:
1414
matrix:
15-
app-id: [ admin, oauth-api, front ]
15+
app-id: [ admin, admin-api, front ]
1616
permissions:
1717
contents: read # for actions/checkout to fetch code
1818
name: Symfony Console
@@ -59,10 +59,10 @@ jobs:
5959
./bin/console cache:clear --env=prod --no-warmup --app-id=${{ matrix.app-id }}
6060
6161
- name: Check app listeners for OAuth API
62-
if: matrix.app-id == 'oauth-api'
62+
if: matrix.app-id == 'admin-api'
6363
run: |
64-
apiListeners=$(./bin/console debug:event-dispatcher kernel.request --app-id=oauth-api | grep 'PrestaShopBundle\\EventListener\\API' | wc -l)
65-
adminListeners=$(./bin/console debug:event-dispatcher kernel.request --app-id=oauth-api | grep 'PrestaShopBundle\\EventListener\\Admin' | wc -l)
64+
apiListeners=$(./bin/console debug:event-dispatcher kernel.request --app-id=admin-api | grep 'PrestaShopBundle\\EventListener\\API' | wc -l)
65+
adminListeners=$(./bin/console debug:event-dispatcher kernel.request --app-id=admin-api | grep 'PrestaShopBundle\\EventListener\\Admin' | wc -l)
6666
echo $apiListeners API listeners detected
6767
echo $adminListeners Admin listeners detected
6868
if [ $adminListeners -ne 0 ]; then
File renamed without changes.
File renamed without changes.

oauth-api/index.php admin-api/index.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
use Symfony\Component\HttpFoundation\Request;
2929
use Symfony\Component\HttpKernel\HttpKernelInterface;
3030

31-
define('_PS_APP_ID_', 'oauth-api');
3231
require __DIR__ . '/../config/config.inc.php';
32+
define('_PS_APP_ID_', AdminAPIKernel::APP_ID);
3333

3434
//small test to clear cache after upgrade
3535
if (Configuration::get('PS_UPGRADE_CLEAR_CACHE')) {
@@ -60,7 +60,7 @@
6060
->loadEnv($dotEnvFile)
6161
;
6262

63-
$kernel = new OAuthAPIKernel(_PS_ENV_, _PS_MODE_DEV_);
63+
$kernel = new AdminAPIKernel(_PS_ENV_, _PS_MODE_DEV_);
6464
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
6565
//Request::enableHttpMethodParameterOverride();
6666
$request = Request::createFromGlobals();

admin-dev/index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
3131
use Symfony\Component\HttpKernel\HttpKernelInterface;
3232

33-
define('_PS_APP_ID_', 'admin');
3433
if (!defined('_PS_ADMIN_DIR_')) {
3534
define('_PS_ADMIN_DIR_', __DIR__);
3635
}
@@ -40,6 +39,7 @@
4039
}
4140

4241
require _PS_ADMIN_DIR_ . '/../config/config.inc.php';
42+
define('_PS_APP_ID_', AdminKernel::APP_ID);
4343

4444
//small test to clear cache after upgrade
4545
if (Configuration::get('PS_UPGRADE_CLEAR_CACHE')) {

app/OAuthAPIKernel.php app/AdminAPIKernel.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626

2727
declare(strict_types=1);
2828

29-
class OAuthAPIKernel extends AppKernel
29+
class AdminAPIKernel extends AppKernel
3030
{
31+
public const APP_ID = 'admin-api';
32+
3133
public function getAppId(): string
3234
{
33-
return 'oauth-api';
35+
return self::APP_ID;
3436
}
3537
}

app/AdminKernel.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
*/
2626
class AdminKernel extends AppKernel
2727
{
28+
public const APP_ID = 'admin';
29+
2830
public function getAppId(): string
2931
{
30-
return 'admin';
32+
return self::APP_ID;
3133
}
3234
}

app/FrontKernel.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
*/
2626
class FrontKernel extends AppKernel
2727
{
28+
public const APP_ID = 'front';
29+
2830
public function getAppId(): string
2931
{
30-
return 'front';
32+
return self::APP_ID;
3133
}
3234
}

app/config/oauth-api/config.yml app/config/admin-api/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ imports:
66

77
framework:
88
router:
9-
resource: "%kernel.project_dir%/app/config/oauth-api/routing.yml"
9+
resource: "%kernel.project_dir%/app/config/admin-api/routing.yml"
1010
strict_requirements: ~
1111

1212
api_platform:

app/config/oauth-api/config_dev.yml app/config/admin-api/config_dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ imports:
44

55
framework:
66
router:
7-
resource: "%kernel.project_dir%/app/config/oauth-api/routing_dev.yml"
7+
resource: "%kernel.project_dir%/app/config/admin-api/routing_dev.yml"
88
strict_requirements: ~
99
profiler: { only_exceptions: false }
File renamed without changes.

app/config/oauth-api/config_test.yml app/config/admin-api/config_test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ imports:
44

55
framework:
66
router:
7-
resource: "%kernel.project_dir%/app/config/oauth-api/routing_test.yml"
7+
resource: "%kernel.project_dir%/app/config/admin-api/routing_test.yml"
88
strict_requirements: ~
99
profiler: { only_exceptions: false }

app/config/oauth-api/routing.yml app/config/admin-api/routing.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
_api_oauth2_routing:
2-
resource: "@PrestaShopBundle/Resources/config/routing/oauth-api.yml"
2+
resource: "@PrestaShopBundle/Resources/config/routing/admin-api.yml"
33

44
_api_platform_routing:
55
resource: .
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

app/config/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ api_platform:
109109
enable_entrypoint: false
110110
enable_swagger: false
111111
enable_swagger_ui: false
112-
# We define mapping here because even though the API routes are oncly accessible via the oauth-api endpoint we still need
112+
# We define mapping here because even though the API routes are oncly accessible via the admin-api endpoint we still need
113113
# to parse the Api Platform resources to extract the scopes
114114
mapping:
115115
paths:

bin/console

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
<?php
33

44
use PrestaShopBundle\Console\PrestaShopApplication;
5-
use Symfony\Component\Console\Input\ArgvInput;
6-
use Symfony\Component\Console\Input\InputOption;
75
use Symfony\Component\Console\Exception\InvalidArgumentException;
6+
use Symfony\Component\Console\Input\ArgvInput;
87
use Symfony\Component\Dotenv\Dotenv;
98
use Symfony\Component\ErrorHandler\Debug;
109

@@ -16,9 +15,9 @@ use Symfony\Component\ErrorHandler\Debug;
1615
set_time_limit(0);
1716

1817
try {
19-
require_once __DIR__ . '/../config/config.inc.php';
18+
require_once __DIR__ . '/../config/config.inc.php';
2019
} catch (PrestaShopException) {
21-
// Prevent breaking all CLI command when the shop is not installed
20+
// Prevent breaking all CLI command when the shop is not installed
2221
}
2322

2423
$input = new ArgvInput();
@@ -28,10 +27,10 @@ $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-d
2827
// Handle PrestaShop global option app-id, by default use the Admin kernel
2928
$appId = $input->getParameterOption(['--app-id'], getenv('APP_ID') ?: 'admin');
3029
$kernelClass = match ($appId) {
31-
'admin' => AdminKernel::class,
32-
'front' => FrontKernel::class,
33-
'oauth-api' => OAuthAPIKernel::class,
34-
default => throw new InvalidArgumentException('Unknown PrestaShop kernel matching the ID ' . $appId),
30+
AdminKernel::APP_ID => AdminKernel::class,
31+
FrontKernel::APP_ID => FrontKernel::class,
32+
AdminAPIKernel::APP_ID => AdminAPIKernel::class,
33+
default => throw new InvalidArgumentException('Unknown PrestaShop kernel matching the ID ' . $appId),
3534
};
3635

3736
if ($debug) {

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239
"classmap": [
240240
"app/AppKernel.php",
241241
"app/AdminKernel.php",
242-
"app/OAuthAPIKernel.php",
242+
"app/AdminAPIKernel.php",
243243
"app/FrontKernel.php",
244244
"app/AppCache.php"
245245
]

index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
}
3737

3838
// Include some configurations & composer autoload
39-
define('_PS_APP_ID_', 'front');
4039
require_once _PS_FRONT_DIR_ . '/config/config.inc.php';
4140
require_once _PS_FRONT_DIR_ . '/vendor/autoload.php';
41+
define('_PS_APP_ID_', FrontKernel::APP_ID);
4242

4343
// Load .env file from the root of project if present
4444
(new Dotenv(false))->loadEnv(_PS_FRONT_DIR_ . '/.env');

src/Adapter/Cache/Clearer/SymfonyCacheClearer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626

2727
namespace PrestaShop\PrestaShop\Adapter\Cache\Clearer;
2828

29+
use AdminAPIKernel;
2930
use AdminKernel;
3031
use AppKernel;
3132
use FrontKernel;
3233
use Hook;
33-
use OAuthAPIKernel;
3434
use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface;
3535
use Psr\Log\LoggerInterface;
3636
use Throwable;
@@ -79,7 +79,7 @@ public function clear()
7979
set_time_limit(0);
8080

8181
$environments = ['prod', 'dev'];
82-
$applicationKernelClasses = [AdminKernel::class, OAuthAPIKernel::class, FrontKernel::class];
82+
$applicationKernelClasses = [AdminKernel::class, AdminAPIKernel::class, FrontKernel::class];
8383
$baseCommandLine = 'php -d memory_limit=-1 ' . $kernel->getProjectDir() . '/bin/console ';
8484
foreach ($applicationKernelClasses as $applicationKernelClass) {
8585
foreach ($environments as $environment) {

src/PrestaShopBundle/Console/PrestaShopApplication.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,17 @@
2828

2929
namespace PrestaShopBundle\Console;
3030

31+
use AdminAPIKernel;
32+
use AdminKernel;
33+
use FrontKernel;
3134
use Symfony\Bundle\FrameworkBundle\Console\Application;
3235
use Symfony\Component\Console\Input\InputDefinition;
3336
use Symfony\Component\Console\Input\InputOption;
3437

38+
/**
39+
* Dedicated application for Symfony console that addition adds default parameter app-id
40+
* to all the commands to allow switching from one kernel to another.
41+
*/
3542
class PrestaShopApplication extends Application
3643
{
3744
protected function getDefaultInputDefinition(): InputDefinition
@@ -43,7 +50,7 @@ protected function getDefaultInputDefinition(): InputDefinition
4350
InputOption::VALUE_REQUIRED,
4451
'Specify a PrestaShop Application ID.',
4552
'admin',
46-
['admin', 'oauth-api', 'front']
53+
[AdminKernel::APP_ID, AdminAPIKernel::APP_ID, FrontKernel::APP_ID]
4754
));
4855

4956
return $definition;

src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/AuthorizationServer/ApiClientController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ private function getOAuthApiBaseUrl(Request $request): string
248248
// Get root url right before the admin folder part
249249
$rootUrl = substr($uri, 0, strpos($uri, $adminFolderName));
250250

251-
return $rootUrl . '/oauth-api';
251+
return $rootUrl . '/admin-api';
252252
}
253253

254254
private function getFormHandler(): FormHandlerInterface
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_admin_oauth2:
2+
resource: "admin-api/oauth2.yml"

src/PrestaShopBundle/Resources/config/routing/oauth-api.yml

-2
This file was deleted.

tests/Integration/ApiPlatform/EndPoint/ApiTestCase.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
namespace Tests\Integration\ApiPlatform\EndPoint;
3030

31+
use AdminAPIKernel;
3132
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase as ApiPlatformTestCase;
3233
use ApiPlatform\Symfony\Bundle\Test\Client;
33-
use OAuthAPIKernel;
3434
use PrestaShop\PrestaShop\Core\Domain\ApiClient\Command\AddApiClientCommand;
3535
use PrestaShop\PrestaShop\Core\Domain\Configuration\ShopConfigurationInterface;
3636
use PrestaShop\PrestaShop\Core\Domain\Language\Command\AddLanguageCommand;
@@ -67,7 +67,7 @@ public static function tearDownAfterClass(): void
6767
*/
6868
protected static function getKernelClass(): string
6969
{
70-
return OAuthAPIKernel::class;
70+
return AdminAPIKernel::class;
7171
}
7272

7373
protected static function createClient(array $kernelOptions = [], array $defaultOptions = []): Client

tests/UI/.env.ci

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# URLs
33
URL_FO="https://localhost:8002/"
44
URL_BO="https://localhost:8002/admin-dev/"
5-
URL_API="https://localhost:8002/oauth-api/"
5+
URL_API="https://localhost:8002/admin-api/"
66
URL_INSTALL="https://localhost:8002/install-dev/"
77

88
# BO account

tests/UI/.env.local

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# URLs
33
URL_FO="https://localhost/"
44
URL_BO="https://localhost/admin-dev/"
5-
URL_API="https://localhost/oauth-api/"
5+
URL_API="https://localhost/admin-api/"
66
URL_INSTALL="http://localhost/install-dev/"
77

88
# BO account

tests/UI/campaigns/functional/API/01_basicTest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('API : Basic Test', async () => {
1515
});
1616

1717
describe('Basic Test', async () => {
18-
it('should request the endpoint /oauth-api', async function () {
18+
it('should request the endpoint /admin-api', async function () {
1919
await testContext.addContextItem(this, 'testIdentifier', 'requestNewApi', baseContext);
2020

2121
const apiResponse = await apiContext.get('');

tests/UI/utils/globals.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ global.BO = {
2121
};
2222

2323
global.API = {
24-
URL: process.env.URL_API || `${global.FO.URL}oauth-api/`,
24+
URL: process.env.URL_API || `${global.FO.URL}admin-api/`,
2525
};
2626

2727
global.PSConfig = {

0 commit comments

Comments
 (0)