karate api testing : Is response header validated based on request headers

30 Views Asked by At

I have an api example -

/get/userBundle

Request header - Accept = application/zip

Response assertion - status == 200.

If response status = 200, but response is NOT of type zip but json response or any other format, will the test fail without having any other assertion for response header or response body.

is it necessary to add assertion of response body to be zip or response header to be application/zip ? or response type is by default validated based on request header (Accept)

1

There are 1 best solutions below

2
Peter Thomas On

Response headers are not validated automatically. You can easily add them: https://github.com/karatelabs/karate#match-header

Here is an example:

* url 'https://httpbin.org/anything'
* method get
* match header Content-Type == 'application/json'

Personally I don't think these add much value.