Objective:
- We want few API calls should go to mock-server(
https://192.x.x.x:8001) and others should go to an actual downstream application server(https://dev.api.acme.com).
Setup :
- On local, mock server is up with standalone jar on port 8001. e.g
https://192.x.x.x:8001 - In application config file
(config.property)downstream system(which need to mock) defined with mockserver IP i.ehttps://192.x.x.x:8001
Testing scenario and problem:
1.
Scenario: pathMatches('/profile/v1/users/{id}/user')
* karate.proceed('https://dev.api.acme.com')
* def response = read ('findScope.json')
* def responseStatus = 200ˀˀ
* print 'created response is: ' + response
Now, when we hit API request via postman or feature file then it does karate.proceed properly to
https://dev.api.acme.com/profile/v1/users/123/userinstead of192.x.x.x.However, in this request, host is referring tohttps://192.x.x.x:8001instead ofhttps://dev.api.acme.comwhich create a problem for us.How can we override request header in this case? I did try with
karate.setand also withheader host=https://192.x.x.x:8001but no luck.
Thanks!