Hello guys.
If you're using Mojolicious, you most likely test your app by
Test::Mojo. It works greates for testing cases when the visitor is a guest.
But if you're going to write a Facebook killer, you'll be missing a way
to test protected parts of your site because it's hard to calculate
cookies manually.
Please consider an example here
(
https://gist.github.com/alexbyk/ad427b4aed2ebaba73a5)
Right now it's impossible (or very hard) to test what's going on because
routes are protected (we have to encrypt cookie manually and get somehow
a csrf_token)
Of course, You can do it something like this (a weird way):
# log in and find csrf_token in the html output
$t->get_ok('/')->post('/login', form => {pass => 'pass', login => 'login'});
my $csrf = $t->ua->get('/')->res->dom->at('#csrf')->text;
But that doesn't look like a right way.
It would be greate to have something like this:
$t->session(user => 'Cartman');
my $token = $t->csrf_token;
If you find those features useful and you miss them to, please vote for
them (thumbs up or '+1' appreciated) here. You can take a closer look
here
https://github.com/kraih/mojo/pull/640 and if you can propose a
better way to do such things, pls let me know