blib/lib/Lemonldap/NG/Portal/Auth/REST.pm

filter: Statementstmt 34.8% 15 / 43 Branchbran 10.0% 1 / 10 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 4 totaltotal 28.5% 20 / 70 CC 10 SCAR 36.2
CC
10
Cov
28%
authenticate
72.0
setAuthSessionInfo
6.0
init
2.3
CRAP 37.4
« blib/lib/Lemonldap/NG/Portal/Plugins/CrowdSecAgent.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Lib/CAS.pm »
1 package Lemonldap::NG::Portal::Auth::REST;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 use Lemonldap::NG::Portal::Main::Constants qw(
6 PE_OK
7 PE_ERROR
8 PE_BADCREDENTIALS
9 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 our $VERSION = '2.0.12';
12  
13 2 extends qw(
14 Lemonldap::NG::Portal::Auth::_WebForm
15 Lemonldap::NG::Portal::Lib::REST
16 );
17  
18 # INITIALIZATION
19  
20 sub init {
21 1 ▶ my $self = shift;
Subroutine init: called CC=2 SCAR=8.4
Pod undocumented
22  
23 # Add warning in log
24 1 ▶ unless ( $self->conf->{restAuthUrl} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->conf->{"restAuthUrl"}) 0 1 1
25 0 $self->logger->error('No REST Authentication URL given');
26 0 return 0;
27 }
28  
29 1 return $self->Lemonldap::NG::Portal::Auth::_WebForm::init();
30 }
31  
32 sub authenticate {
33 0 ▶ my ( $self, $req ) = @_;
Subroutine authenticate: not called CC=8 SCAR=42.8
Pod undocumented
34 0 my $res = eval {
35 $self->restCall( $self->conf->{restAuthUrl},
36 0 { user => $req->user, password => $req->data->{password} } );
37 };
38 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
39 0 $self->logger->error("Auth error: $@");
40 0 $self->setSecurity($req);
41 0 return PE_ERROR;
42 }
43 0 ▶ $self->logger->debug( "REST result:" . ( $res->{result} || 'undef' ) );
Condition0%0/2
$res->{'result'} || 'undef'
l!l
00
MC/DC0%0/1
$res->{'result'} || 'undef'
$res->{'result'}
Truth table0%0/2
A
A= $res->{'result'}
Aresult
11
00
44 0 ▶ if ( $res->{info} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->{"info"}) 0 0 0
45 0 eval {
46 $self->logger->debug(" $_ => $res->{info}->{$_}")
47 0 foreach ( keys %{ $res->{info} } );
48 };
49 }
50 0 ▶ $self->logger->error( 'No "info": ' . $@ ) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
51 0 ▶ unless ( $res->{result} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($res->{"result"}) 0 0 0
52 0 $self->userLogger->warn(
53 "Bad credentials for " . $req->user . ' (' . $req->address . ')' );
54 0 $self->setSecurity($req);
55 0 return PE_BADCREDENTIALS;
56 }
57 0 ▶ $req->data->{restAuthInfo} = $res->{info} || {};
Condition0%0/2
$res->{'info'} || {}
l!l
00
MC/DC0%0/1
$res->{'info'} || {}
$res->{'info'}
Truth table0%0/2
A
A= $res->{'info'}
Aresult
11
00
58 0 return PE_OK;
59 }
60  
61 sub setAuthSessionInfo {
62 0 ▶ my ( $self, $req ) = @_;
Subroutine setAuthSessionInfo: not called CC=2 SCAR=17.9
Pod undocumented
63 0 $self->SUPER::setAuthSessionInfo($req);
64 $req->sessionInfo->{$_} = $req->data->{restAuthInfo}->{$_}
65 0 foreach ( keys %{ $req->data->{restAuthInfo} } );
66 0 $req->sessionInfo->{authenticationLevel} = $self->conf->{restAuthnLevel};
67 0 return PE_OK;
68 }
69  
70 sub authLogout {
71 0 ▶ return PE_OK;
Subroutine authLogout: not called CC=1 SCAR=6.9
Pod undocumented
72 }
73  
74 2 1;
« blib/lib/Lemonldap/NG/Portal/Plugins/CrowdSecAgent.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Lib/CAS.pm »