https://linen.dev logo
#help
Title
# help
s

Sreedhar Singaraju

05/05/2023, 4:45 AM
so my requirment is when localhost:8000/getbalance is called it should come to wiremock running at 9000 and retun 404 inst4ead of what actual service returns
b

Bas Dijkstra

05/05/2023, 5:26 AM
Hey @Sreedhar Singaraju, in that case you’ll need to configure your app to send the requests to port 9000, where WireMock is running. WireMock can then either send responses you defined or forward the requests to the actual endpoint, but you’ll need to tell your app to go to WireMock first.
s

Sreedhar Singaraju

05/05/2023, 5:32 AM
Ok let me tell my scenario
There are bunch of services which are caling into each other using resttemplate
i domt have liberty to go ad chanfe code to mke them call different endpoint
thats why i am exploring interceptors who can give me control to inject different responses and simulate failures from a service
example Payment services calls Balnking Service
I canot change ether of servuce code
So i want to mock say endpoints of Babking srvice which Paymet Service calls but inject response as per my test scenario say Internal error injection
i hope I could explain my scenario cearly
b

Bas Dijkstra

05/05/2023, 6:57 AM
Yes, that's clear. And the app you're testing calls the Payment service?
s

Sreedhar Singaraju

05/05/2023, 7:10 AM
Yes
App can be treated outside platform
So my intention and scope is to check out inside platform communictions and inject exceptions based on scenarios
so app which calls is not of scope
b

Bas Dijkstra

05/05/2023, 8:57 AM
Wouldn't it be much simpler to just mock the calls to the Payment service and forget about everything downstream? If not I'm not sure how WireMock would be able to support what you're trying to do
s

Sreedhar Singaraju

05/05/2023, 10:17 AM
even if it to call to Payment Service the problem statement is same
What I want is without stopping the Payment Service I want to intercept the endpoint calls and provide mocked response
How can it be done
I dont have control on who calls into Payment service as outside platform is blackbox
I am exploring if wiremock can intercept those calls and provide the configured responses for the defined end points
i know little bit about proxy-all option for the jar may help here but not quite sure
b

Bas Dijkstra

05/05/2023, 11:00 AM
What you probably need to look into is the proxying mode indeed. https://wiremock.org/docs/proxying/ The question is, where to put the proxy? At some point you need to tell some of your apps to route traffic through WireMock in some way, there's no escaping that as far as I can see. It's a little difficult without more details (and seeing what you're working with) to give a definite answer.