Commit | Line | Data |
714e2bdc |
1 | package AuthRealmTestAppProgressive; |
2 | use warnings; |
3 | use 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. |
11 | use Catalyst qw/ |
12 | Authentication |
13 | Authentication::Store::Minimal |
14 | /; |
15 | |
16 | use Test::More; |
17 | use Test::Exception; |
18 | |
19 | our %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 | |
58 | sub 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 | |