microshed-testing icon indicating copy to clipboard operation
microshed-testing copied to clipboard

Testing JWT endpoint with RESTassured

Open appiepollo14 opened this issue 1 year ago • 1 comments

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:

  1. Provide a JWT in the header of the request
  2. Configure the RestAssured.authentication property within the test

appiepollo14 avatar Jun 22 '23 05:06 appiepollo14

Started working on this issue!

appiepollo14 avatar Dec 28 '23 12:12 appiepollo14