Webinject - 解析 cookie 的内容

发布于 2024-12-07 03:49:28 字数 1461 浏览 0 评论 0原文

我有一个 Webinject 测试用例,需要使用之前收到的 cookie 的内容设置一个附加标头。我的第一个测试用例登录到 Web 应用程序并获取用于识别的令牌。 cookie的部分内容需要设置为附加标头。我怎样才能实现这个目标?

将设置的 Cookie 如下所示:

    login=user%40myurl.com; __utma=1.748102029.1314655544.1314657537.1316179965.3; __utmz=1.1316179965.3.2.utmcsr=myurl.com|utmccn=(referral)|utmcmd=referral|utmcct=/subpage; __utma=1.748102029.1314655544.1314657537.1316179965.3; __utmz=1.1316179965.3.2.utmcsr=murul.com|utmccn=(referral)|utmcmd=referral|utmcct=/subpage; JSESSIONID=E976943F6BA0D6FDCC7567BAA5988F77; __utmb=1.3.10.1317046713; __utmc=1; token=44962ede5de74d45b1162a935ee18fbf; identifier=""; login=user%40myurl.com

测试用例如下所示。

<case
id="2"
description1="Logging into Login Page"
method="post"
url="http://myurl.com"
postbody="name=user%40myurl.com&password=12345&fragment=}"
verifynegative="^.*The user name and/or password is incorrect!.*$"
verifyresponsecode="302"
errormessage="Could not login (wrong credentials?)"
parseresponse="token=|;"
logresponse="yes"
logrequest="yes"

>> 这是我想解析 cookie 的地方,但我认为它只是解析响应。

<case
id="3"
description1="Open Subpage"
method="get"
url="http://myurl.com/subpage"
addheader="x-subpage-id:{PARSEDRESULT}"
verifyresponsecode="200"
verifypositive="^.*Title: foo bar.*$"
errormessage="Unable to open View"
logresponse="yes"
logrequest="yes"

>>

这是我想添加附加标头的地方。它一定是我想要解析的 cookie 的部分。

I have a Webinject testcase that needs to set an additional header with the content of a previously received cookie. My first testcase logs into a web application and gets a token for identification. Parts of the content of the cookie need to be set as additional header. How can I achieve this?

The Cookie which will be set looks like this:

    login=user%40myurl.com; __utma=1.748102029.1314655544.1314657537.1316179965.3; __utmz=1.1316179965.3.2.utmcsr=myurl.com|utmccn=(referral)|utmcmd=referral|utmcct=/subpage; __utma=1.748102029.1314655544.1314657537.1316179965.3; __utmz=1.1316179965.3.2.utmcsr=murul.com|utmccn=(referral)|utmcmd=referral|utmcct=/subpage; JSESSIONID=E976943F6BA0D6FDCC7567BAA5988F77; __utmb=1.3.10.1317046713; __utmc=1; token=44962ede5de74d45b1162a935ee18fbf; identifier=""; login=user%40myurl.com

The testcases look like the following.

<case
id="2"
description1="Logging into Login Page"
method="post"
url="http://myurl.com"
postbody="name=user%40myurl.com&password=12345&fragment=}"
verifynegative="^.*The user name and/or password is incorrect!.*$"
verifyresponsecode="302"
errormessage="Could not login (wrong credentials?)"
parseresponse="token=|;"
logresponse="yes"
logrequest="yes"

/>
This is where I want to parse the cookie but I think it is only parsing the response.

<case
id="3"
description1="Open Subpage"
method="get"
url="http://myurl.com/subpage"
addheader="x-subpage-id:{PARSEDRESULT}"
verifyresponsecode="200"
verifypositive="^.*Title: foo bar.*$"
errormessage="Unable to open View"
logresponse="yes"
logrequest="yes"

/>

This is where I want to add the addition header. It must be the parts from the cookie I want to parse.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想念有你 2024-12-14 03:49:28

启用 http.log,并查看第一次测试的结果;您应该会看到“Set-Cookie:”行。这对解析器是可见的,即它被考虑。像这样:

Set-Cookie: sessionid=5c028a746958eef2126dd397c20449a4; expires=Sat, 21-Jul-2012 15:40:03 GMT; httponly; Max-Age=1209600; Path=/

在您的情况下,cookie 应该提供更多信息。然后,parseresponse 允许使用正则表达式,因此如果您可以找出所需内容的分隔符,那么您就解决了。

webinject 邮件列表可以更及时地回答问题。
https://groups.google.com/forum/?fromgroups#!forum/webinject

enable http.log, and look at the result from your first test; you should see a 'Set-Cookie:' line. This is visible to the parser, i.e. it gets considered. Like so:

Set-Cookie: sessionid=5c028a746958eef2126dd397c20449a4; expires=Sat, 21-Jul-2012 15:40:03 GMT; httponly; Max-Age=1209600; Path=/

The cookie should be more informative in your case. Then, parseresponse allows to use regular expressions, so if you can make out the delimiter around what you need, you are settled.

The webinject mailing list answers questions in a more timely manner.
https://groups.google.com/forum/?fromgroups#!forum/webinject

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文