【问题标题】:Response cookies using for next requests用于下一个请求的响应 cookie
【发布时间】:2020-03-10 07:00:12
【问题描述】:

正如我从this question 的答案中看到的那样:空手道将在下一个请求中自动发送服务器返回的任何 cookie。

但是当我发送请求时,我在响应的 Set-Cookie 中看到两组 cookie:一组是自动创建的,另一组是真实的,从服务器返回。

当我打印 responseCookies 时,我看到那里只有自动 cookie 并为下一个请求生成并发送新的 cookie。

对于我的测试,我需要使用第一次请求后返回的 cookie,因为它是对登录服务的调用。

Feature: Using cookies in next request

    Background:
    Given url baseUrl
    And path LOGOUT_SERVICE_ENDPOINT
    And configure headers = read('classpath:headers.js')
    And def filename = 'classpath:resources/users/' + brand.toLowerCase() + '/user.json'
    And json user = read(filename)

    Scenario: Login
    When def login =  callonce read('classpath:features/login_service/login.feature') user
    * print login.responseCookies
    And request { arg1: '#(brand)'}
    And method post
    Then status 200

我的功能有什么问题还是空手道问题?

【问题讨论】:

    标签: cookies karate


    【解决方案1】:

    响应的Set-Cookie中的两组cookie:

    也许这是服务器的错误?

    也可以尝试使用"shared scope",因为 cookie 也将成为“全局”变量等的一部分。

    * callonce read('classpath:features/login_service/login.feature') user
    * request { arg1: '#(brand)'}
    

    如果还是卡住,请按照这个流程:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

    【讨论】:

    • 我发现来自服务器的响应有一个 SET-COOKIE 标头(大写)。这不好,但这不是问题,因为根据 HTTP 标头名称不区分大小写,根据 RFC 2616:4.2: > 每个标头字段由一个名称后跟一个冒号(“:”)和字段值组成。字段名称不区分大小写。所以我认为问题出在 Set-Cookies 标头解析中”
    猜你喜欢
    • 2020-11-08
    • 1970-01-01
    • 1970-01-01
    • 2018-03-16
    • 2016-07-26
    • 1970-01-01
    • 2019-09-11
    • 1970-01-01
    • 2012-05-02
    相关资源
    最近更新 更多