Code development platform for open source projects from the European Union institutions

Verified Commit 61f02a5f authored by Pol Dellaiera's avatar Pol Dellaiera
Browse files

tests: Update for Symfony 6.

parent 6a578027
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
Feature: It test the /api endpoint
Feature: It test the /api/token endpoint

    Scenario: Test

    Given I am on "/token"
    Given I am on "/api/token"
    Then the response should be in JSON
    Then the JSON node "token" should not be null
    And the JSON node "token" should not be null

    Given I send a POST request to "/token" with body:
    Given I send a POST request to "/api/token" with body:
        """
        {"foo":"bar"}
        """
    Then the response should be in JSON
    Then the JSON node "token" should not be null
    And the JSON node "token" should not be null
+4 −4
Original line number Diff line number Diff line
Feature: It test the /user endpoint
Feature: It test the /api/user endpoint

    Scenario: Test

    Given I add "Authorization" header equal to "foo"
    When I send a GET request to "/user"
    When I send a GET request to "/api/user"
    Then the response status code should be 401

    Given I add "Authorization" header equal to "pop eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdCI6ImV5SjBlWEFpT2lKS1YxUWlMQ0poYkdjaU9pSklVekkxTmlKOS5leUp6ZFdJaU9pSjFjMlZ5WHpZd09Ea3hNREUyWkdFNVlqSWlMQ0poWTNScGRtVWlPblJ5ZFdWOS51SkhMLWxJdUVOVlFqVE9hM3dWQVFQVlI1am9uY3VTb3RpTURBM3o1VFpFIn0.r1mDS0qCjy_4a-XXD6SPPgDQd9McDDvZFJfRxq2Xwn4"
    When I send a GET request to "/user"
    When I send a GET request to "/api/user"
    Then the response should be in JSON
    Then the JSON node "sub" should not be null
    Then the JSON node "active" should be equal to "true"
    Then the response status code should be 200

    Given I add "Authorization" header equal to "pop eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdCI6ImV5SjBlWEFpT2lKS1YxUWlMQ0poYkdjaU9pSklVekkxTmlKOS5leUptYjI4aU9pSmlZWElpTENKemRXSWlPaUoxYzJWeVh6WXdPRGt4TWpBek4yTmtOV0VpTENKaFkzUnBkbVVpT25SeWRXVjkuU0JaSDNMNEVkcHk4NWlITHVDcVpWTkQxSDltYU9UZERjZUF2bXF3NFp4byJ9.eVRIsRLwFNoCRNsiCyVEfhPze4sjx9DKl-RJ9mwkZEQ"
    When I send a GET request to "/user"
    When I send a GET request to "/api/user"
    Then the response should be in JSON
    Then the JSON node "sub" should not be null
    Then the JSON node "active" should be equal to "true"
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ final class Kernel extends BaseKernel
{
    use MicroKernelTrait;

    public function registerBundles()
    public function registerBundles(): iterable
    {
        return [
            new MonologBundle(),
+13 −11
Original line number Diff line number Diff line
security:
    enable_authenticator_manager: true

    # https://symfony.com/doc/current/security.html#c-hashing-passwords
    password_hashers:
        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'

    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        users_in_memory: { memory: null }

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            anonymous: true
            provider: eu_login_api_authentication
            pattern: ^/
            guard:
                authenticators:
                    - eu_login_api_authentication.guard
            custom_authenticators:
                - eu_login_api_authentication.authenticator

    access_control:
        - { path: ^/token, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/user, role: IS_AUTHENTICATED_FULLY }
        - { path: ^/api/user, roles: IS_AUTHENTICATED_FULLY }
+1 −0
Original line number Diff line number Diff line
controllers:
    resource: '@EuLoginApiAuthenticationBundle/Resources/config/routes/routes.php'
    prefix: /api