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

add cookies/headers to the RESTClient decorator

Open a-simoes opened this issue 5 years ago • 2 comments
trafficstars

I have a lot of tests that use the RESTClient decorator.

Due to some security concerns, now we need to exchange a session cookie. This cookie must remain the same between requests on some operations.

It would be nice if we can use something like RESTClient(headers = {header1, header2}) public static MyService myService;

I know it is possible to use the RestClientBuilder, but I do prefer the decorator approach!

a-simoes avatar Sep 01 '20 13:09 a-simoes

hi @a-simoes, thanks for raising this idea. Are the headers you need to add static/final strings? Keep in mind that annotation values must be constants. If you generate the header values at runtime, or even if they have to be created by a function, then they cannot be used in annotation attributes because they are not constant values.

aguibert avatar Sep 01 '20 15:09 aguibert

Hi @aguibert . I understand that only static/final strings could be added and not runtime values. That is completely ok. For this particular case, it will work perfectly.

a-simoes avatar Sep 02 '20 08:09 a-simoes

@a-simoes are you still interested in this enhancement? Have you considered using RestAssured to overcome this issue?

appiepollo14 avatar Jan 03 '24 21:01 appiepollo14

nop. I ended up creating a custom REST client.

a-simoes avatar Jan 04 '24 12:01 a-simoes