In our project we have an other project B dependency. I'm trying to write Integration tests for this flow.
Project B has hard coded API : https://store-platform-dev/items with some headers.
I tried using wiremock stub with proxiedFrom(https://store-platform-dev/items)
withHost(https://store-platform-dev/items)
And also proxyvia(), nothing seemed to work. Stubbing is not happening and the api call is not returning stubbed response.
How to approach this? Since it's the external project we can't even make changes to their api.
If Project B has the hostname hardcoded to store-platform-dev
you only have two options:
store-platform-dev
is resolved to get it resolving to WireMockFor 1 - if you're running locally obviously you could use /etc/hosts
to map store-platform-dev
to 127.0.0.1
. Or you could use dnsmasq or similar to run your own DNS server to map store-platform-dev
to 127.0.0.1
.
For 2 - see "Running as a browser proxy" in WireMock | Proxying. You can run WireMock as a browser proxy programatically as so:
WireMockServer wireMockServer = new WireMockServer(options()
.enableBrowserProxying(true)
);
wireMockServer.start();