3

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.

shekhar
  • 31
  • 1

1 Answers1

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