microshed-testing
microshed-testing copied to clipboard
Testing JWT endpoint with RESTassured
When following the guide on testing a JWT endpoint, there is a provided solution for injecting a JWT when using the Microshed RESTClient. However, I'm fond of using REST Assured. I was frustrated to find out, that the @JwtConfig is not applicable to the REST Assured client.
In a testclass annotated with @MicroShedTest, I would like to apply the @JwtConfig annotation or a similar annotation, on the testmethod to apply the same logic as when applied to annotating the Microshed RESTClient with it. When annotation the methods, It should not matter what client being used, whether it is REST Assured or the Microshed RESTClient, the logic of generate and configure a pair of JWT secrets for the ApplicationContainer container, should be executed in order to test endpoints secured with a JWT without a hassle.
An alternative would be updating the documentation and mention two possibilities:
- Provide a JWT in the header of the request
- Configure the RestAssured.authentication property within the test
Started working on this issue!