9 use lib "$FindBin::Bin/lib";
12 eval { require Test::WWW::Mechanize::Catalyst }
14 "Test::WWW::Mechanize::Catalyst is required for this test";
16 eval { require DBD::SQLite }
18 "DBD::SQLite is required for this test";
20 eval { require DBIx::Class }
22 "DBIx::Class is required for this test";
24 eval { require Catalyst::Plugin::Session;
25 die unless $Catalyst::Plugin::Session::VERSION >= 0.02 }
27 "Catalyst::Plugin::Session >= 0.02 is required for this test";
31 $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
33 $ENV{TESTAPP_CONFIG} = {
36 default_realm => "users",
40 'class' => "Password",
41 'password_field' => 'password',
42 'password_type' => 'clear'
45 'class' => 'DBIx::Class',
46 'user_class' => 'TestApp::User',
53 $ENV{TESTAPP_PLUGINS} = [
57 Session::State::Cookie
64 use Test::WWW::Mechanize::Catalyst 'TestApp';
65 my $m = Test::WWW::Mechanize::Catalyst->new;
69 $m->get_ok( 'http://localhost/user_login?username=joeuser&password=hackme', undef, 'request ok' );
70 $m->content_is( 'joeuser logged in', 'user logged in ok' );
73 # verify the user is still logged in
75 $m->get_ok( 'http://localhost/get_session_user', undef, 'request ok' );
76 $m->content_is( 'joeuser', 'user still logged in' );
81 $m->get_ok( 'http://localhost/user_logout', undef, 'request ok' );
82 $m->content_is( 'logged out', 'user logged out ok' );
85 # verify there is no session
87 $m->get_ok( 'http://localhost/get_session_user', undef, 'request ok' );
88 $m->content_is( '', "user's session deleted" );
92 unlink $ENV{TESTAPP_DB_FILE};