I recently found a way to verify multiple Set-Cookie header fields. The
problem was that storeHeader only stores the first Set-Cookie if multiples
are set. In my case i needed to verify JSESSIONID but another Set-Cookie
always appeared first.

groovy step is your friend:

groovy(description:'examine Set-Cookie response header fields', """
            def setCookieHeaders =
step.context.currentResponse.webResponse.responseHeaders.grep { it.name ==
'Set-Cookie'}
            step.setWebtestProperty('firstCookie', setCookieHeaders.find
{it.value =~ /.*first-cookie.*/}?.value )
            step.setWebtestProperty('secondCookie', setCookieHeaders.find
{it.value =~ /.*second-cookie.*/}?.value )
            step.setWebtestProperty('jsessionid', setCookieHeaders.find {it
=~ /.*JSESSIONID=.*/}?.value)

verifyProperty(description:'Set-Cookie response field contains JSSESSIONID',
regex:'true', name: "jsessionid", text:'JSESSIONID=.*')
        """)

I hope that helps if someone is coping with webtest and cookie handling

Regards 

Sebastian
-- 
View this message in context: 
http://old.nabble.com/Multiple-response-field-Set-Cookie-handling-tp27637118p27637118.html
Sent from the WebTest mailing list archive at Nabble.com.

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to