Hi Team,
1. Is it possible to fetch dynamic value in request header (not in response) in line no 75 of this image.
2. To have the value of that key, inorder to validate the content inside it. (For reference in line 79).
Thanks.
b
Bas Dijkstra
05/02/2023, 3:13 PM
@Shruti Mishra: a request filter will help here. Extract the request header value, perform the verification you need and based on that, either continue processing the request or seen back a response (probably a 401 in case of failed verification)
s
Shruti Mishra
05/02/2023, 3:27 PM
@Bas Dijkstra
Probably 2 things:
What can be passed as a value of
"Auth" : ""
Is method call is allowed under the stubFor block?
If yes then will include
"Auth" : filter("value")
All incoming requests will pass through the filter before WireMock tries to find a response definition for them, so you don’t need to change your stubFor() method, although you can remove the request matching on the Authorization header, because the request filter takes care of that.
s
Shruti Mishra
05/02/2023, 4:07 PM
Okay @Bas Dijkstra that means just registering the request filter class in the implementation class will work.
Thanks!
b
Bas Dijkstra
05/02/2023, 4:11 PM
Yes. Again, please have a look at the examples and let me know if you worked it out, or if you’re stuck. Happy to help once I get back to work (Thursday) if needed.