开发者

Webinject - Parse content of a 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%40myu开发者_JAVA技巧rl.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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜