Actually error in the appropriate way
Tomas Doran [Thu, 5 Feb 2009 22:05:32 +0000 (22:05 +0000)]
lib/Catalyst/Authentication/Realm.pm
t/lib/AuthSessionTestApp.pm
t/live_app_session.t

index d7d33e6..b36d14d 100644 (file)
@@ -191,9 +191,10 @@ sub restore_user {
     
         # this sets the realm the user originated in.
         $user->auth_realm($self->name);
-    } else {
-               $c->log->error("Store claimed to have a restorable user, but restoration failed.  Did you change the user's id_field?");
-               $self->failed_user_restore($c);
+    } 
+    else {
+        $self->failed_user_restore($c) ||
+            $c->error("Store claimed to have a restorable user, but restoration failed.  Did you change the user's id_field?");
        }
         
     return $user;
@@ -201,10 +202,12 @@ sub restore_user {
 
 ## this occurs if there is a session but the thing the session refers to
 ## can not be found.  Do what you must do here.
+## Return true if you can fix the situation and find a user, false otherwise
 sub failed_user_restore {
        my ($self, $c) = @_;
        
        $self->remove_persisted_user($c);
+       return;
 }
 
 sub persist_user {
index b6e4a50..ad6b862 100644 (file)
@@ -48,7 +48,8 @@ sub yak : Local {
     my ( $self, $c ) = @_;
     ok( $c->sessionid, "session ID was restored after user renamed" );
     ok( $c->user_exists, "user appears to exist" );
-    ok( !$c->user, "try to restore - user was not restored");
+    ok( !$c->user, "user was not restored");
+    ok(scalar(@{ $c->error }), 'Error recorded');
     ok( !$c->user_exists, "user no longer appears to exist" );
 }
 
index a1c3ae1..8bf83d5 100644 (file)
@@ -6,7 +6,7 @@ use Test::More;
 BEGIN {
        eval { require Test::WWW::Mechanize::Catalyst; require Catalyst::Plugin::Session; require Catalyst::Plugin::Session::State::Cookie };
        plan skip_all => "This test needs Test::WWW::Mechanize::Catalyst, Catalyst::Plugin::Session and Catalyst::Plugin::Session::State::Cookie installed" if $@;
-       plan tests => 28;
+       plan tests => 29;
 }
 
 use lib 't/lib';
@@ -16,7 +16,10 @@ my $m = Test::WWW::Mechanize::Catalyst->new;
 
 $m->get_ok("http://localhost/moose", "get ok");
 $m->get_ok("http://localhost/elk", "get ok");
-$m->get_ok("http://localhost/yak", "get ok");
+
+$m->get("http://localhost/yak");
+ok(!$m->success, 'Not ok, user unable to be resotred == nasal demons');
+
 $m->get_ok("http://localhost/goat", "get ok");
 $m->get_ok("http://localhost/fluffy_bunny", "get ok");
 $m->get_ok("http://localhost/possum", "get ok");