[Catalyst] Testing controller which require login.
Peter Karman
peter at peknet.com
Thu May 14 18:51:11 GMT 2009
Louis Erickson wrote on 05/14/2009 09:39 AM:
>
> I'm using AuthTkt, and it works very well.
glad to hear it.
If you're using AuthTkt, then the whole cookie this is a non-issue. Just
pass the ticket as a URL param like the tests do. The plugin supports
both ways (cookie and param).
>
> Why didn't it occur to me to look at the tests for it?
I have had to learn that habit myself.
>
> On Thu, 14 May 2009, Peter Karman wrote:
>
>> You can see the AuthTkt tests here[0]. The my_request() function just
>> sets $ENV{COOKIE} and lets the standard AsCGI magic work. I'm sure
>> that's a Bad Way to Do It, but it works.
>
> Why is it a bad way? If it's a standard and documented part of AsCGI,
> then it should continue to work properly, shouldn't it?
>
It should probably be:
local $ENV{COOKIE} = $cookie;
instead. It's a little nitpicky, since in this particular case setting
the global env var doesn't hurt, but in general I try to avoid setting
class/global/env vars unless I really want global behaviour.
> The question I asked in the other message about cookies and Catalyst::Test
> is: Is that a good idea? Should it get added and/or documented, and let
> people use it, or should people be pointed at Mechanize or other tools?
>
Seems like a good idea to me to make some sort of official way to
get/set cookies in Catalyst::Test. I won't have time soon to try it
myself; care to try a patch yourself?
--
Peter Karman . peter at peknet.com . http://peknet.com/
More information about the Catalyst
mailing list