1 package AuthSessionTestApp::Controller::Root;
4 use base qw/Catalyst::Controller/;
6 __PACKAGE__->config(namespace => '');
11 use Digest::MD5 qw/md5/;
14 my ( $self, $c ) = @_;
16 ok(!$c->sessionid, "no session id yet");
17 ok(!$c->user_exists, "no user exists");
18 ok(!$c->user, "no user yet");
19 ok($c->login( "foo", "s3cr3t" ), "can login with clear");
20 is( $c->user, $AuthSessionTestApp::users->{foo}, "user object is in proper place");
24 my ( $self, $c ) = @_;
26 ok( $c->sessionid, "session ID was restored" );
27 ok( $c->user_exists, "user exists" );
28 ok( $c->user, "a user was also restored");
29 is_deeply( $c->user, $AuthSessionTestApp::users->{foo}, "restored user is the right one (deep test - store might change identity)" );
32 $AuthSessionTestApp::users->{bar} = delete $AuthSessionTestApp::users->{foo};
36 my ( $self, $c ) = @_;
37 ok( $c->sessionid, "session ID was restored after user renamed" );
38 ok( $c->user_exists, "user appears to exist" );
39 ok( !$c->user, "user was not restored");
40 ok(scalar(@{ $c->error }), 'Error recorded');
41 ok( !$c->user_exists, "user no longer appears to exist" );
45 my ( $self, $c ) = @_;
46 ok($c->login( "bar", "s3cr3t" ), "can login with clear (new username)");
47 is( $c->user, $AuthSessionTestApp::users->{bar}, "user object is in proper place");
51 sub fluffy_bunny : Local {
52 my ( $self, $c ) = @_;
54 ok( $c->session_is_valid, "session ID is restored after logout");
55 ok( !$c->user, "no user was restored after logout");
57 $c->delete_session("bah");
61 my ( $self, $c ) = @_;
63 ok( !$c->session_is_valid, "no session ID was restored");
64 $c->session->{definitely_not_a_user} = "moose";
68 sub butterfly : Local {
69 my ( $self, $c ) = @_;
71 ok( $c->session_is_valid, "valid session" );
72 ok( !$c->user_exists, "but no user exists" );
73 ok( !$c->user, "no user object either" );