Skip to content

Commit

Permalink
Merge pull request #53 from BitBagCommerce/OPSRC-526/Sylius_1.11_support
Browse files Browse the repository at this point in the history
Add sylius 1.11 support
  • Loading branch information
liszkapawel authored Apr 14, 2022
2 parents ae5e5e5 + 509c851 commit 0e7bc98
Show file tree
Hide file tree
Showing 24 changed files with 442 additions and 47 deletions.
20 changes: 7 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,22 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.4, 7.3, 8.0]
php: [8.0, 7.4]
symfony: [^4.4, ^5.2]
sylius: [~1.8.0, ~1.9.0, ~1.10.0]
node: [10.x]
sylius: [~1.9.0, ~1.10.0, ~1.11.0]
node: [14.19]
mysql: [5.7]

exclude:
-
php: 7.3
mysql: 8.0
-
sylius: ~1.8.0
symfony: ^5.2
-
sylius: ~1.8.0
php: 8.0
-
sylius: ~1.9.0
php: 8.0
-
sylius: ~1.10.0
php: 7.3
symfony: 4.4
-
sylius: ~1.11.0
php: 7.4

env:
APP_ENV: test
Expand Down
12 changes: 0 additions & 12 deletions .scrutinizer.yml

This file was deleted.

14 changes: 12 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"require": {
"php": "^7.3 || ^7.4 || ^8.0",
"sylius/sylius": "^1.10",
"sylius/sylius": "~1.9.0 || ~1.10.0 || ~1.11.0",
"drewm/mailchimp-api": "^v2.5.4",
"ext-json": "*",
"vimeo/psalm": "^4.12",
Expand Down Expand Up @@ -39,7 +39,9 @@
"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"
"symfony/web-profiler-bundle": "^4.4 || ^5.2",
"friendsofsymfony/oauth-server-bundle": "2.*@dev",
"polishsymfonycommunity/symfony-mocker-container": "^1.0"
},
"prefer-stable": true,
"conflict": {
Expand All @@ -53,5 +55,13 @@
},
"autoload-dev": {
"classmap": ["tests/Application/Kernel.php"]
},
"config": {
"allow-plugins": {
"symfony/thanks": true,
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
}
}
8 changes: 8 additions & 0 deletions tests/Application/.env
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ JWT_PASSPHRASE=acme_plugin_development
# Delivery is disabled by default via "null://localhost"
MAILER_URL=smtp://localhost
###< symfony/swiftmailer-bundle ###

###> symfony/messenger ###
# Choose one of the transports below
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# MESSENGER_TRANSPORT_DSN=doctrine://default
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
MESSENGER_TRANSPORT_DSN=sync://
###< symfony/messenger ###
2 changes: 1 addition & 1 deletion tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function configureRoutes(RouteCollectionBuilder $routes): void

protected function getContainerBaseClass(): string
{
if ($this->isTestEnvironment()) {
if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) {
return MockerContainer::class;
}

Expand Down
Empty file.
9 changes: 0 additions & 9 deletions tests/Application/config/packages/security_checker.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions tests/Application/config/sylius/1.10/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
];
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jms_serializer:
visitors:
xml_serialization:
format_output: '%kernel.debug%'
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,7 +25,7 @@ security:
providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider]

encoders:
Sylius\Component\User\Model\UserInterface: sha512
Sylius\Component\User\Model\UserInterface: argon2i
firewalls:
admin:
switch_user: true
Expand All @@ -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
Expand Down Expand Up @@ -89,12 +93,6 @@ security:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator

api:
pattern: "%sylius.security.api_regex%/.*"
provider: sylius_admin_user_provider
stateless: true
anonymous: true

shop:
switch_user: { role: ROLE_ALLOWED_TO_SWITCH }
context: shop
Expand Down Expand Up @@ -145,3 +143,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 }
9 changes: 9 additions & 0 deletions tests/Application/config/sylius/1.11/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

return [
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true],
];
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jms_serializer:
visitors:
xml_serialization:
format_output: '%kernel.debug%'
Original file line number Diff line number Diff line change
@@ -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
138 changes: 138 additions & 0 deletions tests/Application/config/sylius/1.11/packages/security.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
parameters:
sylius.security.admin_regex: "^/admin"
sylius.security.shop_regex: "^/(?!admin|new-api|api/.*|api$|media/.*)[^/]++"
sylius.security.new_api_route: "/api/v2"
sylius.security.new_api_regex: "^%sylius.security.new_api_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: /admin
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.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.shop_regex%/account", role: ROLE_USER }
8 changes: 8 additions & 0 deletions tests/Application/config/sylius/1.9/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true],
Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true],
];
2 changes: 2 additions & 0 deletions tests/Application/config/sylius/1.9/packages/_sylius.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports:
- { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" }
Loading

0 comments on commit 0e7bc98

Please sign in to comment.