Karate 空手道提出了两个要求

Karate 空手道提出了两个要求,karate,web-api-testing,Karate,Web Api Testing,在我的空手道项目中,我有以下场景的一个特点。对于我提出的请求,我得到了预期的响应,但有第二个相同的请求是无意的 我注意到第二个请求包含一个额外的头字段“Cookie:” Feature: Get the authorization Scenario: Retrieve Login page url Given url 'http://someUri:port' And path '/secure/author' And param response

在我的空手道项目中,我有以下场景的一个特点。对于我提出的请求,我得到了预期的响应,但有第二个相同的请求是无意的

我注意到第二个请求包含一个额外的头字段“Cookie:”

Feature: Get the authorization
 Scenario: Retrieve Login page url     
      Given url 'http://someUri:port'
      And path '/secure/author'
      And param response_type = 'code'
      And param client_id = 'valid_clientID'
      And param scope = 'link_submit'
      And param redirect_uri = 'https://someotherUri'
      When method get
      Then status 302
下面是我的控制台

20:19:26.955 [main] INFO  com.intuit.karate - karate.env system property was: null 
20:19:27.998 [main] DEBUG com.intuit.karate - request:
1 > GET http://uri:port/security/authorize?correct-Parameters-are-here
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Host: the host
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_221)

20:19:31.377 [main] DEBUG com.intuit.karate - response time in milliseconds: 3374.29
1 < 302
1 < Connection: Keep-Alive
1 < Date: Mon, 09 Sep 2019 21:40:38 GMT
1 < Location: http:wantedurl.com
1 < Set-Cookie: linkCookie="/V455555555555rhuaUFYc3pkwQ="; Version=1; Path=/
1 < Transfer-Encoding: chunked
1 < X-Content-Type-Options: nosniff
1 < X-Frame-Options: DENY
1 < X-XSS-Protection: 1; mode=block
1 < activityID: 222222222444424

20:19:31.398 [main] DEBUG com.intuit.karate - request:
2 > GET http://uri:port/security/authorize?correct-Parameters-are-here
2 > Accept-Encoding: gzip,deflate
2 > Connection: Keep-Alive
2 > Cookie: $Version=1; linkCookie="/VvfdfdlV3ZRawnoIY83QrhuaUFYc3pkwQ="; $Path="/"
2 > Host: the host
2 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_221)

20:19:31.755 [main] DEBUG com.intuit.karate - response time in milliseconds: 352.96
2 < 200
2 < Accept-Ranges: bytes
2 < Access-Control-Allow-Headers: Content-Type,x-openui
2 < Access-Control-Allow-Methods: GET
2 < Access-Control-Allow-Origin: *
2 < Cache-control: private
2 < Connection: Keep-Alive
2 < Content-Type: text/html
2 < Date: Mon, 09 Sep 2019 21:40:38 GMT
2 < ETag: "288-59152f593c040"
2 < Last-Modified: Fri, 30 Aug 2019 10:19:37 GMT
2 < Set-Cookie: 34c188e0698035e66376b276a0a05cd4=f2a878936046ce053dcdc55f78d1e7ca; path=/; HttpOnly; Secure
2 < Transfer-Encoding: chunked
2 < activityID: 31910620180969978101601944
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>some titile</title><base href="."><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><link href="styles.ea03e93ac5f3a194d43b.bundle.css" rel="stylesheet"/></head><body><app-root></app-root><div id="test"></div><script type="text/javascript" src="inline.318b50c57b4eba3d437b.bundle.js"></script><script type="text/javascript" src="polyfills.9e6fb2e22bb7bf8ba831.bundle.js"></script><script type="text/javascript" src="main.7aff2d014e2a36462a25.bundle.js"></script></body></html>

[Fatal Error] :1:3: The markup in the document preceding the root element must be well-formed.
20:19:31.820 [main] WARN  com.intuit.karate - xml parsing failed, response data type set to string: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 3; The markup in the document preceding the root element must be well-formed.
20:19:31.823 [main] ERROR com.intuit.karate - status code was: 200, expected: 302, response time: 353, url: http://uri:port/security/authorize?correct-Parameters-are-here, response: <!doctype html><html lang="en"><head><meta charset="utf-8"><title>title goes here</title><base href="."><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><link href="styles.ea03e93ac5f3a194d43b.bundle.css" rel="stylesheet"/></head><body><app-root></app-root><div id="test"></div><script type="text/javascript" src="inline.318b50c57b4eba3d437b.bundle.js"></script><script type="text/javascript" src="polyfills.9e6fb2e22bb7bf8ba831.bundle.js"></script><script type="text/javascript" src="main.7aff2d014e2a36462a25.bundle.js"></script></body></html>
20:19:26.955[main]INFO com.intuit.karate-karate.env系统属性为:null
20:19:27.998[main]调试com.intuit.karate-请求:
1>获取http://uri:port/security/authorize?correct-参数在这里
1>接受编码:gzip,deflate
1>连接:保持活动状态
1>主机:主机
1>用户代理:Apache HttpClient/4.5.5(Java/1.8.0_221)
20:19:31.377[main]DEBUG com.intuit.karate-响应时间(毫秒):3374.29
1 < 302
1<连接:保持活动
日期:2019年9月9日星期一21:40:38 GMT
1<位置:http:wantedurl.com
1获得http://uri:port/security/authorize?correct-参数在这里
2>接受编码:gzip,deflate
2>连接:保持活动状态
2>Cookie:$Version=1;linkCookie=“/VvfdfdlV3ZRawnoIY83QrhuaUFYc3pkwQ=“$Path=“/”
2>主机:主机
2>用户代理:Apache HttpClient/4.5.5(Java/1.8.0_221)
20:19:31.755[main]DEBUG com.intuit.karate-响应时间(毫秒):352.96
2 < 200
2<接受范围:字节
2<访问控制允许标题:内容类型,x-openui
2<访问控制允许方法:获取
2<访问控制允许原点:*
2<缓存控制:专用
2<连接:保持活动
2<内容类型:文本/html
日期:2019年9月9日星期一21:40:38 GMT
2
是的,这是正确的行为-请注意,对于第一个请求。在本例中,响应为您提供了一个名为
linkCookie
的cookie

您的请求是一个
GET
,看起来应该可以。在一些罕见的情况下,你需要这样做


还可以在文档中查找
followRedirects

非常感谢。老实说,我不知道URL重定向和cookies。我将禁用followRedirects。我的最终目标是从第一个响应中的“位置”中提取值。