I need to test making a request for a restricted resource, both as an authenticated and unauthenticated user.
I have a method on my request object that allows me to set the current user.
e.g., $app->req->set_user($user)
It depends on the Session middleware having been loaded.
First I test the unauthenticated case:
my $t = Kelp::Test->new(app => MyApp->new);
$t->request(GET $url)->code_is(302);
No problem. The user is redirected to the signin/registration page as expected.
But now how would I set the user as part of a request?
Should I be doing these tests at a different level (e.g., with WWW::Mech or something where I perform the actual login as part of the test)?
I was thinking an advantage of this level is direct access to the $app, but I don't see much to hook onto.
Suggestions?
Thanks