diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 505edaa..7407496 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,32 +14,23 @@ on: jobs: tests: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" strategy: fail-fast: false matrix: - php: [7.4, 8.0] - symfony: [^4.4, ^5.2] - sylius: [~1.8.0, ~1.9.0, ~1.10.0, ~1.11.0] - node: [14.x] - mysql: [5.7] + php: [8.0] + symfony: [^5.4, ^6.0] + sylius: [~1.11.0, ~1.12.0] + node: [14.19] + mysql: [5.7, 8.0] exclude: - - - sylius: ~1.8.0 - symfony: ^5.2 - - - sylius: ~1.8.0 - php: 8.0 - - - sylius: ~1.9.0 - php: 8.0 - sylius: ~1.11.0 - php: 7.4 + symfony: ^6.0 env: APP_ENV: test @@ -144,13 +135,13 @@ jobs: name: Prepare test application database run: | (cd tests/Application && bin/console doctrine:database:create -vvv) - (cd tests/Application && bin/console doctrine:schema:create -vvv) + (cd tests/Application && bin/console doctrine:schema:create -vvv) - name: Prepare test application assets run: | (cd tests/Application && bin/console assets:install public -vvv) - (cd tests/Application && yarn build) + (cd tests/Application && yarn encore dev) - name: Prepare test application cache diff --git a/composer.json b/composer.json index 480e5ae..f00b865 100644 --- a/composer.json +++ b/composer.json @@ -4,12 +4,14 @@ "description": "Shipping data export environment for Sylius platform applications", "license": "MIT", "require": { - "php": "^7.3 || ^8.0", + "php": "^8.0", "bitbag/coding-standard": "^1.0.1 || ^2.0.0", - "sylius/sylius": "~1.8.0 || ~1.9.0 || ~1.10.0 || ~1.11.0" + "doctrine/dbal": "^2.7", + "sylius/sylius": "~1.11.0 || ~1.12.0" }, "require-dev": { "behat/behat": "^3.6.1", + "symfony/webpack-encore-bundle": "^1.15", "behat/mink-selenium2-driver": "^1.4", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", @@ -28,16 +30,14 @@ "phpstan/phpstan-strict-rules": "^0.12.0 || ^1.0", "phpstan/phpstan-webmozart-assert": "0.12.12 || ^1.0", "phpunit/phpunit": "^9.5", - "sensiolabs/security-checker": "^6.0", "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", - "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev" + "symfony/browser-kit": "^5.4 || ^6.0", + "symfony/debug-bundle": "^5.4 || ^6.0", + "symfony/dotenv": "^5.4 || ^6.0", + "symfony/intl": "^5.4 || ^6.0", + "symfony/web-profiler-bundle": "^5.4 || ^6.0", + "vimeo/psalm": "4.7.1 || ^5.0.0", + "polishsymfonycommunity/symfony-mocker-container": "^1.0" }, "config": { "sort-packages": true, @@ -48,14 +48,6 @@ "phpstan/extension-installer": true } }, - "conflict": { - "doctrine/dbal": "^3.0", - "symfony/symfony": "4.1.8", - "symfony/browser-kit": "4.1.8", - "symfony/dom-crawler": "4.1.8", - "symfony/routing": "4.1.8", - "symfony/doctrine-bridge": "4.4.16" - }, "autoload": { "psr-4": { "BitBag\\SyliusShippingExportPlugin\\": "src/", diff --git a/phpstan.neon b/phpstan.neon index 2d625f6..9fa76d1 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,7 @@ parameters: reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false + checkGenericClassInNonGenericObjectType: false excludes_analyse: # Makes PHPStan crash @@ -11,4 +12,6 @@ parameters: - 'tests/Application/src/**.php' ignoreErrors: - - '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./' + - '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./' + - '/Cannot call method [a-z]+Node\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface\|null\./' + diff --git a/spec/Controller/ShippingExportDownloadLabelActionSpec.php b/spec/Controller/ShippingExportDownloadLabelActionSpec.php index 30fba55..a4559bb 100644 --- a/spec/Controller/ShippingExportDownloadLabelActionSpec.php +++ b/spec/Controller/ShippingExportDownloadLabelActionSpec.php @@ -46,6 +46,7 @@ function it_should_not_allow_directory_travelsal( } function it_returns_a_streamed_response_for_label( + Filesystem $filesystem, Request $request, ShippingExportRepositoryInterface $repository, ShippingExportInterface $shippingExport @@ -59,13 +60,16 @@ function it_returns_a_streamed_response_for_label( $repository->find(1) ->willReturn($shippingExport) ; + $filesystem->exists('/var/www/shipping_labels/label.pdf')->willReturn(true); $this->__invoke($request) ->shouldBeAnInstanceOf(StreamedResponse::class) ; + $this->__invoke($request) ->headers->get('Content-Disposition') ->shouldReturn('attachment; filename=label.pdf') ; } + } diff --git a/src/Controller/ShippingExportController.php b/src/Controller/ShippingExportController.php index 7b3440a..3b22e8e 100644 --- a/src/Controller/ShippingExportController.php +++ b/src/Controller/ShippingExportController.php @@ -16,6 +16,7 @@ use Sylius\Component\Resource\Model\ResourceInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; use Webmozart\Assert\Assert; final class ShippingExportController extends ResourceController @@ -28,7 +29,9 @@ public function exportAllNewShipmentsAction(Request $request): RedirectResponse $shippingExports = $this->repository->findAllWithNewOrPendingState(); if (0 === count($shippingExports)) { - $this->addFlash('error', 'bitbag.ui.no_new_shipments_to_export'); + /** @var FlashBagInterface $flashBag */ + $flashBag = $request->getSession()->getBag('flashes'); + $flashBag->add('error', 'bitbag.ui.no_new_shipments_to_export'); return $this->redirectToReferer($request); } diff --git a/src/Controller/ShippingExportDownloadLabelAction.php b/src/Controller/ShippingExportDownloadLabelAction.php index 01b6e56..2672cfc 100644 --- a/src/Controller/ShippingExportDownloadLabelAction.php +++ b/src/Controller/ShippingExportDownloadLabelAction.php @@ -10,6 +10,7 @@ namespace BitBag\SyliusShippingExportPlugin\Controller; +use BitBag\SyliusShippingExportPlugin\Entity\ShippingExportInterface; use BitBag\SyliusShippingExportPlugin\Repository\ShippingExportRepositoryInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Request; @@ -42,6 +43,7 @@ public function __construct( public function __invoke(Request $request): Response { + /** @var ?ShippingExportInterface $shippingExport */ $shippingExport = $this->repository->find($request->get('id')); Assert::notNull($shippingExport); $labelPath = $shippingExport->getLabelPath(); diff --git a/src/Repository/ShippingGatewayRepositoryInterface.php b/src/Repository/ShippingGatewayRepositoryInterface.php index c4ea930..110d0be 100644 --- a/src/Repository/ShippingGatewayRepositoryInterface.php +++ b/src/Repository/ShippingGatewayRepositoryInterface.php @@ -12,9 +12,16 @@ use BitBag\SyliusShippingExportPlugin\Entity\ShippingGatewayInterface; use Doctrine\ORM\QueryBuilder; +use Doctrine\Persistence\ObjectRepository; +use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; use Sylius\Component\Shipping\Model\ShippingMethodInterface; +/** + * @template T of ResourceInterface + * + * @extends RepositoryInterface + */ interface ShippingGatewayRepositoryInterface extends RepositoryInterface { public function createListQueryBuilder(): QueryBuilder; diff --git a/src/Resources/config/routing/bitbag_shipping_export.yml b/src/Resources/config/routing/bitbag_shipping_export.yml index c3aeeee..d084ae9 100644 --- a/src/Resources/config/routing/bitbag_shipping_export.yml +++ b/src/Resources/config/routing/bitbag_shipping_export.yml @@ -22,13 +22,13 @@ bitbag_admin_export_all_new_shipments: path: /shipping-exports/export/all methods: [POST, PUT] defaults: - _controller: bitbag.controller.shipping_export:exportAllNewShipmentsAction + _controller: bitbag.controller.shipping_export::exportAllNewShipmentsAction bitbag_admin_export_single_shipment: path: /shipping-exports/export/{id} methods: [POST, PUT] defaults: - _controller: bitbag.controller.shipping_export:exportSingleShipmentAction + _controller: bitbag.controller.shipping_export::exportSingleShipmentAction bitbag_admin_get_shipping_label: path: /shipping-exports/label/{id} diff --git a/src/Resources/config/routing/bitbag_shipping_gateway.yml b/src/Resources/config/routing/bitbag_shipping_gateway.yml index 41e7028..3a74f09 100644 --- a/src/Resources/config/routing/bitbag_shipping_gateway.yml +++ b/src/Resources/config/routing/bitbag_shipping_gateway.yml @@ -22,7 +22,7 @@ bitbag_admin_shipping_gateway_create: path: /shipping-gateways/new/{code} methods: [GET, POST] defaults: - _controller: bitbag.controller.shipping_gateway:createAction + _controller: bitbag.controller.shipping_gateway::createAction _sylius: section: admin template: '@SyliusAdmin/Crud/create.html.twig' diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index c8d18f2..15db127 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -12,6 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; use Symfony\Component\Routing\RouteCollectionBuilder; final class Kernel extends BaseKernel @@ -58,7 +59,7 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa } } - protected function configureRoutes(RouteCollectionBuilder $routes): void + protected function configureRoutes(RoutingConfigurator $routes): void { foreach ($this->getConfigurationDirectories() as $confDir) { $this->loadRoutesConfiguration($routes, $confDir); @@ -87,11 +88,11 @@ private function loadContainerConfiguration(LoaderInterface $loader, string $con $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); } /** @@ -103,6 +104,7 @@ private function registerBundlesFromFile(string $bundlesFile): iterable foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[$this->environment])) { yield new $class(); + } } } diff --git a/tests/Application/assets/admin/entry.js b/tests/Application/assets/admin/entry.js new file mode 100644 index 0000000..635f5ac --- /dev/null +++ b/tests/Application/assets/admin/entry.js @@ -0,0 +1 @@ +import 'sylius/bundle/AdminBundle/Resources/private/entry'; diff --git a/tests/Application/assets/shop/entry.js b/tests/Application/assets/shop/entry.js new file mode 100644 index 0000000..aadc317 --- /dev/null +++ b/tests/Application/assets/shop/entry.js @@ -0,0 +1 @@ +import 'sylius/bundle/ShopBundle/Resources/private/entry'; diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index e23eca0..ae509ac 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -15,7 +15,7 @@ throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); } else { // load all the .env files - (new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env'); + (new Dotenv())->loadEnv(dirname(__DIR__) . '/.env'); } $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index fef846c..ac59ec5 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -1,10 +1,15 @@ ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], - Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], @@ -54,4 +59,5 @@ Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all'=> true], ]; diff --git a/tests/Application/config/packages/framework.yaml b/tests/Application/config/packages/framework.yaml index 9b44501..3a2fff8 100644 --- a/tests/Application/config/packages/framework.yaml +++ b/tests/Application/config/packages/framework.yaml @@ -3,4 +3,8 @@ framework: form: true csrf_protection: true session: + save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%' handler_id: ~ + cookie_secure: auto + cookie_samesite: lax + storage_factory_id: session.storage.factory.native 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..daf04d4 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 + handler_id: ~ diff --git a/tests/Application/config/packages/webpack_encore.yaml b/tests/Application/config/packages/webpack_encore.yaml new file mode 100644 index 0000000..9427d36 --- /dev/null +++ b/tests/Application/config/packages/webpack_encore.yaml @@ -0,0 +1,5 @@ +webpack_encore: + output_path: '%kernel.project_dir%/public/build/default' + builds: + shop: '%kernel.project_dir%/public/build/shop' + admin: '%kernel.project_dir%/public/build/admin' diff --git a/tests/Application/config/routes/sylius_shop.yaml b/tests/Application/config/routes/sylius_shop.yaml index 92eeae0..fae46cb 100644 --- a/tests/Application/config/routes/sylius_shop.yaml +++ b/tests/Application/config/routes/sylius_shop.yaml @@ -11,4 +11,4 @@ sylius_shop_default_locale: path: / methods: [GET] defaults: - _controller: sylius.controller.shop.locale_switch:switchAction + _controller: sylius.controller.shop.locale_switch::switchAction diff --git a/tests/Application/config/sylius/1.10/bundles.php b/tests/Application/config/sylius/1.10/bundles.php deleted file mode 100644 index bd33f4a..0000000 --- a/tests/Application/config/sylius/1.10/bundles.php +++ /dev/null @@ -1,6 +0,0 @@ - ['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 deleted file mode 100644 index 2f32a9b..0000000 --- a/tests/Application/config/sylius/1.10/packages/dev/jms_serializer.yaml +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index ed7bc61..0000000 --- a/tests/Application/config/sylius/1.10/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index c288182..0000000 --- a/tests/Application/config/sylius/1.10/packages/prod/jms_serializer.yaml +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 1062810..0000000 --- a/tests/Application/config/sylius/1.10/packages/security.yaml +++ /dev/null @@ -1,148 +0,0 @@ -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.11/bundles.php b/tests/Application/config/sylius/1.11/bundles.php index ce7c123..f202ab5 100644 --- a/tests/Application/config/sylius/1.11/bundles.php +++ b/tests/Application/config/sylius/1.11/bundles.php @@ -1,7 +1,14 @@ ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], + Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/packages/dev/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/dev/swiftmailer.yaml similarity index 100% rename from tests/Application/config/packages/dev/swiftmailer.yaml rename to tests/Application/config/sylius/1.11/packages/dev/swiftmailer.yaml diff --git a/tests/Application/config/packages/staging/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/staging/swiftmailer.yaml similarity index 100% rename from tests/Application/config/packages/staging/swiftmailer.yaml rename to tests/Application/config/sylius/1.11/packages/staging/swiftmailer.yaml diff --git a/tests/Application/config/packages/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml similarity index 100% rename from tests/Application/config/packages/swiftmailer.yaml rename to tests/Application/config/sylius/1.11/packages/swiftmailer.yaml diff --git a/tests/Application/config/packages/test/security.yaml b/tests/Application/config/sylius/1.11/packages/test/security.yaml similarity index 100% rename from tests/Application/config/packages/test/security.yaml rename to tests/Application/config/sylius/1.11/packages/test/security.yaml diff --git a/tests/Application/config/packages/test/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml similarity index 100% rename from tests/Application/config/packages/test/swiftmailer.yaml rename to tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml diff --git a/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml new file mode 100644 index 0000000..c438f4b --- /dev/null +++ b/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml @@ -0,0 +1,6 @@ +swiftmailer: + disable_delivery: true + logging: true + spool: + type: file + path: "%kernel.cache_dir%/spool" diff --git a/tests/Application/config/sylius/1.12/bundles.php b/tests/Application/config/sylius/1.12/bundles.php new file mode 100644 index 0000000..448fd5e --- /dev/null +++ b/tests/Application/config/sylius/1.12/bundles.php @@ -0,0 +1,13 @@ + ['all'=> true], + Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], + BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true] +]; diff --git a/tests/Application/config/sylius/1.12/packages/mailer.yaml b/tests/Application/config/sylius/1.12/packages/mailer.yaml new file mode 100644 index 0000000..0a0697c --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/mailer.yaml @@ -0,0 +1,3 @@ +framework: + mailer: + dsn: '%env(MAILER_DSN)%' diff --git a/tests/Application/config/sylius/1.12/packages/security.yaml b/tests/Application/config/sylius/1.12/packages/security.yaml new file mode 100644 index 0000000..842b093 --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/security.yaml @@ -0,0 +1,124 @@ +security: + enable_authenticator_manager: 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 + + password_hashers: + 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 + enable_csrf: true + 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 + + new_api_admin_user: + pattern: "%sylius.security.new_api_admin_regex%/.*" + provider: sylius_api_admin_user_provider + stateless: 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 + jwt: true + + new_api_shop_user: + pattern: "%sylius.security.new_api_shop_regex%/.*" + provider: sylius_api_shop_user_provider + stateless: 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 + jwt: 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 + enable_csrf: true + 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_homepage + invalidate_session: false + + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + image_resolver: + pattern: ^/media/cache/resolve + security: false + + access_control: + - { 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: 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: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } + + - { 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: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } + - { 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/sylius/1.12/packages/test/mailer.yaml b/tests/Application/config/sylius/1.12/packages/test/mailer.yaml new file mode 100644 index 0000000..56cc28f --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/test/mailer.yaml @@ -0,0 +1,7 @@ +framework: + mailer: + dsn: 'null://null' + cache: + pools: + test.mailer_pool: + adapter: cache.adapter.filesystem diff --git a/tests/Application/config/sylius/1.8/bundles.php b/tests/Application/config/sylius/1.8/bundles.php deleted file mode 100644 index c3c8ea4..0000000 --- a/tests/Application/config/sylius/1.8/bundles.php +++ /dev/null @@ -1,8 +0,0 @@ - ['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 deleted file mode 100644 index 1674a97..0000000 --- a/tests/Application/config/sylius/1.8/packages/_sylius.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } diff --git a/tests/Application/config/sylius/1.8/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/dev/jms_serializer.yaml deleted file mode 100644 index 353e460..0000000 --- a/tests/Application/config/sylius/1.8/packages/dev/jms_serializer.yaml +++ /dev/null @@ -1,7 +0,0 @@ -jms_serializer: - visitors: - json: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.8/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/jms_serializer.yaml deleted file mode 100644 index 64dd8d1..0000000 --- a/tests/Application/config/sylius/1.8/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -jms_serializer: - visitors: - xml: - format_output: '%kernel.debug%' diff --git a/tests/Application/config/sylius/1.8/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/prod/jms_serializer.yaml deleted file mode 100644 index bc97faf..0000000 --- a/tests/Application/config/sylius/1.8/packages/prod/jms_serializer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -jms_serializer: - visitors: - json: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.8/packages/security.yaml b/tests/Application/config/sylius/1.8/packages/security.yaml deleted file mode 100644 index 8161bda..0000000 --- a/tests/Application/config/sylius/1.8/packages/security.yaml +++ /dev/null @@ -1,159 +0,0 @@ -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.8/routes/dev/twig.yaml b/tests/Application/config/sylius/1.8/routes/dev/twig.yaml deleted file mode 100644 index f4ee839..0000000 --- a/tests/Application/config/sylius/1.8/routes/dev/twig.yaml +++ /dev/null @@ -1,3 +0,0 @@ -_errors: - resource: '@TwigBundle/Resources/config/routing/errors.xml' - prefix: /_error diff --git a/tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml b/tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml deleted file mode 100644 index 80aed45..0000000 --- a/tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_admin_api: - resource: "@SyliusAdminApiBundle/Resources/config/routing.yml" - prefix: /api diff --git a/tests/Application/config/sylius/1.9/bundles.php b/tests/Application/config/sylius/1.9/bundles.php deleted file mode 100644 index 66f523d..0000000 --- a/tests/Application/config/sylius/1.9/bundles.php +++ /dev/null @@ -1,8 +0,0 @@ - ['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 deleted file mode 100644 index 1674a97..0000000 --- a/tests/Application/config/sylius/1.9/packages/_sylius.yaml +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 2f32a9b..0000000 --- a/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index ed7bc61..0000000 --- a/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index c288182..0000000 --- a/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 8161bda..0000000 --- a/tests/Application/config/sylius/1.9/packages/security.yaml +++ /dev/null @@ -1,159 +0,0 @@ -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 deleted file mode 100644 index 80aed45..0000000 --- a/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_admin_api: - resource: "@SyliusAdminApiBundle/Resources/config/routing.yml" - prefix: /api diff --git a/tests/Application/package.json b/tests/Application/package.json index b27949d..ba0708a 100755 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,15 +1,16 @@ { "dependencies": { - "babel-polyfill": "^6.26.0", - "chart.js": "^2.9.3", - "jquery": "^3.4.0", + "@babel/polyfill": "^7.0.0", + "chart.js": "^3.7.1", + "jquery": "^3.5.0", "jquery.dirtyforms": "^2.0.0", "lightbox2": "^2.9.0", "semantic-ui-css": "^2.2.0", "slick-carousel": "^1.8.1" }, "devDependencies": { - "@symfony/webpack-encore": "^0.28.0", + "webpack": "^5.76.1", + "@symfony/webpack-encore": "^1.6.1", "babel-core": "^6.26.3", "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-module-resolver": "^3.1.1", @@ -21,31 +22,14 @@ "eslint-config-airbnb-base": "^12.1.0", "eslint-import-resolver-babel-module": "^4.0.0", "eslint-plugin-import": "^2.11.0", - "fast-async": "^6.3.7", - "gulp": "^4.0.0", - "gulp-chug": "^0.5", - "gulp-concat": "^2.6.0", - "gulp-debug": "^2.1.2", - "gulp-if": "^2.0.0", - "gulp-livereload": "^4.0.1", - "gulp-order": "^1.1.1", - "gulp-sass": "^4.0.1", - "gulp-sourcemaps": "^1.6.0", - "gulp-uglifycss": "^1.0.5", "merge-stream": "^1.0.0", - "rollup": "^0.60.2", - "rollup-plugin-babel": "^3.0.4", - "rollup-plugin-commonjs": "^9.1.3", - "rollup-plugin-inject": "^2.0.0", - "rollup-plugin-node-resolve": "^3.3.0", - "rollup-plugin-uglify": "^4.0.0", - "sass-loader": "^7.0.1", - "upath": "^1.1.0", - "yargs": "^6.4.0" + "sass": "^1.39.2", + "sass-loader": "^12.1.0" }, "scripts": { - "build": "gulp build", - "gulp": "gulp build", + "dev": "yarn encore dev", + "watch": "yarn encore dev --watch", + "prod": "yarn encore prod", "lint": "yarn lint:js", "lint:js": "eslint gulpfile.babel.js" }, diff --git a/tests/Application/src/assets/admin/entry.js b/tests/Application/src/assets/admin/entry.js new file mode 100644 index 0000000..f3cf750 --- /dev/null +++ b/tests/Application/src/assets/admin/entry.js @@ -0,0 +1,2 @@ +import './js'; +import './scss/main.scss'; diff --git a/tests/Application/public/media/image/.gitignore b/tests/Application/src/assets/admin/js/index.js old mode 100755 new mode 100644 similarity index 100% rename from tests/Application/public/media/image/.gitignore rename to tests/Application/src/assets/admin/js/index.js diff --git a/tests/Application/src/assets/admin/scss/main.scss b/tests/Application/src/assets/admin/scss/main.scss new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/src/assets/shop/entry.js b/tests/Application/src/assets/shop/entry.js new file mode 100644 index 0000000..f3cf750 --- /dev/null +++ b/tests/Application/src/assets/shop/entry.js @@ -0,0 +1,2 @@ +import './js'; +import './scss/main.scss'; diff --git a/tests/Application/src/assets/shop/js/index.js b/tests/Application/src/assets/shop/js/index.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/src/assets/shop/scss/main.scss b/tests/Application/src/assets/shop/scss/main.scss new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig new file mode 100644 index 0000000..607f4e1 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig @@ -0,0 +1,2 @@ +{{ encore_entry_script_tags('admin-entry', null, 'admin') }} + diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig new file mode 100644 index 0000000..c8d6214 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig @@ -0,0 +1,2 @@ +{{ encore_entry_link_tags('admin-entry', null, 'admin') }} + diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig new file mode 100644 index 0000000..faf6a6c --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig @@ -0,0 +1,2 @@ +{{ encore_entry_script_tags('shop-entry', null, 'shop') }} + diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig new file mode 100644 index 0000000..fcf90fb --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig @@ -0,0 +1,2 @@ +{{ encore_entry_link_tags('shop-entry', null, 'shop') }} + diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js new file mode 100644 index 0000000..489a416 --- /dev/null +++ b/tests/Application/webpack.config.js @@ -0,0 +1,46 @@ +const path = require('path'); +const Encore = require('@symfony/webpack-encore'); + +const syliusBundles = path.resolve(__dirname, '../../vendor/sylius/sylius/src/Sylius/Bundle/'); +const uiBundleScripts = path.resolve(syliusBundles, 'UiBundle/Resources/private/js/'); +const uiBundleResources = path.resolve(syliusBundles, 'UiBundle/Resources/private/'); + +// Shop config +Encore.setOutputPath('public/build/shop/') + .setPublicPath('/build/shop') + .addEntry('shop-entry', './assets/shop/entry.js') + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableSassLoader(); + +const shopConfig = Encore.getWebpackConfig(); + +shopConfig.resolve.alias['sylius/ui'] = uiBundleScripts; +shopConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; +shopConfig.resolve.alias['sylius/bundle'] = syliusBundles; +shopConfig.name = 'shop'; + +Encore.reset(); + +// Admin config +Encore.setOutputPath('public/build/admin/') + .setPublicPath('/build/admin') + .addEntry('admin-entry', './assets/admin/entry.js') + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableSassLoader(); + +const adminConfig = Encore.getWebpackConfig(); + +adminConfig.resolve.alias['sylius/ui'] = uiBundleScripts; +adminConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; +adminConfig.resolve.alias['sylius/bundle'] = syliusBundles; +adminConfig.resolve.alias['chart.js/dist/Chart.min'] = path.resolve(__dirname, 'node_modules/chart.js/dist/chart.min.js'); +adminConfig.externals = Object.assign({}, adminConfig.externals, {window: 'window', document: 'document'}); +adminConfig.name = 'admin'; + +module.exports = [shopConfig, adminConfig]; diff --git a/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php b/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php index 8f961fa..6f9a835 100644 --- a/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php +++ b/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php @@ -14,7 +14,8 @@ use Doctrine\Persistence\ObjectManager; use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent; use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; + +use Symfony\Component\HttpFoundation\RequestStack; use Webmozart\Assert\Assert; final class FrankMartinShippingExportEventListener @@ -22,8 +23,8 @@ final class FrankMartinShippingExportEventListener /** @var bool */ private static $success = true; - /** @var FlashBagInterface */ - private $flashBag; + /** @var RequestStack */ + private $requestStack; /** @var Filesystem */ private $filesystem; @@ -35,12 +36,12 @@ final class FrankMartinShippingExportEventListener private $shippingLabelsPath; public function __construct( - FlashBagInterface $flashBag, + RequestStack $requestStack, Filesystem $filesystem, ObjectManager $shippingExportManager, string $shippingLabelsPath ) { - $this->flashBag = $flashBag; + $this->requestStack = $requestStack; $this->filesystem = $filesystem; $this->shippingExportManager = $shippingExportManager; $this->shippingLabelsPath = $shippingLabelsPath; @@ -60,12 +61,13 @@ public function exportShipment(ResourceControllerEvent $event): void } if (false === self::$success) { - $this->flashBag->add('error', 'bitbag.ui.shipping_export_error'); // Add an error notification + $this->requestStack->getSession()->getBag('flashes') + ->add('error', 'bitbag.ui.shipping_export_error'); // Add an error notification return; } - - $this->flashBag->add('success', 'bitbag.ui.shipment_data_has_been_exported'); // Add success notification + $this->requestStack->getSession()->getBag('flashes') + ->add('success', 'bitbag.ui.shipment_data_has_been_exported'); // Add success notification $this->saveShippingLabel($shippingExport, $this->mockLabelContent(), 'pdf'); // Save label $this->markShipmentAsExported($shippingExport); // Mark shipment as "Exported" } diff --git a/tests/Behat/Resources/services.yml b/tests/Behat/Resources/services.yml index 8e200a4..84bf3ab 100644 --- a/tests/Behat/Resources/services.yml +++ b/tests/Behat/Resources/services.yml @@ -10,7 +10,7 @@ services: bitbag.shipping_gateway_plugin.mock.event_listener.frank_martin_shipping_export: class: Tests\BitBag\SyliusShippingExportPlugin\Behat\Mock\EventListener\FrankMartinShippingExportEventListener arguments: - - '@session.flash_bag' + - '@request_stack' - '@filesystem' - '@bitbag.manager.shipping_export' - '%bitbag.shipping_labels_path%' diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..943ae65 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,38 @@ +const path = require('path'); +const Encore = require('@symfony/webpack-encore'); +const pluginName = 'cs'; + +const getConfig = (pluginName, type) => { + Encore.reset(); + + Encore.setOutputPath(`public/build/bitbag/${pluginName}/${type}/`) + .setPublicPath(`/build/bitbag/${pluginName}/${type}/`) + .addEntry(`bitbag-${pluginName}-${type}`, path.resolve(__dirname, `./src/Resources/assets/${type}/entry.js`)) + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableSassLoader(); + + const config = Encore.getWebpackConfig(); + config.name = `bitbag-${pluginName}-${type}`; + + return config; +}; + +Encore.setOutputPath(`src/Resources/public/build/`) + .setPublicPath(`/public/build/`) + .addEntry(`bitbag-${pluginName}-shop`, path.resolve(__dirname, `./src/Resources/assets/shop/entry.js`)) + .addEntry(`bitbag-${pluginName}-admin`, path.resolve(__dirname, `./src/Resources/assets/admin/entry.js`)) + .cleanupOutputBeforeBuild() + .disableSingleRuntimeChunk() + .enableSassLoader(); + +const distConfig = Encore.getWebpackConfig(); +distConfig.name = `bitbag-plugin-dist`; + +Encore.reset(); + +const shopConfig = getConfig(pluginName, 'shop'); +const adminConfig = getConfig(pluginName, 'admin'); + +module.exports = [shopConfig, adminConfig, distConfig];