繁体   English   中英

无法在请求中设置Cookie

[英]Can't set cookie in the request

我正在为API测试使用可放心的库,似乎无法设置新的cookie。 但是,我可以修改服务器设置的cookie。

given()
  .cookie("cookie1", "true")
  .get(url)
  .then()
  .assertThat().cookie("cookie1", "true");
// Fails with "Cookie "cookie1" was not
// defined in the response. Cookies are: cookie2=true, cookie3=true


given()
  .cookie("cookie2", "false")
  .get(url)
  .then()
  .assertThat().cookie("cookie2", "false");
// PASS

根据REST保证的文档 ,您需要调用when()body()方法:

given()
.cookie("cookie1", "true")
.when() // <----
.get(url)
.then()
.assertThat()
.body(equalTo("true")) // <----

请注意,我从未使用过此API,而只是根据提供的规范进行推测。

你应该尝试这样的事情

given().
                proxy(host("http.proxy.someDomain.com").withScheme("http").withPort(xxxx)).

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM