Using wiremock, can I return a body that is dependent on the post request

后端 未结 6 840
盖世英雄少女心
盖世英雄少女心 2021-02-12 20:10

I am trying to test an openid provider class. The openid consumer class is making an http request. I am mocking the response to this request using wiremock. I am trying to mock

6条回答
  •  孤独总比滥情好
    2021-02-12 20:53

    Wiremock supports extensions that you can write yourself that act as a middleware used to intercept the request and response bodies so you can format it however you like. It's very flexible and allows you to make up new response bodies dynamically or even no response at all.

    As an example, we wrote an extension for this at Opentable and open sourced it on Maven Central. It allows you treat the json attributes as variables and interpolate them into your response body. Check it out. Let us know how it goes or if you have any questions. https://github.com/opentable/wiremock-body-transformer

提交回复
热议问题