added role self_check and self_check_any to User store
[catagits/Catalyst-Authentication-Store-DBIx-Class.git] / t / 11-authsessions-load-app-context.t
1 #!perl
2
3 use strict;
4 use warnings;
5 use DBI;
6 use File::Path;
7 use FindBin;
8 use Test::More;
9 use lib "$FindBin::Bin/lib";
10
11 BEGIN {
12     eval { require Test::WWW::Mechanize::Catalyst }
13       or plan skip_all =>
14       "Test::WWW::Mechanize::Catalyst is required for this test";
15
16     eval { require DBD::SQLite }
17         or plan skip_all =>
18         "DBD::SQLite is required for this test";
19
20     eval { require Catalyst::Plugin::Session;
21            die unless $Catalyst::Plugin::Session::VERSION >= 0.02 }
22         or plan skip_all =>
23         "Catalyst::Plugin::Session >= 0.02 is required for this test";
24
25     eval { require Catalyst::Plugin::Session::State::Cookie; }
26         or plan skip_all =>
27         "Catalyst::Plugin::Session::State::Cookie is required for this test";
28
29
30     plan tests => 4;
31
32     use TestApp;
33     TestApp->config( {
34         name => 'TestApp',      
35         authentication => {
36             default_realm => "users",
37             realms => {
38                 users => {
39                     credential => {
40                         'class' => 'Password',
41                         'password_field' => 'password',
42                                         },
43                     store => {
44                         'class' => 'Person',                        
45                         'use_userdata_from_session' => 0,
46                     },
47                 },
48             },
49         },
50     } );
51
52     TestApp->setup(
53         qw/Authentication
54             Session
55                     Session::Store::Dummy                  
56             Session::State::Cookie                               
57            /
58     );
59 }
60
61 use Test::WWW::Mechanize::Catalyst 'TestApp';
62 my $m = Test::WWW::Mechanize::Catalyst->new;
63
64 # log a user in
65 {
66     $m->get_ok( 'http://localhost/user_login?username=joeuser&password=hackme', undef, 'request ok' );
67     $m->content_is( 'joeuser logged in', 'user logged in ok' );
68 }
69
70 # verify the user is still logged in
71 {
72     $m->get_ok( 'http://localhost/get_session_user', undef, 'request ok' );
73     $m->content_is( 'joeuser', 'user still logged in' );
74 }
75
76