fixed a nasty bug in compat mode with store::minimal. From the comments left in ...
[catagits/Catalyst-Plugin-Authentication.git] / t / lib / AuthRealmTestAppCompat.pm
CommitLineData
692dcea4 1package AuthRealmTestAppCompat;
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 bob => {
21 password => "s00p3r"
22 },
23};
24
25sub moose : Local {
26 my ( $self, $c ) = @_;
27
28 while ( my ($user, $info) = each %$members ) {
29
30 my $ok = eval {
31 $c->authenticate(
32 { username => $user, password => $info->{password} },
33 'members'
34 ),
35 };
36
37 ok( !$@, "Test did not die: $@" );
38 ok( $ok, "user $user authentication" );
39 }
40
41 $c->res->body( "ok" );
42}
43
44__PACKAGE__->config->{'Plugin::Authentication'} = {
45 default_realm => 'members',
46 realms => {
47 members => {
48 credential => {
49 class => 'Password',
50 password_field => 'password',
51 password_type => 'clear'
52 },
53 store => {
54 class => 'Minimal',
55 users => $members,
56 }
57 },
58 }
59};
60
61__PACKAGE__->setup;