[Catalyst] Testing controller which require login.
Louis Erickson
lerickson at rdwarf.net
Thu May 14 14:39:14 GMT 2009
I'm using AuthTkt, and it works very well.
Why didn't it occur to me to look at the tests for it?
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?
Looking at Catalyst::Test, it seems to call the same function, at least
for local requests. The same environment variable should work. It isn't
implemented for remote requests, so I guess it isn't a general case.
> I would love to see some basic cookie features in Catalyst::Test, and if
> I knew the Right Way to do it, I'd be happy to add code. I use
> Catalyst::Test for most things. It is simple, comes with Catalyst so
> there's no extra dep. I have used the Mech tests too, and Mech is cool.
> But I like keeping my deps down where I can.
It looks to me like it would be pretty straightforward... there's a
function called _customize_request which takes the contents of a hash and
adjusts the request before it is used. Currently that only lets the host
be set. To add the setting of cookie values to that hash looks
straightforward. It would then work with both local and remote queries,
too. I wonder if it could be generalized to let you set any header at
all?
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?
--
Louis Erickson - lerickson at rdwarf.net - http://www.rdwarf.com/~wwonko/
If you push the "extra ice" button on the soft drink vending machine,
you won't get any ice. If you push the "no ice" button, you'll get
ice, but no cup.
More information about the Catalyst
mailing list