blib/lib/Lemonldap/NG/Portal/Lib/Wrapper.pm

filter: Statementstmt 69.6% 39 / 56 Branchbran 35.0% 7 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 78.9% 15 / 19 Podpod 0.0% 0 / 6 totaltotal 60.4% 61 / 101 CC 12 SCAR 26.9
CC
12
Cov
61%
_wrapEntryPoint
37.8
AUTOLOAD
2.1
_afterData
2.0
CRAP 14.7
« blib/lib/Lemonldap/NG/Portal/Password/REST.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/UserDB/OpenID.pm »
1 # Base class for auth modules that call other auth modules (Choice,...)
2 #
3 # It fakes portal object to catch entry points and load them only if underlying
4 # auth module is activated
5 package Lemonldap::NG::Portal::Lib::Wrapper;
6  
7 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 25 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 25 ▶use Lemonldap::NG::Portal::Main::Constants qw(PE_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 25 our $VERSION = '2.18.0';
12  
13 25 extends 'Lemonldap::NG::Portal::Main::Auth';
14  
15 66 ▶has availableModules => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
16  
17 # Wrappers for portal entry points: entry points are enabled only for active
18 # authentication module
19 #
20 # Note that "beforeAuth" can't be used here and must be wrapped in auth
21 # module
22 #
23 # Note also that auth module must store in $req->data->{enabledMods} a ref
24 # to each enabled underlying auth modules
25 66 ▶sub betweenAuthAndData { '_betweenAuthAndData' }
Subroutine betweenAuthAndData: called CC=1 SCAR=0.0
Pod undocumented
26 66 ▶sub afterData { '_afterData' }
Subroutine afterData: called CC=1 SCAR=0.0
Pod undocumented
27 66 ▶sub endAuth { '_endAuth' }
Subroutine endAuth: called CC=1 SCAR=0.0
Pod undocumented
28 66 ▶sub forAuthUser { '_forAuthUser' }
Subroutine forAuthUser: called CC=1 SCAR=0.0
Pod undocumented
29 66 ▶sub beforeLogout { '_beforeLogout' }
Subroutine beforeLogout: called CC=1 SCAR=0.0
Pod undocumented
30 66 ▶sub authCancel { '_authCancel' }
Subroutine authCancel: called CC=1 SCAR=0.0
Pod undocumented
31  
32 11 ▶sub _betweenAuthAndData { _wrapEntryPoint( @_, 'betweenAuthAndData' ); }
Subroutine _betweenAuthAndData: called CC=1 SCAR=0.0
33 0 ▶sub _afterData { _wrapEntryPoint( @_, 'afterData' ); }
Subroutine _afterData: not called CC=1 SCAR=6.9
34 0 ▶sub _endAuth { _wrapEntryPoint( @_, 'endAuth' ); }
Subroutine _endAuth: not called CC=1 SCAR=6.9
35 0 ▶sub _forAuthUser { _wrapEntryPoint( @_, 'forAuthUser', 1 ); }
Subroutine _forAuthUser: not called CC=1 SCAR=6.9
36 0 ▶sub _beforeLogout { _wrapEntryPoint( @_, 'beforeLogout', 1 ); }
Subroutine _beforeLogout: not called CC=1 SCAR=6.9
37 2 ▶sub _authCancel { _wrapEntryPoint( @_, 'authCancel' ); }
Subroutine _authCancel: called CC=1 SCAR=0.0
38  
39 sub _wrapEntryPoint {
40 13 ▶ my ( $self, $req, $name, $connected ) = @_;
Subroutine _wrapEntryPoint: called CC=11 SCAR=36.3
41 13 my @t;
42 13 ▶ if ($connected) {
Branch: 3 branches
BranchTrueFalseTotal
if ($connected) { } 0 13 13
elsif (my $mod = $req->sessionInfo->{$self->sessionKey}) { } 11 2 13
elsif (ref $req->data->{'enabledMods' . $self->type}) { } 0 2 2
43 0 ▶ if ( my $mod = $req->userData->{ $self->sessionKey } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mod = $req->userData->{$self->sessionKey}) { } 0 0 0
44 0 ▶ if ( $self->modules->{$mod} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->modules->{$mod}) { } 0 0 0
45 0 @t = ( $self->modules->{$mod} );
46 }
47 else {
48 0 $self->userLogger->error(
49 "Bad $self->{sessionKey} value in session ($name)");
50 }
51 }
52 else {
53 0 $self->userLogger->warn(
54 "Missing $self->{sessionKey} key in session");
55 }
56 }
57 elsif ( my $mod = $req->sessionInfo->{ $self->sessionKey } ) {
58 11 ▶ if ( $self->modules->{$mod} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->modules->{$mod}) { } 11 0 11
59 11 @t = ( $self->modules->{$mod} );
60 }
61 else {
62 0 $self->userLogger->error(
63 "Bad $self->{sessionKey} value in session ($name)");
64 }
65 }
66 elsif ( ref $req->data->{ "enabledMods" . $self->type } ) {
67 0 @t = @{ $req->data->{ "enabledMods" . $self->type } };
68 }
69 else {
70 2 $self->logger->debug(
71 "Unable to find enabledMods$self->{type} in this context: $name");
72 }
73 13 foreach (@t) {
74 11 ▶ if ( $_->can($name) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->can($name)) 0 11 11
75  
76 # Launch sub and break loop if result isn't PE_OK (==0)
77 0 ▶ if ( my $sub = $_->$name() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sub = $_->$name) 0 0 0
78 0 my $res = $_->$sub($req);
79 0 ▶ return $res if ($res);
Branch: 1 branch
BranchTrueFalseTotal
if $res 0 0 0
80 }
81 }
82 }
83 13 return PE_OK;
84 }
85  
86 sub AUTOLOAD {
87 25 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
88  
89 # Unknown methods are tried with real portal
90 9 ▶ my $self = shift;
Subroutine AUTOLOAD: called CC=2 SCAR=7.6
91 9 my $sub = $AUTOLOAD;
92 9 $sub =~ s/.*:://;
93 9 ▶ if ( $self->p->can($sub) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->p->can($sub)) 9 0 9
94 9 return $self->p->$sub(@_);
95 }
96 0 require Carp;
97 0 Carp::confess "Unknown method $sub";
98 }
99  
100 25 1;
« blib/lib/Lemonldap/NG/Portal/Password/REST.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/UserDB/OpenID.pm »