【问题标题】:testing cookies on flags在标志上测试 cookie
【发布时间】:2018-05-24 20:15:06
【问题描述】:

我正在尝试在 Postman App (Chrome ext.) 中编写一些测试。我有一个简单的 HTTP 请求:

GET /BusinessBanking/ HTTP/1.1
Host: www.mojebanka.cz

返回两个不同的 cookie,具有不同的 HTTP 和安全标志。

cookie flags

现在我运行这些测试,所有测试都通过了:

tests ["cookie1 HTTP"] = postman.getResponseCookie("JSESSIONID").http = true;
tests ["cookie1 secure"] = postman.getResponseCookie("JSESSIONID").secure = true;
tests ["cookie2 HTTP"] = postman.getResponseCookie("language").http = true;
tests ["cookie2 secure"] = postman.getResponseCookie("language").secure = true;

所以我的问题是,如何在 HTTP 和安全标志上测试这些 cookie?

【问题讨论】:

  • 我不是在测试值,我想在 HTTPonly 和安全标志上测试 cookie。我已将所有测试更改为=== true,现在除了第二次测试之外所有测试都失败了。我读过一些关于 JS 无法访问 HTTPonly cookie 的内容,但我可以轻松地在他们的其他标志(值、路径等)上运行测试;所以我不确定,“在 JS 中无法访问 httpOnly cookie”究竟是什么意思
  • 在 Postman 应用程序 cookie 标志指定中(至少 HTTP 作为 httpOnly)似乎也是错误的。还是谢谢。

标签: javascript cookies postman


【解决方案1】:

我想通了,如何对 HTTPonly 和安全标志进行测试:

tests ["cookie1 HTTP"] = postman.getResponseCookie("JSESSIONID").httpOnly === true;
tests ["cookie1 secure"] = postman.getResponseCookie("JSESSIONID").secure === true;
tests ["cookie2 HTTP"] = postman.getResponseCookie("language").httpOnly === false;
tests ["cookie2 secure"] = postman.getResponseCookie("language").secure === false; 

因此,即使是 HTTPonly(或准确地说是 httpOnly)cookie 也可以通过这种方式进行测试。

【讨论】:

    猜你喜欢
    • 2011-05-18
    • 2019-07-26
    • 2021-07-30
    • 1970-01-01
    • 2017-09-11
    • 2023-02-19
    • 2013-04-02
    • 2015-11-02
    • 1970-01-01
    相关资源
    最近更新 更多