I have a microservice that use JWT for authentication/authorization, and it just need a verify an jwt token is correct or incorrect, so in the code, i only implement the decoder for JWT.
Lcobucci\JWT\Configuration:
factory: [ 'App\Security\JWT\JWTConfigurationFactory', 'createJWTReader' ]
arguments:
- '%env(JWT_PUBLIC_KEY)%'
this configuration will be injected to JWTManager. but as you see, i just implement the read part.
but in functional test, i need to generate some token to pass some functional test (call to authenticated endpoint.. eg) that need a encoder part.
my strategy is create a new file service-test.yaml and write a createAsymmetricSigner in factory to work both with read/write JWT.
Lcobucci\JWT\Configuration:
factory: [ '@CCT\Monolith\Shared\Symfony\Security\JWT\JWTConfigurationFactory', 'createAsymmetricSigner' ]
arguments:
- '%env(JWT_PRIVATE_KEY)%'
- '%env(JWT_PUBLIC_KEY)%'
- '%env(JWT_PASSWORD)%'
and the problem is, how can i overide the symfony start up endpoint to make it take service-test.yaml instead of service.yaml for DI configuration file.
when@testin your existing services file for that. See docsconfig/services_test.yamlas said in the doc