[Webtest] Do cookies work?

Alan Grover webtest@lists.canoo.com
Tue, 6 May 2003 19:25:25 -0400


Perhaps there is a problem with httpunit keeping a cookie when 
redirect'ed?

I had guessed that each testspec is a new "session" (and have since 
seen that in the code). But, I can't get cookies to work on my site 
within one testspec. Here's the stripped down steps:

             <steps>
                 <invoke 
url="../sessioninit?return=http%3A%2F%2F${host}"/>
             </steps>

Sessioninit replies with a set-cookie and a redirect to a cgi that 
checks for a cookie.  The debug output does not show a cookie being 
sent as webtest follows the redirect, and the cgi is also logging the 
absence of a cookie.

I have to assume that I'm doing something slightly out-of-spec, since 
no-one else has complained about cookie problems. Or, there is some 
subtle bug in webtest that I'm lucky enough to find.

Further testing shows that a my webtest installation will work with 
cookies (at least in a <meta> tag) from another site.


On Tuesday, May 6, 2003, at 03:34 America/Detroit, Dierk Koenig 
localhost wrote:

> Hi Alan,
>
> Cookie handling (better: Session handling) is per TestSpec.
> Every new TestSpec opens a new Session and therefore old Cookies are 
> not
> sent.
>
> cheers
> Mittie
>
>> -----Original Message-----
>> From: webtest-admin@lists.canoo.com
>> [mailto:webtest-admin@lists.canoo.com]On Behalf Of Alan Grover
>> Sent: Freitag, 2. Mai 2003 19:25
>> To: webtest@gate.canoo.com
>> Subject: Re: [Webtest] Do cookies work?
>>
>>
>> I was finally able to try this out (build 276). Below is the output
>> from setLoggingHttpHeaders(true).
>>
>> Why doesn't webtest/httpunit send the cookie (step 3)? Browsers (IE &
>> Mozilla) work. I tried changing the domain of the cookie, but that 
>> made
>> no difference.
>>
>> 1. A 'clickbutton' posted to a page that requires a cookie, so the cgi
>> redirects:
>>   [testSpec] Setup.doExecute: acceptCookies = true
>>
>>   [testSpec] Header:: HTTP/1.0 302 Moved
>>   [testSpec] Header:: Date: Fri, 02 May 2003 16:02:36 GMT
>>   [testSpec] Header:: Server: Apache/1.3.19 (Unix) mod_perl/1.25
>>   [testSpec] Header:: Location:
>> http://dev6.office.techstreet.com/cgi-bin/
>> sessioninit?return=http%3A%2F%2Fdev6.office.techstreet.com%2Fcgi-
>> bin%2Fsubscriptions%2Fhttp%3A%2F%2Fdev6.office.techstreet.com
>>   [testSpec] Header:: Content-Type: text/html
>>
>> 2. Webtest follows. Receiving a page with a cookie header. The page is
>> a dumy, redirecting to a verifier ('sessionval'):
>>
>>   [testSpec] Sending:: User-Agent: httpunit/1.4
>>   [testSpec] Sending:: Accept-Encoding: gzip
>>   [testSpec] Header:: HTTP/1.0 302 Moved
>>   [testSpec] Header:: Date: Fri, 02 May 2003 16:02:36 GMT
>>   [testSpec] Header:: Server: Apache/1.3.19 (Unix) mod_perl/1.25
>>   [testSpec] Header:: Set-Cookie:
>> techstreet_dev6=YLJTHRKSHBNJMTZSMEFZIRLCVCFSRHNQTXJAOUSW;
>> domain=dev6.office.techstreet.com; path=/
>>   [testSpec] Header:: Location:
>> http://dev6.office.techstreet.com/cgi-bin/
>> sessionval?return=http%3A%2F%2Fdev6.office.techstreet.com%2Fcgi-
>> bin%2Fsubscriptions%2Fhttp%3A%2F%2Fdev6.office.techstreet.com
>>   [testSpec] Header:: Content-Type: text/html
>>
>> 3. Webtest follows, but doesn't send the cookie. The cgi at
>> 'sessionval' returns (yet another redirect) to the "you need a cookie"
>> page:
>>
>>   [testSpec] Sending:: User-Agent: httpunit/1.4
>>   [testSpec] Sending:: Accept-Encoding: gzip
>>   [testSpec] Header:: HTTP/1.0 302 Moved
>>   [testSpec] Header:: Date: Fri, 02 May 2003 16:02:38 GMT
>>   [testSpec] Header:: Server: Apache/1.3.19 (Unix) mod_perl/1.25
>>   [testSpec] Header:: Location:
>> http://dev6.office.techstreet.com/cgi-bin/
>> sessionfail?return=http%3A%2F%2Fdev6.office.techstreet.com%2Fcgi-
>> bin%2Fsubscriptions%2Fhttp%3A%2F%2Fdev6.office.techstreet.com
>>   [testSpec] Header:: Content-Type: text/html
>>   [testSpec] Sending:: User-Agent: httpunit/1.4
>>   [testSpec] Sending:: Accept-Encoding: gzip
>>
>>
>>
>> On Wednesday, Apr 16, 2003, at 13:40 America/Detroit, Richard Hill
>> wrote:
>>
>>> Alan,
>>> com.canoo.webtest.steps.Setup has a method doExecute(Context context)
>>> that
>>> you can insert the httpunit option:
>>>
>>>     boolean acceptCookies = HttpUnitOptions.isAcceptCookies();
>>>     System.out.println("Setup.doExecute: acceptCookies = " +
>>> acceptCookies);
>>>
>>> This should let you know if httpunit is accepting cookies.
>>>
>>> You can also set the httpunit option:
>>>
>>>     HttpUnitOptions.setLoggingHttpHeaders(true);
>>>
>>> With this set you can see cookies being set or sent from httpunit as
>>> the
>>> test is running.
>>>
>>> Hope this helps,
>>> - Richard
>>>
>>> -----Original Message-----
>>> From: Alan Grover [mailto:awgrover@mail.msen.com]
>>> Sent: Wednesday, April 09, 2003 7:13 AM
>>> To: webtest@gate.canoo.com
>>> Subject: [Webtest] Do cookies work?
>>>
>>>
>>> Can anyone confirm that cookies are handled by webtest? Or, when they
>>> aren't?
>>> ---
>>> Alan Grover
>>> awgrover@mail.msen.com
>>>
>>> _______________________________________________
>>> WebTest mailing list
>>> WebTest@lists.canoo.com
>>> http://lists.canoo.com/mailman/listinfo/webtest
>>> _______________________________________________
>>> WebTest mailing list
>>> WebTest@lists.canoo.com
>>> http://lists.canoo.com/mailman/listinfo/webtest
>>>
>>>
>> ---
>> Alan Grover
>> awgrover@mail.msen.com
>>
>> _______________________________________________
>> WebTest mailing list
>> WebTest@lists.canoo.com
>> http://lists.canoo.com/mailman/listinfo/webtest
>>
>
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>
>
---
Alan Grover
awgrover@mail.msen.com