Try::Tiny used so we can catch a detach from the like of Credential::HTTP as per...
[catagits/Catalyst-Plugin-Authentication.git] / t / lib / AuthRealmTestAppProgressive / Controller / Root.pm
1 package AuthRealmTestAppProgressive::Controller::Root;
2 use warnings;
3 use strict;
4 use base qw/Catalyst::Controller/;
5
6 __PACKAGE__->config( namespace => '' );
7
8 use Test::More;
9 use Test::Exception;
10
11 sub progressive : Local {
12     my ( $self, $c ) = @_;
13
14     foreach my $realm ( keys %AuthRealmTestAppProgressive::members ) {
15         while ( my ( $user, $info ) =
16             each %{ $AuthRealmTestAppProgressive::members{$realm} } )
17         {
18             my $res;
19             my $ok = eval {
20                 $res = $c->authenticate(
21                     { username => $user, password => $info->{password} },
22                 );
23                 1;
24             };
25             ok( !$@,                       "authentication passed." );
26             ok( $ok,                       "user authenticated" );
27             ok( $c->user_in_realm($realm), "user in proper realm" );
28         }
29     }
30     $c->res->body("ok");
31 }
32
33 1;
34