Commit | Line | Data |
9db54bcf |
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 DBIx::Class } |
21 | or plan skip_all => |
22 | "DBIx::Class is required for this test"; |
23 | |
24 | eval { require Catalyst::Plugin::Session; |
25 | die unless $Catalyst::Plugin::Session::VERSION >= 0.02 } |
26 | or plan skip_all => |
27 | "Catalyst::Plugin::Session >= 0.02 is required for this test"; |
28 | |
29 | eval { require Catalyst::Plugin::Session::State::Cookie; } |
30 | or plan skip_all => |
31 | "Catalyst::Plugin::Session::State::Cookie is required for this test"; |
32 | |
33 | |
34 | plan tests => 4; |
35 | |
b4319877 |
36 | use TestApp; |
37 | TestApp->config( { |
9db54bcf |
38 | name => 'TestApp', |
39 | authentication => { |
40 | default_realm => "users", |
41 | realms => { |
42 | users => { |
43 | credential => { |
44 | 'class' => 'Password', |
45 | 'password_field' => 'password', |
46 | }, |
47 | store => { |
48 | 'class' => 'Person', |
49 | 'use_userdata_from_session' => 0, |
50 | }, |
51 | }, |
52 | }, |
53 | }, |
b4319877 |
54 | } ); |
9db54bcf |
55 | |
b4319877 |
56 | TestApp->setup( |
9db54bcf |
57 | qw/Authentication |
58 | Session |
59 | Session::Store::Dummy |
60 | Session::State::Cookie |
61 | / |
b4319877 |
62 | ); |
9db54bcf |
63 | } |
64 | |
65 | use Test::WWW::Mechanize::Catalyst 'TestApp'; |
66 | my $m = Test::WWW::Mechanize::Catalyst->new; |
67 | |
68 | # log a user in |
69 | { |
70 | $m->get_ok( 'http://localhost/user_login?username=joeuser&password=hackme', undef, 'request ok' ); |
71 | $m->content_is( 'joeuser logged in', 'user logged in ok' ); |
72 | } |
73 | |
74 | # verify the user is still logged in |
75 | { |
76 | $m->get_ok( 'http://localhost/get_session_user', undef, 'request ok' ); |
77 | $m->content_is( 'joeuser', 'user still logged in' ); |
78 | } |
79 | |
80 | |