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
CommitLineData
9db54bcf 1#!perl
2
3use strict;
4use warnings;
5use DBI;
6use File::Path;
7use FindBin;
8use Test::More;
9use lib "$FindBin::Bin/lib";
10
11BEGIN {
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
9db54bcf 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
b4319877 32 use TestApp;
33 TestApp->config( {
9db54bcf 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 },
b4319877 50 } );
9db54bcf 51
b4319877 52 TestApp->setup(
9db54bcf 53 qw/Authentication
54 Session
55 Session::Store::Dummy
56 Session::State::Cookie
57 /
b4319877 58 );
9db54bcf 59}
60
61use Test::WWW::Mechanize::Catalyst 'TestApp';
62my $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