From 8af3e00c4a577cb6f97410781a92d39bd7f490eb Mon Sep 17 00:00:00 2001 From: Jonathan Lelievre Date: Thu, 28 Mar 2024 17:44:07 +0100 Subject: [PATCH 1/2] Adapt tests to core changes about AdminApi renaming --- tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php b/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php index 2ce91bf..05257ba 100644 --- a/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php +++ b/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php @@ -81,7 +81,7 @@ public static function setUpBeforeClass(): void ]; $featureFlagManager = self::getContainer()->get('PrestaShop\PrestaShop\Core\FeatureFlag\FeatureFlagManager'); - $featureFlagManager->enable(FeatureFlagSettings::FEATURE_FLAG_AUTHORIZATION_SERVER_MULTISTORE); + $featureFlagManager->enable(FeatureFlagSettings::FEATURE_FLAG_ADMIN_API_MULTISTORE); } public function getProtectedEndpoints(): iterable From 58fe2edad43346d3b923b3b1616af412bf7d9374 Mon Sep 17 00:00:00 2001 From: Jonathan Lelievre Date: Fri, 29 Mar 2024 12:35:33 +0100 Subject: [PATCH 2/2] Adapt new configuration to enable access without HTTPS in tests --- tests/Integration/ApiPlatform/ApiTestCase.php | 3 +++ tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php | 2 ++ tests/Integration/bootstrap.php | 1 - 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/Integration/ApiPlatform/ApiTestCase.php b/tests/Integration/ApiPlatform/ApiTestCase.php index 5f8292a..1f611e7 100644 --- a/tests/Integration/ApiPlatform/ApiTestCase.php +++ b/tests/Integration/ApiPlatform/ApiTestCase.php @@ -40,6 +40,7 @@ abstract class ApiTestCase extends SymfonyApiTestCase public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); + self::updateConfiguration('PS_ADMIN_API_FORCE_DEBUG_SECURED', 0); ApiClientResetter::resetApiClient(); } @@ -47,6 +48,7 @@ public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); ApiClientResetter::resetApiClient(); + self::updateConfiguration('PS_ADMIN_API_FORCE_DEBUG_SECURED', 1); self::$clientSecret = null; } @@ -258,5 +260,6 @@ protected static function addShop(string $shopName, int $shopGroupId, string $co protected static function updateConfiguration(string $configurationKey, $value, ShopConstraint $shopConstraint = null): void { self::getContainer()->get(ShopConfigurationInterface::class)->set($configurationKey, $value, $shopConstraint ?: ShopConstraint::allShops()); + \Configuration::resetStaticCache(); } } diff --git a/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php b/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php index 05257ba..c103bcb 100644 --- a/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php +++ b/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php @@ -61,6 +61,8 @@ public static function setUpBeforeClass(): void self::$frenchLangId = self::addLanguageByLocale('fr-FR'); self::updateConfiguration(MultistoreConfig::FEATURE_STATUS, 1); + // Disable secure protection for the tests (the configuration reset forced the default config back) + self::updateConfiguration('PS_ADMIN_API_FORCE_DEBUG_SECURED', 0); self::$secondShopGroupId = self::addShopGroup('Second group'); self::$secondShopId = self::addShop('Second shop', self::DEFAULT_SHOP_GROUP_ID); self::$thirdShopId = self::addShop('Third shop', self::$secondShopGroupId); diff --git a/tests/Integration/bootstrap.php b/tests/Integration/bootstrap.php index b068185..9106a53 100644 --- a/tests/Integration/bootstrap.php +++ b/tests/Integration/bootstrap.php @@ -21,7 +21,6 @@ define('_PS_ROOT_DIR_', dirname(__DIR__, 4)); } define('_PS_IN_TEST_', true); -define('_PS_API_FORCE_TLS_VERSION_', false); define('_PS_MODULE_DIR_', _PS_ROOT_DIR_ . '/tests/Resources/modules/'); require_once _PS_ROOT_DIR_ . '/vendor/smarty/smarty/libs/functions.php'; require_once _PS_ROOT_DIR_ . '/admin-dev/bootstrap.php';