diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 164f464..cec60cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - php: [7.4, 7.3] + php: [8.0, 7.4] node: [10.x] mysql: [5.7, 8.0] diff --git a/composer.json b/composer.json index 4c6e878..6766efc 100644 --- a/composer.json +++ b/composer.json @@ -5,9 +5,8 @@ "description": "Provides table rate shipping calculator.", "license": "MIT", "require": { - "php": "^7.3", - - "sylius/sylius": "^1.8" + "php": "^7.4 || ^8.0", + "sylius/sylius": "~1.9.0 || ~1.10.0@beta" }, "require-dev": { "behat/behat": "^3.6.1", @@ -16,32 +15,28 @@ "dmore/chrome-mink-driver": "^2.7", "friends-of-behat/mink": "^1.8", "friends-of-behat/mink-browserkit-driver": "^1.4", + "friends-of-behat/mink-debug-extension": "^2.0.0", "friends-of-behat/mink-extension": "^2.4", "friends-of-behat/page-object-extension": "^0.3", "friends-of-behat/suite-settings-extension": "^1.0", "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", - "lakion/mink-debug-extension": "^2.0.0", + "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev", "phpspec/phpspec": "^7.0", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.67", - "phpstan/phpstan-doctrine": "0.12.28", + "phpstan/phpstan": "0.12.85", + "phpstan/phpstan-doctrine": "0.12.33", "phpstan/phpstan-strict-rules": "^0.12.0", - "phpstan/phpstan-webmozart-assert": "0.12.8", + "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^9.5", "sensiolabs/security-checker": "^6.0", - "sylius-labs/coding-standard": "^3.1", - "symfony/browser-kit": "^4.4", - "symfony/debug-bundle": "^4.4|^5.0", - "symfony/dotenv": "^4.4|^5.0", - "symfony/intl": "^4.4|^5.0", - "symfony/web-profiler-bundle": "^4.4|^5.0", - "symfony/web-server-bundle": "^4.4|^5.0", - "vimeo/psalm": "4.4.1" - }, - "conflict": { - "symfony/doctrine-bridge": "4.4.16", - "symplify/package-builder": "^8.3.25" + "sylius-labs/coding-standard": "^4.0", + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/debug-bundle": "^4.4 || ^5.2", + "symfony/dotenv": "^4.4 || ^5.2", + "symfony/intl": "^4.4 || ^5.2", + "symfony/web-profiler-bundle": "^4.4 || ^5.2", + "vimeo/psalm": "4.7.1" }, "autoload": { "psr-4": { diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 1561d93..7233c9e 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -12,7 +12,6 @@ final class Configuration implements ConfigurationInterface public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('acme_sylius_example_plugin'); - $rootNode = $treeBuilder->getRootNode(); return $treeBuilder; } diff --git a/src/DependencyInjection/WebgriffeSyliusTableRateShippingExtension.php b/src/DependencyInjection/WebgriffeSyliusTableRateShippingExtension.php index 6fdff9a..11df776 100644 --- a/src/DependencyInjection/WebgriffeSyliusTableRateShippingExtension.php +++ b/src/DependencyInjection/WebgriffeSyliusTableRateShippingExtension.php @@ -16,7 +16,7 @@ final class WebgriffeSyliusTableRateShippingExtension extends Extension */ public function load(array $config, ContainerBuilder $container): void { - $config = $this->processConfiguration($this->getConfiguration([], $container), $config); + $this->processConfiguration($this->getConfiguration([], $container), $config); $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.yml'); diff --git a/src/Resolver/TableRateResolver.php b/src/Resolver/TableRateResolver.php index cf075bf..e9455f3 100644 --- a/src/Resolver/TableRateResolver.php +++ b/src/Resolver/TableRateResolver.php @@ -57,7 +57,7 @@ public function resolve(ShipmentInterface $shipment, array $calculatorConfig): S /** @var ShippingTableRate $tableRate */ $tableRate = $calculatorConfig[$channelCode][TableRateConfigurationType::TABLE_RATE_FIELD_NAME]; - /** @var ShippingTableRate $tableRate */ + /** @var ShippingTableRate|null $tableRate */ $tableRate = $this->tableRateRepository->findOneBy(['code' => $tableRate->getCode()]); Assert::isInstanceOf($tableRate, ShippingTableRate::class); diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 109c9fe..9f3cace 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -4,13 +4,13 @@ namespace Tests\Webgriffe\SyliusTableRateShippingPlugin\Application; -use ProxyManager\Proxy\VirtualProxyInterface; use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; +use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\RouteCollectionBuilder; @@ -20,13 +20,6 @@ final class Kernel extends BaseKernel private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; - private const IGNORED_SERVICES_DURING_CLEANUP = [ - 'kernel', - 'http_kernel', - 'liip_imagine.mime_type_guesser', - 'liip_imagine.extension_guesser', - ]; - public function getCacheDir(): string { return $this->getProjectDir() . '/var/cache/' . $this->environment; @@ -39,52 +32,37 @@ public function getLogDir(): string public function registerBundles(): iterable { - $contents = require $this->getProjectDir() . '/config/bundles.php'; - foreach ($contents as $class => $envs) { - if (isset($envs['all']) || isset($envs[$this->environment])) { - yield new $class(); + foreach ($this->getConfigurationDirectories() as $confDir) { + $bundlesFile = $confDir . '/bundles.php'; + if (false === is_file($bundlesFile)) { + continue; } + yield from $this->registerBundlesFromFile($bundlesFile); } } - public function shutdown(): void + protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { - if (!$this->isTestEnvironment()) { - parent::shutdown(); - - return; - } - - if (false === $this->booted) { - return; + foreach ($this->getConfigurationDirectories() as $confDir) { + $bundlesFile = $confDir . '/bundles.php'; + if (false === is_file($bundlesFile)) { + continue; + } + $container->addResource(new FileResource($bundlesFile)); } - $container = $this->getContainer(); - - parent::shutdown(); - - $this->cleanupContainer($container); - } - - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void - { - $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php')); $container->setParameter('container.dumper.inline_class_loader', true); - $confDir = $this->getProjectDir() . '/config'; - $loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); + foreach ($this->getConfigurationDirectories() as $confDir) { + $this->loadContainerConfiguration($loader, $confDir); + } } protected function configureRoutes(RouteCollectionBuilder $routes): void { - $confDir = $this->getProjectDir() . '/config'; - - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); + foreach ($this->getConfigurationDirectories() as $confDir) { + $this->loadRoutesConfiguration($routes, $confDir); + } } protected function getContainerBaseClass(): string @@ -101,44 +79,47 @@ private function isTestEnvironment(): bool return 0 === strpos($this->getEnvironment(), 'test'); } - /** - * Remove all container references from all loaded services - */ - private function cleanupContainer(ContainerInterface $container): void + private function loadContainerConfiguration(LoaderInterface $loader, string $confDir): void { - $containerReflection = new \ReflectionObject($container); - $containerServicesPropertyReflection = $containerReflection->getProperty('services'); - $containerServicesPropertyReflection->setAccessible(true); - - $services = $containerServicesPropertyReflection->getValue($container) ?: []; - foreach ($services as $serviceId => $service) { - if (null === $service) { - continue; - } - - if (in_array($serviceId, self::IGNORED_SERVICES_DURING_CLEANUP, true)) { - continue; - } - - $serviceReflection = new \ReflectionObject($service); - - if ($serviceReflection->implementsInterface(VirtualProxyInterface::class)) { - continue; - } + $loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob'); + $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); + $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); + $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); + } - $servicePropertiesReflections = $serviceReflection->getProperties(); - $servicePropertiesDefaultValues = $serviceReflection->getDefaultProperties(); - foreach ($servicePropertiesReflections as $servicePropertyReflection) { - $defaultPropertyValue = null; - if (isset($servicePropertiesDefaultValues[$servicePropertyReflection->getName()])) { - $defaultPropertyValue = $servicePropertiesDefaultValues[$servicePropertyReflection->getName()]; - } + private function loadRoutesConfiguration(RouteCollectionBuilder $routes, string $confDir): void + { + $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); + } - $servicePropertyReflection->setAccessible(true); - $servicePropertyReflection->setValue($service, $defaultPropertyValue); + /** + * @return BundleInterface[] + */ + private function registerBundlesFromFile(string $bundlesFile): iterable + { + $contents = require $bundlesFile; + foreach ($contents as $class => $envs) { + if (isset($envs['all']) || isset($envs[$this->environment])) { + yield new $class(); } } + } - $containerServicesPropertyReflection->setValue($container, null); + /** + * @return string[] + */ + private function getConfigurationDirectories(): iterable + { + yield $this->getProjectDir() . '/config'; + $syliusConfigDir = $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION; + if (is_dir($syliusConfigDir)) { + yield $syliusConfigDir; + } + $symfonyConfigDir = $this->getProjectDir() . '/config/symfony/' . BaseKernel::MAJOR_VERSION . '.' . BaseKernel::MINOR_VERSION; + if (is_dir($symfonyConfigDir)) { + yield $symfonyConfigDir; + } } } diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index 0188278..e23eca0 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -5,6 +5,7 @@ use Symfony\Component\Dotenv\Dotenv; require dirname(__DIR__).'../../../vendor/autoload.php'; + // Load cached env vars if the .env.local.php file exists // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2) if (is_array($env = @include dirname(__DIR__) . '/.env.local.php')) { @@ -16,6 +17,7 @@ // load all the .env files (new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env'); } + $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; $_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 54ddd19..35ecbda 100755 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -7,7 +7,6 @@ Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], - Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true], Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true], @@ -40,16 +39,12 @@ Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true], Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], - WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true], Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true], Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true], - Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['all' => true], Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true], Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], - FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], - Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], @@ -58,7 +53,6 @@ Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], - Symplify\ConsoleColorDiff\ConsoleColorDiffBundle::class => ['dev' => true, 'test' => true], Webgriffe\SyliusTableRateShippingPlugin\WebgriffeSyliusTableRateShippingPlugin::class => ['all' => true], ]; diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml index 79f5ce6..7532b01 100755 --- a/tests/Application/config/packages/_sylius.yaml +++ b/tests/Application/config/packages/_sylius.yaml @@ -2,7 +2,6 @@ imports: - { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" } - { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" } - - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } - { resource: "@SyliusShopBundle/Resources/config/app/config.yml" } diff --git a/tests/Application/config/packages/framework.yaml b/tests/Application/config/packages/framework.yaml old mode 100755 new mode 100644 index e74ed81..9b44501 --- a/tests/Application/config/packages/framework.yaml +++ b/tests/Application/config/packages/framework.yaml @@ -2,6 +2,5 @@ framework: secret: '%env(APP_SECRET)%' form: true csrf_protection: true - templating: { engines: ["twig"] } session: handler_id: ~ diff --git a/tests/Application/config/sylius/1.10/bundles.php b/tests/Application/config/sylius/1.10/bundles.php new file mode 100644 index 0000000..bd33f4a --- /dev/null +++ b/tests/Application/config/sylius/1.10/bundles.php @@ -0,0 +1,6 @@ + ['all' => true], + SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], +]; diff --git a/tests/Application/config/sylius/1.10/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.10/packages/dev/jms_serializer.yaml new file mode 100644 index 0000000..2f32a9b --- /dev/null +++ b/tests/Application/config/sylius/1.10/packages/dev/jms_serializer.yaml @@ -0,0 +1,12 @@ +jms_serializer: + visitors: + json_serialization: + options: + - JSON_PRETTY_PRINT + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION + json_deserialization: + options: + - JSON_PRETTY_PRINT + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.10/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.10/packages/jms_serializer.yaml new file mode 100644 index 0000000..ed7bc61 --- /dev/null +++ b/tests/Application/config/sylius/1.10/packages/jms_serializer.yaml @@ -0,0 +1,4 @@ +jms_serializer: + visitors: + xml_serialization: + format_output: '%kernel.debug%' diff --git a/tests/Application/config/sylius/1.10/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.10/packages/prod/jms_serializer.yaml new file mode 100644 index 0000000..c288182 --- /dev/null +++ b/tests/Application/config/sylius/1.10/packages/prod/jms_serializer.yaml @@ -0,0 +1,10 @@ +jms_serializer: + visitors: + json_serialization: + options: + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION + json_deserialization: + options: + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.10/packages/security.yaml b/tests/Application/config/sylius/1.10/packages/security.yaml new file mode 100644 index 0000000..1062810 --- /dev/null +++ b/tests/Application/config/sylius/1.10/packages/security.yaml @@ -0,0 +1,148 @@ +parameters: + sylius.security.admin_regex: "^/%sylius_admin.path_name%" + sylius.security.api_regex: "^/api" + sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++" + sylius.security.new_api_route: "/new-api" + sylius.security.new_api_regex: "^%sylius.security.new_api_route%" + sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin" + sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%" + sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop" + sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%" + +security: + always_authenticate_before_granting: true + providers: + sylius_admin_user_provider: + id: sylius.admin_user_provider.email_or_name_based + sylius_api_admin_user_provider: + id: sylius.admin_user_provider.email_or_name_based + sylius_shop_user_provider: + id: sylius.shop_user_provider.email_or_name_based + sylius_api_shop_user_provider: + id: sylius.shop_user_provider.email_or_name_based + sylius_api_chain_provider: + chain: + providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider] + + encoders: + Sylius\Component\User\Model\UserInterface: argon2i + firewalls: + admin: + switch_user: true + context: admin + pattern: "%sylius.security.admin_regex%" + provider: sylius_admin_user_provider + form_login: + provider: sylius_admin_user_provider + login_path: sylius_admin_login + check_path: sylius_admin_login_check + failure_path: sylius_admin_login + default_target_path: sylius_admin_dashboard + use_forward: false + use_referer: true + csrf_token_generator: security.csrf.token_manager + csrf_parameter: _csrf_admin_security_token + csrf_token_id: admin_authenticate + remember_me: + secret: "%env(APP_SECRET)%" + path: "/%sylius_admin.path_name%" + name: APP_ADMIN_REMEMBER_ME + lifetime: 31536000 + remember_me_parameter: _remember_me + logout: + path: sylius_admin_logout + target: sylius_admin_login + anonymous: true + + new_api_admin_user: + pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" + provider: sylius_admin_user_provider + stateless: true + anonymous: true + json_login: + check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" + username_path: email + password_path: password + success_handler: lexik_jwt_authentication.handler.authentication_success + failure_handler: lexik_jwt_authentication.handler.authentication_failure + guard: + authenticators: + - lexik_jwt_authentication.jwt_token_authenticator + + new_api_shop_user: + pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" + provider: sylius_shop_user_provider + stateless: true + anonymous: true + json_login: + check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" + username_path: email + password_path: password + success_handler: lexik_jwt_authentication.handler.authentication_success + failure_handler: lexik_jwt_authentication.handler.authentication_failure + guard: + authenticators: + - lexik_jwt_authentication.jwt_token_authenticator + + new_api: + pattern: "%sylius.security.new_api_regex%/*" + provider: sylius_api_chain_provider + stateless: true + anonymous: lazy + guard: + authenticators: + - lexik_jwt_authentication.jwt_token_authenticator + + shop: + switch_user: { role: ROLE_ALLOWED_TO_SWITCH } + context: shop + pattern: "%sylius.security.shop_regex%" + provider: sylius_shop_user_provider + form_login: + success_handler: sylius.authentication.success_handler + failure_handler: sylius.authentication.failure_handler + provider: sylius_shop_user_provider + login_path: sylius_shop_login + check_path: sylius_shop_login_check + failure_path: sylius_shop_login + default_target_path: sylius_shop_homepage + use_forward: false + use_referer: true + csrf_token_generator: security.csrf.token_manager + csrf_parameter: _csrf_shop_security_token + csrf_token_id: shop_authenticate + remember_me: + secret: "%env(APP_SECRET)%" + name: APP_SHOP_REMEMBER_ME + lifetime: 31536000 + remember_me_parameter: _remember_me + logout: + path: sylius_shop_logout + target: sylius_shop_login + invalidate_session: false + success_handler: sylius.handler.shop_user_logout + anonymous: true + + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + access_control: + - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } + - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } + + - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + + - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } + + - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } + - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + + - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } diff --git a/tests/Application/config/sylius/1.8/bundles.php b/tests/Application/config/sylius/1.8/bundles.php new file mode 100644 index 0000000..c3c8ea4 --- /dev/null +++ b/tests/Application/config/sylius/1.8/bundles.php @@ -0,0 +1,8 @@ + ['all' => true], + WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true], + FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], + Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], +]; diff --git a/tests/Application/config/sylius/1.8/packages/_sylius.yaml b/tests/Application/config/sylius/1.8/packages/_sylius.yaml new file mode 100644 index 0000000..1674a97 --- /dev/null +++ b/tests/Application/config/sylius/1.8/packages/_sylius.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } diff --git a/tests/Application/config/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/dev/jms_serializer.yaml old mode 100755 new mode 100644 similarity index 100% rename from tests/Application/config/packages/dev/jms_serializer.yaml rename to tests/Application/config/sylius/1.8/packages/dev/jms_serializer.yaml diff --git a/tests/Application/config/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/jms_serializer.yaml old mode 100755 new mode 100644 similarity index 100% rename from tests/Application/config/packages/jms_serializer.yaml rename to tests/Application/config/sylius/1.8/packages/jms_serializer.yaml diff --git a/tests/Application/config/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/prod/jms_serializer.yaml old mode 100755 new mode 100644 similarity index 100% rename from tests/Application/config/packages/prod/jms_serializer.yaml rename to tests/Application/config/sylius/1.8/packages/prod/jms_serializer.yaml diff --git a/tests/Application/config/packages/security.yaml b/tests/Application/config/sylius/1.8/packages/security.yaml old mode 100755 new mode 100644 similarity index 90% rename from tests/Application/config/packages/security.yaml rename to tests/Application/config/sylius/1.8/packages/security.yaml index 12e842b..8161bda --- a/tests/Application/config/packages/security.yaml +++ b/tests/Application/config/sylius/1.8/packages/security.yaml @@ -1,9 +1,13 @@ parameters: - sylius.security.admin_regex: "^/admin" + sylius.security.admin_regex: "^/%sylius_admin.path_name%" sylius.security.api_regex: "^/api" - sylius.security.shop_regex: "^/(?!admin|new-api|api/.*|api$|media/.*)[^/]++" + sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++" sylius.security.new_api_route: "/new-api" sylius.security.new_api_regex: "^%sylius.security.new_api_route%" + sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin" + sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%" + sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop" + sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%" security: always_authenticate_before_granting: true @@ -41,7 +45,7 @@ security: csrf_token_id: admin_authenticate remember_me: secret: "%env(APP_SECRET)%" - path: /admin + path: "/%sylius_admin.path_name%" name: APP_ADMIN_REMEMBER_ME lifetime: 31536000 remember_me_parameter: _remember_me @@ -150,3 +154,6 @@ security: - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + + - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } diff --git a/tests/Application/config/routes/dev/twig.yaml b/tests/Application/config/sylius/1.8/routes/dev/twig.yaml old mode 100755 new mode 100644 similarity index 100% rename from tests/Application/config/routes/dev/twig.yaml rename to tests/Application/config/sylius/1.8/routes/dev/twig.yaml diff --git a/tests/Application/config/routes/sylius_admin_api.yaml b/tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml old mode 100755 new mode 100644 similarity index 100% rename from tests/Application/config/routes/sylius_admin_api.yaml rename to tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml diff --git a/tests/Application/config/sylius/1.9/bundles.php b/tests/Application/config/sylius/1.9/bundles.php new file mode 100644 index 0000000..66f523d --- /dev/null +++ b/tests/Application/config/sylius/1.9/bundles.php @@ -0,0 +1,8 @@ + ['all' => true], + SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], + FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], + Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], +]; diff --git a/tests/Application/config/sylius/1.9/packages/_sylius.yaml b/tests/Application/config/sylius/1.9/packages/_sylius.yaml new file mode 100644 index 0000000..1674a97 --- /dev/null +++ b/tests/Application/config/sylius/1.9/packages/_sylius.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } diff --git a/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml new file mode 100644 index 0000000..2f32a9b --- /dev/null +++ b/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml @@ -0,0 +1,12 @@ +jms_serializer: + visitors: + json_serialization: + options: + - JSON_PRETTY_PRINT + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION + json_deserialization: + options: + - JSON_PRETTY_PRINT + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml new file mode 100644 index 0000000..ed7bc61 --- /dev/null +++ b/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml @@ -0,0 +1,4 @@ +jms_serializer: + visitors: + xml_serialization: + format_output: '%kernel.debug%' diff --git a/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml new file mode 100644 index 0000000..c288182 --- /dev/null +++ b/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml @@ -0,0 +1,10 @@ +jms_serializer: + visitors: + json_serialization: + options: + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION + json_deserialization: + options: + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.9/packages/security.yaml b/tests/Application/config/sylius/1.9/packages/security.yaml new file mode 100644 index 0000000..8161bda --- /dev/null +++ b/tests/Application/config/sylius/1.9/packages/security.yaml @@ -0,0 +1,159 @@ +parameters: + sylius.security.admin_regex: "^/%sylius_admin.path_name%" + sylius.security.api_regex: "^/api" + sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++" + sylius.security.new_api_route: "/new-api" + sylius.security.new_api_regex: "^%sylius.security.new_api_route%" + sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin" + sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%" + sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop" + sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%" + +security: + always_authenticate_before_granting: true + providers: + sylius_admin_user_provider: + id: sylius.admin_user_provider.email_or_name_based + sylius_api_admin_user_provider: + id: sylius.admin_user_provider.email_or_name_based + sylius_shop_user_provider: + id: sylius.shop_user_provider.email_or_name_based + sylius_api_shop_user_provider: + id: sylius.shop_user_provider.email_or_name_based + sylius_api_chain_provider: + chain: + providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider] + + encoders: + Sylius\Component\User\Model\UserInterface: argon2i + firewalls: + admin: + switch_user: true + context: admin + pattern: "%sylius.security.admin_regex%" + provider: sylius_admin_user_provider + form_login: + provider: sylius_admin_user_provider + login_path: sylius_admin_login + check_path: sylius_admin_login_check + failure_path: sylius_admin_login + default_target_path: sylius_admin_dashboard + use_forward: false + use_referer: true + csrf_token_generator: security.csrf.token_manager + csrf_parameter: _csrf_admin_security_token + csrf_token_id: admin_authenticate + remember_me: + secret: "%env(APP_SECRET)%" + path: "/%sylius_admin.path_name%" + name: APP_ADMIN_REMEMBER_ME + lifetime: 31536000 + remember_me_parameter: _remember_me + logout: + path: sylius_admin_logout + target: sylius_admin_login + anonymous: true + + oauth_token: + pattern: "%sylius.security.api_regex%/oauth/v2/token" + security: false + + new_api_admin_user: + pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" + provider: sylius_admin_user_provider + stateless: true + anonymous: true + json_login: + check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" + username_path: email + password_path: password + success_handler: lexik_jwt_authentication.handler.authentication_success + failure_handler: lexik_jwt_authentication.handler.authentication_failure + guard: + authenticators: + - lexik_jwt_authentication.jwt_token_authenticator + + new_api_shop_user: + pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" + provider: sylius_shop_user_provider + stateless: true + anonymous: true + json_login: + check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" + username_path: email + password_path: password + success_handler: lexik_jwt_authentication.handler.authentication_success + failure_handler: lexik_jwt_authentication.handler.authentication_failure + guard: + authenticators: + - lexik_jwt_authentication.jwt_token_authenticator + + new_api: + pattern: "%sylius.security.new_api_regex%/*" + provider: sylius_api_chain_provider + stateless: true + anonymous: lazy + guard: + authenticators: + - lexik_jwt_authentication.jwt_token_authenticator + + api: + pattern: "%sylius.security.api_regex%/.*" + provider: sylius_admin_user_provider + fos_oauth: true + stateless: true + anonymous: true + + shop: + switch_user: { role: ROLE_ALLOWED_TO_SWITCH } + context: shop + pattern: "%sylius.security.shop_regex%" + provider: sylius_shop_user_provider + form_login: + success_handler: sylius.authentication.success_handler + failure_handler: sylius.authentication.failure_handler + provider: sylius_shop_user_provider + login_path: sylius_shop_login + check_path: sylius_shop_login_check + failure_path: sylius_shop_login + default_target_path: sylius_shop_homepage + use_forward: false + use_referer: true + csrf_token_generator: security.csrf.token_manager + csrf_parameter: _csrf_shop_security_token + csrf_token_id: shop_authenticate + remember_me: + secret: "%env(APP_SECRET)%" + name: APP_SHOP_REMEMBER_ME + lifetime: 31536000 + remember_me_parameter: _remember_me + logout: + path: sylius_shop_logout + target: sylius_shop_login + invalidate_session: false + success_handler: sylius.handler.shop_user_logout + anonymous: true + + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + access_control: + - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } + - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } + + - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + + - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } + + - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } + - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + + - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } diff --git a/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml b/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml new file mode 100644 index 0000000..80aed45 --- /dev/null +++ b/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml @@ -0,0 +1,3 @@ +sylius_admin_api: + resource: "@SyliusAdminApiBundle/Resources/config/routing.yml" + prefix: /api diff --git a/tests/Application/config/symfony/4.4/packages/framework.yaml b/tests/Application/config/symfony/4.4/packages/framework.yaml new file mode 100644 index 0000000..62f82d3 --- /dev/null +++ b/tests/Application/config/symfony/4.4/packages/framework.yaml @@ -0,0 +1,2 @@ +framework: + templating: { engines: ["twig"] } diff --git a/tests/Application/public/build/admin/entrypoints.json b/tests/Application/public/build/admin/entrypoints.json new file mode 100644 index 0000000..76d6083 --- /dev/null +++ b/tests/Application/public/build/admin/entrypoints.json @@ -0,0 +1,3 @@ +{ + "entrypoints": {} +} \ No newline at end of file diff --git a/tests/Application/public/build/admin/manifest.json b/tests/Application/public/build/admin/manifest.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/tests/Application/public/build/admin/manifest.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/tests/Application/public/build/shop/entrypoints.json b/tests/Application/public/build/shop/entrypoints.json new file mode 100644 index 0000000..76d6083 --- /dev/null +++ b/tests/Application/public/build/shop/entrypoints.json @@ -0,0 +1,3 @@ +{ + "entrypoints": {} +} \ No newline at end of file diff --git a/tests/Application/public/build/shop/manifest.json b/tests/Application/public/build/shop/manifest.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/tests/Application/public/build/shop/manifest.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index ab6f9dc..bd15d22 100755 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -1,10 +1,12 @@