Proxy "selected requests" to my mock server

I have a wiremock server running in a remote server. I’m mocking some api’s(registering stubs via wiremock groovy client) before running my test cases, without chaning my application code how can i reroute my api’s to my remote wiremock server.

Is there any way I can proxy “only” those api requests to my mock server via katalon studio? what exactly is proxy preference in katalon studio? Can I use it somehow to achieve what I want?

I believe, no, there isn’t.

You need to introduce a sort of “Reverse Proxy” in between the HTTP client (= Katalon Studio Test Case) and your target HTTP server.

Which product? I don’t know. I google-searched “Reverse proxy” and I found Nginx Reverse Proxy as a candidate. I remembers that I touched Squid years ago.

Or you could write a Java/Groovy code that performs exactly what you want.

Can I do that (introducing Reverse proxy) without changing my application code that is under testing?

Should I have to configure the proxy in the system(where Jenkins will run our testcases)

If you have a Proxy up and running outside Katralon Studio, you can configure Katalon Studio to talk to the proxy.

(The Proxy can run on another network node in your loca area network, or on your PC itself, it does not matter.)

Have a look at this.

https://docs.katalon.com/docs/get-started/set-up-your-workspace/katalon-studio-preferences/configure-proxy-preferences-in-katalon-studio

Possibly you want to configure “system proxy” to let your test script send HTTP request to the Proxy.

The “Authentication proxy” is something concerned about the licensing etc, which you would not be interested in.

hi @saravanan.m

you do not need a separate reverse proxy, wiremock already is one. register a lowest priority catch all stub that proxies to the real backend:

wm.register(any(anyUrl()).atPriority(10).willReturn(aResponse().proxiedFrom('https://real-api.example.com')))

your specific stubs at a higher priority win, everything else passes through to the real api. then only one thing has to change: where the client sends traffic.

for api tests in katalon that is just a GlobalVariable for the base url, point the profile at the wiremock host.

for a browser app you cannot change, redirect at the browser level instead of the system proxy. chrome’s --host-resolver-rules="MAP api.example.com wiremock-host" as a chromeOptions arg (project settings > desired capabilities > web ui > chrome) sends only that hostname to wiremock, nothing else is touched. port must match, and for https wiremock needs a cert the browser trusts or --ignore-certificate-errors. a pac file via --proxy-pac-url works too if you need rules per path.

katalon’s own proxy preference is for the studio process (licensing, http client), not for selectively rewriting your application’s calls.

Katalon’s proxy preference only tells Katalon to send traffic through a proxy; it doesn’t choose which requests go where, so “only these APIs” has to be decided outside Katalon. WireMock can already do it: register a low-priority catch-all stub that proxies to the real backend (proxiedFrom(...)), and your specific stubs at a higher priority will win. Then you only need to change where the client sends traffic.

For API tests, point your base URL (a GlobalVariable) at the WireMock host. For a browser app you can’t change, you can map just that hostname to WireMock with Chrome’s --host-resolver-rules="MAP api.example.com wiremock-host:port" argument in the desired capabilities, so nothing else is rerouted.