Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lib/mana.pm
- get '/' => sub {
- template 'index.tt' => { login => session('user')};
- };
- post '/login' => sub {
- redirect '/login' unless
- Mana::Interface::checkLogin({ params });
- session user => params->{ login };
- redirect '/';
- };
- t/002.pm
- use strict;
- use warnings;
- use Mana;
- use Test::More tests => 3;
- use Plack::Test;
- use HTTP::Request::Common;
- use HTTP::Cookies;
- my $jar = HTTP::Cookies->new;
- my $app = Mana->to_app;
- is( ref $app, 'CODE', 'Got app' );
- my $test = Plack::Test->create($app);
- my $req = POST "/login?login=bapt&password=mdp";
- $jar->add_cookie_header($req);
- my $res = $test->request($req);
- ok( $res->is_redirect, "[GET /login] successful" );
- $res = $test->request( GET "/" );
- ok( $res->is_success, "[GET /] successful" );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement