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?
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.
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.