I am getting wiremock request which is in encrypted format (either whole body or some fields). I wanted to create a wiremock extension which intercepts wiremock request and replaces encrypted body with decrypted body content (received by calling http post request for decryption). This helps me to create a generic solution to decrypt all incoming wiremcok requests so that matchers can work on decrypted data.
Asked
Active
Viewed 370 times
3
-
Please provide enough code so others can better understand or reproduce the problem. – Community Jul 18 '22 at 13:07
1 Answers
2
To achieve this, implement a subclass of StubRequestFilter
and register it as an extension.
Your class's filter(...)
method will need to wrap the request in a RequestWrapper
that transforms the body by calling transformBody(...)
with a function that decrypts the data.
You can find some examples of this here: https://github.com/wiremock/wiremock/blob/master/src/test/java/com/github/tomakehurst/wiremock/RequestFilterAcceptanceTest.java

Tom
- 3,471
- 21
- 14