sumit
sumit

Reputation: 241

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

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)

Upvotes: 1

Views: 81

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58088

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.

Upvotes: 0

Related Questions