diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 242f7046e..63e783b4d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,8 +12,8 @@ - - + + diff --git a/tests/App/AppKernel.php b/tests/App/AppKernel.php index 536749fa2..564fa55c0 100644 --- a/tests/App/AppKernel.php +++ b/tests/App/AppKernel.php @@ -41,18 +41,17 @@ public function registerBundles(): array public function registerContainerConfiguration(LoaderInterface $loader): void { - $loader->load(__DIR__.'/config/config.yaml'); if (Kernel::VERSION_ID >= 60000) { + $loader->load(__DIR__.'/config/config_v6.yaml'); $loader->load(__DIR__.'/config/security_v6.yaml'); } elseif (Kernel::VERSION_ID >= 50100 && Kernel::VERSION_ID < 59999) { + $loader->load(__DIR__.'/config/config_v5.yaml'); if (0 === (int) getenv('USE_NEW_SYMFONY_SECURITY')) { $loader->load(__DIR__.'/config/security_v5_bc.yaml'); } else { $loader->load(__DIR__.'/config/security_v5.yaml'); } - } else { - $loader->load(__DIR__.'/config/security_v4.yaml'); } } diff --git a/tests/App/config/config.yaml b/tests/App/config/config_v5.yaml similarity index 100% rename from tests/App/config/config.yaml rename to tests/App/config/config_v5.yaml diff --git a/tests/App/config/config_v6.yaml b/tests/App/config/config_v6.yaml new file mode 100644 index 000000000..14d31dace --- /dev/null +++ b/tests/App/config/config_v6.yaml @@ -0,0 +1,101 @@ +framework: + test: ~ + secret: secret + router: + utf8: true + resource: "%kernel.project_dir%/../App/config/routing.yaml" + translator: ~ + form: + enabled: true + csrf_protection: ~ + session: + handler_id: 'session.handler.native' + http_method_override: false + +monolog: + handlers: + main: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug + +services: + _defaults: + autowire: true + autoconfigure: true + + HWI\Bundle\OAuthBundle\Tests\App\Controller\HomeController: + tags: + - controller.service_arguments + + HWI\Bundle\OAuthBundle\Tests\App\Form\RegistrationFormHandler: ~ + HWI\Bundle\OAuthBundle\Tests\App\Form\RegistrationFormType: ~ + HWI\Bundle\OAuthBundle\Tests\App\UserProvider: ~ + + # Must be "public" to allow replacing it with mock client + hwi_oauth.http_client: + class: Symfony\Contracts\HttpClient\HttpClientInterface + public: true + + app.oauth2_resource_owner: + class: HWI\Bundle\OAuthBundle\Tests\App\ResourceOwner\OAuth2ResourceOwner + arguments: + $options: { + access_token_url: 'http://custom/token', + authorization_url: 'http://custom/auth', + infos_url: 'http://custom/info', + client_id: 'client_id', + client_secret: 'client_secret', + } + $name: 'custom' + $storage: '@hwi_oauth.storage.session' + +doctrine: + dbal: + driver: pdo_sqlite + url: 'sqlite:///:memory:' + orm: + auto_generate_proxy_classes: '%kernel.debug%' + auto_mapping: true + +hwi_oauth: + connect: + confirmation: true + account_connector: HWI\Bundle\OAuthBundle\Tests\App\UserProvider + registration_form_handler: HWI\Bundle\OAuthBundle\Tests\App\Form\RegistrationFormHandler + registration_form: HWI\Bundle\OAuthBundle\Tests\App\Form\RegistrationFormType + resource_owners: + google: + type: google + client_id: 'google_client_id' + client_secret: 'google_client_secret' + scope: 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile' + yahoo: + type: yahoo + client_id: 'yahoo_client_id' + client_secret: 'yahoo_client_secret' + scope: 'scope=mail-r sdct-r' + options: + refresh_on_expire: true + oauth2: + service: 'app.oauth2_resource_owner' + oauth1: + class: 'HWI\Bundle\OAuthBundle\Tests\App\ResourceOwner\OAuth1ResourceOwner' + client_id: "fake_client_id" + client_secret: "fake_client_secret" + options: + access_token_url: 'http://localhost/token' + authorization_url: 'http://localhost/auth' + infos_url: 'http://localhost/info' + request_token_url: 'http://localhost/request-token' + custom: + class: 'HWI\Bundle\OAuthBundle\Tests\App\ResourceOwner\CustomResourceOwner' + client_id: "fake_client_id" + client_secret: "fake_client_secret" + base_url: "http://localhost/" + +twig: + strict_variables: '%kernel.debug%' + exception_controller: ~ + paths: + '%kernel.project_dir%/templates': 'Acme' diff --git a/tests/App/config/security_v4.yaml b/tests/App/config/security_v4.yaml deleted file mode 100644 index 62181c165..000000000 --- a/tests/App/config/security_v4.yaml +++ /dev/null @@ -1,52 +0,0 @@ -security: - encoders: - HWI\Bundle\OAuthBundle\Tests\Fixtures\User: sha512 - - providers: - HWI\Bundle\OAuthBundle\Tests\App\UserProvider: - id: HWI\Bundle\OAuthBundle\Tests\App\UserProvider - - firewalls: - login_area: - pattern: ^/(login$|connect|login_hwi) - anonymous: lazy - context: hwi_context - api: - pattern: ^/api/ - anonymous: lazy - stateless: true - oauth: - resource_owners: - google: '/api/check-login/google' - yahoo: '/api/check-login/yahoo' - oauth1: '/api/check-login/oauth1' - oauth2: '/api/check-login/oauth2' - custom: '/api/check-login/custom' - login_path: /api/login - check_path: /api/check-login - use_forward: false - failure_path: /api/login - oauth_user_provider: - service: HWI\Bundle\OAuthBundle\Tests\App\UserProvider - provider: HWI\Bundle\OAuthBundle\Tests\App\UserProvider - context: hwi_context - main: - pattern: ^/ - anonymous: lazy - oauth: - resource_owners: - google: '/check-login/google' - yahoo: '/check-login/yahoo' - oauth1: '/check-login/oauth1' - oauth2: '/check-login/oauth2' - custom: '/check-login/custom' - login_path: /login - use_forward: false - failure_path: /login - oauth_user_provider: - service: HWI\Bundle\OAuthBundle\Tests\App\UserProvider - provider: HWI\Bundle\OAuthBundle\Tests\App\UserProvider - context: hwi_context - - access_control: - - { path: ^/private, roles: ROLE_USER } diff --git a/tests/App/config/security_v6.yaml b/tests/App/config/security_v6.yaml index e074e8c33..a9344c86f 100644 --- a/tests/App/config/security_v6.yaml +++ b/tests/App/config/security_v6.yaml @@ -6,8 +6,6 @@ security: HWI\Bundle\OAuthBundle\Tests\App\UserProvider: id: HWI\Bundle\OAuthBundle\Tests\App\UserProvider - enable_authenticator_manager: true - firewalls: api: pattern: ^/api/