Stop forcing $authinfo->{id} to be passed down to the store, instead using just confi...
[catagits/Catalyst-Plugin-Authentication.git] / t / lib / AuthRealmTestAppProgressive.pm
CommitLineData
714e2bdc 1package AuthRealmTestAppProgressive;
2use warnings;
3use strict;
4
5### using A::Store::minimal with new style realms
6### makes the app blow up, since c::p::a::s::minimal
7### isa c:a::s::minimal, and it's compat setup() gets
8### run, with an unexpected config has (realms on top,
9### not users). This tests makes sure the app no longer
10### blows up when this happens.
11use Catalyst qw/
12 Authentication
13 Authentication::Store::Minimal
14/;
15
16use Test::More;
17use Test::Exception;
18
19our %members = (
20 'members' => {
21 bob => { password => "s00p3r" }
22 },
23 'other' => {
24 sally => { password => "s00p3r" }
25 },
26);
27
28__PACKAGE__->config->{'Plugin::Authentication'} = {
29 default_realm => 'progressive',
30 progressive => {
31 class => 'Progressive',
32 realms => [ 'other', 'members' ],
33 },
34 other => {
35 credential => {
36 class => 'Password',
37 password_field => 'password',
38 password_type => 'clear'
39 },
40 store => {
41 class => 'Minimal',
42 users => $members{other},
43 }
44 },
45 members => {
46 credential => {
47 class => 'Password',
48 password_field => 'password',
49 password_type => 'clear'
50 },
51 store => {
52 class => 'Minimal',
53 users => $members{members},
54 }
55 },
56};
57
58sub progressive : Local {
59 my ( $self, $c ) = @_;
60
61 foreach my $realm ( keys %members ) {
62 while ( my ( $user, $info ) = each %{$members{$realm}} ) {
63 my $ok = eval {
64 $c->authenticate(
65 { username => $user, password => $info->{password} },
66 );
67 };
68 ok( !$@, "authentication passed." );
69 ok( $ok, "user authenticated" );
70 ok( $c->user_in_realm($realm), "user in proper realm" );
71 }
72 }
73 $c->res->body( "ok" );
74}
75
76__PACKAGE__->setup;
77