blib/lib/Catalyst/Authentication/Credential/Fallback.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 55 CC 4 SCAR 18.3
CC
4
Cov
0%
new
12.0
authenticate
6.0
BEGIN
2.0
CRAP 6.2
1 package Catalyst::Authentication::Credential::Fallback;
2  
3 use strict;
4 use warnings;
5  
6 use base 'Class::Accessor::Fast';
7  
8 our $VERSION = 1.001;
9  
10 BEGIN {
11 __PACKAGE__->mk_accessors(qw/realm_list realm/);
12 }
13  
14 sub new {
15 my ( $class, $config, $app, $realm ) = @_;
16  
17 my $self = { };
18 bless $self, $class;
19  
20 if (! defined($config->{realms}) || (ref [] ne ref $config->{realms})) {
21 Catalyst::Exception->throw("realms configuration parameter must be an ARRAY ref");
22 }
23 if (defined($config->{realms}) && (0 == scalar @{$config->{realms}})) {
24 Catalyst::Exception->throw("a value in realms configuration parameter is required");
25 }
26  
27 $self->realm_list($config->{realms});
28 $self->realm($realm);
29 return $self;
30 }
31  
32 sub authenticate {
33 my ( $self, $c, $realm, $authinfo ) = @_;
34  
35 foreach my $rlm (@{ $self->realm_list }) {
36 my $u_obj = eval { $c->authenticate($authinfo, $rlm) };
37 return $u_obj if $u_obj;
38 }
39  
40 return;
41 }
42  
43 1;
44  
45 __END__