Codeception / module-rest

REST module for Codeception
MIT License
54 stars 27 forks source link

[Codeception/Rest, Codeception/Symfony] Security token not stored in token storage #80

Open amigian74 opened 2 years ago

amigian74 commented 2 years ago

What are you trying to achieve?

I'm trying to test my API interface in Symfony. This API uses JWT-Authentication. So far retrieving the token and calling the controller works.

What do you get instead?

Unfortunately the token is not stored in the token storage and so my voters dont get the right user (they get a Null-Token instead).

Provide test source code if related

$I->amBearerAuthenticated($token);
$I->sendGet('/api/resource');
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
$I->seeResponseIsJson();

Details

actor: ApiTester
modules:
    enabled:
        - \App\Tests\Helper\Api
        - Symfony:
            app_path: 'src'
            environment: 'test'
            headers:
                Content-Type: application/json
        - Doctrine2:
            depends: Symfony
            cleanup: true
        - REST:
            url: https://localhost
            depends: Symfony
        - Asserts
        - Db:
            dsn: 'mysql:host=%DATABASE_HOST%:%DATABASE_PORT%;dbname=%META_DATABASE_NAME%'
            user: '%DATABASE_USER%'
            password: '%DATABASE_PASSWORD%'
            dump:
              - tests/_data/meta_dump.sql
              - tests/_data/meta_security_dump.sql
            cleanup: true # reload dump between tests
            populate: true # load dump before all tests
            databases:
                DATA:
                    dsn: 'mysql:host=%DATABASE_HOST%:%DATABASE_PORT%;dbname=%DATA_DATABASE_NAME%'
                    user: '%DATABASE_USER%'
                    password: '%DATABASE_PASSWORD%'
                    dump: tests/_data/data_dump.sql
                    cleanup: false
                    populate: true # load dump before all tests
Naktibalda commented 2 years ago

@TavoNiievez token storage seems like a Symfony thing to me.

TavoNiievez commented 2 years ago

@Naktibalda I moved it because I didn't see any module-symfony method in the description.

It is very surely related to the particular implementation of @amigian74 of the tokens.