diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3a1c86..418fc1d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: fail-fast: false matrix: php: ["8.0", "8.1"] - symfony: ["5.4.*"] + symfony: ["5.4.*", "^6.0"] sylius: ["^1.12"] node: ["14.x", "16.x", "18.x"] mysql: ["5.7", "8.0"] @@ -97,6 +97,12 @@ jobs: composer global config --no-plugins allow-plugins.symfony/flex true composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^2.2.2" + - + name: Restrict Symfony version + if: matrix.symfony != '' + run: | + composer config extra.symfony.require "${{ matrix.symfony }}" + - name: Restrict Sylius version if: matrix.sylius != '' diff --git a/composer.json b/composer.json index 3da8c6f..12a0729 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "require": { "php": "^8.0", "sylius/sylius": "^1.12", + "sylius/mailer-bundle": "^1.8 || ^2.0@beta", "symfony/webpack-encore-bundle": "^1.15" }, "require-dev": { @@ -25,7 +26,6 @@ "friends-of-behat/suite-settings-extension": "^1.0", "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", - "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev", "phpspec/phpspec": "^7.2", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.8.1", @@ -34,14 +34,13 @@ "phpstan/phpstan-webmozart-assert": "^1.2.0", "phpunit/phpunit": "^9.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "sensiolabs/security-checker": "^6.0", "sylius-labs/coding-standard": "^4.2", - "symfony/browser-kit": "^5.4", - "symfony/debug-bundle": "^5.4", - "symfony/dotenv": "^5.4", + "symfony/browser-kit": "^5.4 || ^6.0", + "symfony/debug-bundle": "^5.4 || ^6.0", + "symfony/dotenv": "^5.4 || ^6.0", "symfony/flex": "^2.2.2", - "symfony/intl": "^5.4", - "symfony/web-profiler-bundle": "^5.4", + "symfony/intl": "^5.4 || ^6.0", + "symfony/web-profiler-bundle": "^5.4 || ^6.0", "vimeo/psalm": "4.27.0" }, "config": { diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index b1e62dc..0bedc86 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -7,12 +7,9 @@ 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\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\RouteCollectionBuilder; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; final class Kernel extends BaseKernel { @@ -41,24 +38,7 @@ public function registerBundles(): iterable } } - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void - { - foreach ($this->getConfigurationDirectories() as $confDir) { - $bundlesFile = $confDir . '/bundles.php'; - if (false === is_file($bundlesFile)) { - continue; - } - $container->addResource(new FileResource($bundlesFile)); - } - - $container->setParameter('container.dumper.inline_class_loader', true); - - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadContainerConfiguration($loader, $confDir); - } - } - - protected function configureRoutes(RouteCollectionBuilder $routes): void + protected function configureRoutes(RoutingConfigurator $routes): void { foreach ($this->getConfigurationDirectories() as $confDir) { $this->loadRoutesConfiguration($routes, $confDir); @@ -79,19 +59,11 @@ private function isTestEnvironment(): bool return 0 === strpos($this->getEnvironment(), 'test'); } - private function loadContainerConfiguration(LoaderInterface $loader, string $confDir): void - { - $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'); - } - - private function loadRoutesConfiguration(RouteCollectionBuilder $routes, string $confDir): void + private function loadRoutesConfiguration(RoutingConfigurator $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'); + $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); } /** diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index e23eca0..c9951a7 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -13,6 +13,10 @@ $_ENV += $env; } elseif (!class_exists(Dotenv::class)) { throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); +} elseif (method_exists(Dotenv::class, 'bootEnv')) { + (new Dotenv())->bootEnv(dirname(__DIR__) . '/.env'); + + return; } else { // load all the .env files (new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env'); diff --git a/tests/Application/config/packages/security.yaml b/tests/Application/config/packages/security.yaml index 5101dde..4ed342f 100644 --- a/tests/Application/config/packages/security.yaml +++ b/tests/Application/config/packages/security.yaml @@ -1,5 +1,5 @@ security: - always_authenticate_before_granting: true + enable_authenticator_manager: true providers: sylius_admin_user_provider: id: sylius.admin_user_provider.email_or_name_based @@ -10,7 +10,7 @@ security: sylius_api_shop_user_provider: id: sylius.shop_user_provider.email_or_name_based - encoders: + password_hashers: Sylius\Component\User\Model\UserInterface: argon2i firewalls: admin: @@ -26,7 +26,7 @@ security: default_target_path: sylius_admin_dashboard use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_admin_security_token csrf_token_id: admin_authenticate remember_me: @@ -38,37 +38,32 @@ security: logout: path: sylius_admin_logout target: sylius_admin_login - anonymous: true new_api_admin_user: pattern: "%sylius.security.new_api_admin_regex%/.*" provider: sylius_api_admin_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: check_path: "%sylius.security.new_api_admin_route%/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 + jwt: true new_api_shop_user: pattern: "%sylius.security.new_api_shop_regex%/.*" provider: sylius_api_shop_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: check_path: "%sylius.security.new_api_shop_route%/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 + jwt: true shop: switch_user: { role: ROLE_ALLOWED_TO_SWITCH } @@ -85,7 +80,7 @@ security: default_target_path: sylius_shop_homepage use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_shop_security_token csrf_token_id: shop_authenticate remember_me: @@ -95,10 +90,8 @@ security: remember_me_parameter: _remember_me logout: path: sylius_shop_logout - target: sylius_shop_login + target: sylius_shop_homepage invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ @@ -109,22 +102,23 @@ security: 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: PUBLIC_ACCESS, 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: PUBLIC_ACCESS, 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.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS } - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } - - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/packages/security_checker.yaml b/tests/Application/config/packages/security_checker.yaml deleted file mode 100644 index 0f9cf00..0000000 --- a/tests/Application/config/packages/security_checker.yaml +++ /dev/null @@ -1,9 +0,0 @@ -services: - SensioLabs\Security\SecurityChecker: - public: false - - SensioLabs\Security\Command\SecurityCheckerCommand: - arguments: ['@SensioLabs\Security\SecurityChecker'] - public: false - tags: - - { name: console.command, command: 'security:check' } diff --git a/tests/Application/config/packages/test/framework.yaml b/tests/Application/config/packages/test/framework.yaml index 76d7e5e..fc1d3c1 100644 --- a/tests/Application/config/packages/test/framework.yaml +++ b/tests/Application/config/packages/test/framework.yaml @@ -1,4 +1,4 @@ framework: test: ~ session: - storage_id: session.storage.mock_file + storage_factory_id: session.storage.factory.mock_file diff --git a/tests/Application/config/packages/test/security.yaml b/tests/Application/config/packages/test/security.yaml index 21cc377..4071d31 100644 --- a/tests/Application/config/packages/test/security.yaml +++ b/tests/Application/config/packages/test/security.yaml @@ -1,3 +1,6 @@ security: - encoders: - sha512: sha512 + password_hashers: + Sylius\Component\User\Model\UserInterface: + algorithm: argon2i + time_cost: 3 + memory_cost: 10 diff --git a/tests/Application/config/packages/test_cached/framework.yaml b/tests/Application/config/packages/test_cached/framework.yaml index 76d7e5e..e9dd6ee 100644 --- a/tests/Application/config/packages/test_cached/framework.yaml +++ b/tests/Application/config/packages/test_cached/framework.yaml @@ -1,4 +1,2 @@ -framework: - test: ~ - session: - storage_id: session.storage.mock_file +imports: + - { resource: ../test/framework.yaml } diff --git a/tests/Application/config/packages/test_cached/security.yaml b/tests/Application/config/packages/test_cached/security.yaml index 21cc377..76e9273 100644 --- a/tests/Application/config/packages/test_cached/security.yaml +++ b/tests/Application/config/packages/test_cached/security.yaml @@ -1,3 +1,2 @@ -security: - encoders: - sha512: sha512 +imports: + - { resource: ../test/security.yaml }