Test fix.
[blog.pm-common-perl-mods.git] / CatalystX-Plugin-Authorization-ACL-Paranoid / t / live.t
blobcb7082b13205d59dab844426212fb6faa9555d0d
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use lib 't/lib';
8 use Test::More 'no_plan';
10 BEGIN {
11 eval {
12 require Test::WWW::Mechanize::Catalyst;
13 require Catalyst::Plugin::Authentication;
14 require Catalyst::Plugin::Session;
15 require Catalyst::Plugin::Session::State::Cookie;
18 plan skip_all => 'Many plugins are required' if $@;
20 use_ok 'Test::WWW::Mechanize::Catalyst', 'TestApp';
23 my $m = Test::WWW::Mechanize::Catalyst->new;
25 is_allowed( '/', 'index page' );
27 is_allowed( '/user_login', 'index page' );
29 is_denied( '/post_delete', 'post delete' );
31 is_denied( '/user_logout', 'logout before login' );
33 login( 'user', 'password');
35 is_denied( '/user_login', 'login again after login' );
37 is_allowed( '/post_delete', 'delete post after login');
39 is_allowed( '/user_logout', 'logout after login' );
41 sub login {
42 my ( $l, $p ) = @_;
43 is_allowed( "/user_login?user=$l&password=$p" );
46 sub is_denied {
47 my $path = shift;
48 my $res = $m->get( $path );
49 is( $res->status_line, '403 Forbidden' );
52 sub is_allowed {
53 my ( $path, $text ) = @_;
54 $m->get_ok( $path );