In karate mocking (karate-netty), how can we override request header value?

Viewed 398

Objective:

  1. 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 :

  1. On local, mock server is up with standalone jar on port 8001. e.g https://192.x.x.x:8001
  2. In application config file (config.property)downstream system(which need to mock) defined with mockserver IP i.e https://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
  1. 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/user instead of 192.x.x.x. However, in this request, host is referring to https://192.x.x.x:8001 instead of https://dev.api.acme.com which create a problem for us.

  2. How can we override request header in this case? I did try with karate.set and also with header host=https://192.x.x.x:8001 but no luck.

Thanks!

1 Answers
  1. Please see if the 1.0 version works: https://github.com/intuit/karate/wiki/1.0-upgrade-guide

  2. Unfortunately https proxying may not work as mentioned. If you are depending on this, we may need your help (code contribution) to get this working

  3. If the Host header is still not mutable, that also can be considered a feature request, and here also I'd request you to consider contributing code

Related