New test for credentials with detach.
[catagits/Catalyst-Plugin-Authentication.git] / t / lib / AuthRealmTestAppProgressive / Controller / Root.pm
CommitLineData
d055ce0c 1package AuthRealmTestAppProgressive::Controller::Root;
2use warnings;
3use strict;
4use base qw/Catalyst::Controller/;
5
3a311407 6__PACKAGE__->config( namespace => '' );
d055ce0c 7
8use Test::More;
9use Test::Exception;
10
11sub progressive : Local {
fb90f091 12 my ( $self, $c ) = @_;
d055ce0c 13
14 foreach my $realm ( keys %AuthRealmTestAppProgressive::members ) {
3a311407 15 while ( my ( $user, $info ) =
16 each %{ $AuthRealmTestAppProgressive::members{$realm} } )
17 {
18 my $res;
d055ce0c 19 my $ok = eval {
3a311407 20 $res = $c->authenticate(
d055ce0c 21 { username => $user, password => $info->{password} },
3a311407 22 );
23 1;
d055ce0c 24 };
3a311407 25 ok( !$@, "authentication passed." );
26 ok( $ok, "user authenticated" );
d055ce0c 27 ok( $c->user_in_realm($realm), "user in proper realm" );
28 }
29 }
3a311407 30 $c->res->body("ok");
d055ce0c 31}
32
05e98f5f 33sub progressive_detach : Local {
34 my ( $self, $c ) = @_;
35
36 my $realm = $AuthRealmTestAppProgressive::detach_test_info->{realm_to_pass};
37 my $user = $AuthRealmTestAppProgressive::detach_test_info->{user};
38 my $pass = $AuthRealmTestAppProgressive::detach_test_info->{password};
39 my $res;
40 my $ok = eval {
41 $res = $c->authenticate( { username => $user, password => $pass }, );
42 1;
43 };
44 ok( !$@, "authentication passed skipping detach." );
45 ok( $ok, "user authenticated skipping detach" );
46 ok( $c->user_in_realm($realm), "user in proper realm" );
47 $c->res->body("ok");
48}
d055ce0c 491;
50