New test for credentials with detach. handle-detach-tests mirror/handle-detach-tests
Gavin Henry [Wed, 14 Dec 2011 20:55:41 +0000 (20:55 +0000)]
t/lib/AuthRealmTestAppProgressive.pm
t/lib/AuthRealmTestAppProgressive/Controller/Root.pm
t/live_app_realms_progressive.t

index 2035a07..82ea5a9 100644 (file)
@@ -23,6 +23,14 @@ our %members = (
     },
 );
 
+# Matches user above so we can test against a detach and confirm
+# it gets skipped and auths in 'members' realm
+our $detach_test_info = {
+    'user' => 'bob',
+    'password' => 's00p3r',
+    'realm_to_pass' => 'members',
+};
+
 __PACKAGE__->config('Plugin::Authentication' => {
     default_realm => 'progressive',
     progressive => {
index 4e9037f..6c6e5ab 100644 (file)
@@ -30,5 +30,21 @@ sub progressive : Local {
     $c->res->body("ok");
 }
 
+sub progressive_detach : Local {
+    my ( $self, $c ) = @_;
+
+    my $realm = $AuthRealmTestAppProgressive::detach_test_info->{realm_to_pass};
+    my $user  = $AuthRealmTestAppProgressive::detach_test_info->{user};
+    my $pass  = $AuthRealmTestAppProgressive::detach_test_info->{password};
+    my $res;
+    my $ok = eval {
+        $res = $c->authenticate( { username => $user, password => $pass }, );
+        1;
+    };
+    ok( !$@,                       "authentication passed skipping detach." );
+    ok( $ok,                       "user authenticated skipping detach" );
+    ok( $c->user_in_realm($realm), "user in proper realm" );
+    $c->res->body("ok");
+}
 1;
 
index f7131e5..2736f6e 100644 (file)
@@ -7,6 +7,7 @@ use lib 't/lib';
 use Catalyst::Test qw/AuthRealmTestAppProgressive/;
 
 ok(get("/progressive"), "get ok");
+ok(get("/progressive_detach"), "get ok");
 
 done_testing;