[英]Unable to validate response headers from a REST API using Karate
我有一个简单的 REST API 允许在给定端点中发布资源,并且我想验证响应标头是否设置正确。 我已经定义了以下功能,它在数据库中插入了一堆用户:
Scenario Outline: Creating a bunch of new users when the database is empty
Given header Content-Type = 'application/json'
And request __row
When method post
Then status 201
* match header Content-Type == 'application/json'
* match header Location == 'http://localhost:8080/users/'+response.id
Examples:
| users |
用户已正确插入,在控制台中我可以看到以下响应标头:
1 < 201
1 < Connection: keep-alive
1 < Content-Type: application/json
1 < Date: Mon, 22 Feb 2021 14:06:31 GMT
1 < Keep-Alive: timeout=60
1 < Location: http://localhost:8080/users/user1@test.com
1 < Transfer-Encoding: chunked
但是每次我尝试运行这个测试时,我都会得到相同的响应:
path: $['Content-Type'][0], actual: null, expected: 'application/json', reason: actual json-path does not exist
在 0.9.6 上为我工作
* url 'https://httpbin.org/get'
* method get
* match header Content-Type == 'application/json'
但正如我在评论中提到的,请尝试 1.0 / RC 版本: https://github.com/intuit/karate/wiki/1.0-upgrade-guide
因为我们正在集中精力。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.