MatrixPolicy.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 92 CC 10 SCAR 45.2
CC
10
Cov
0%
get
110.0
BEGIN
2.0
BEGIN
2.0
CRAP 92.0
1 package Lemonldap::Handlers::MatrixPolicy;
2 use strict;
3 use warnings;
4 our $VERSION = '3.1.1';
5 our $VERSION_LEMONLDAP = "3.1";
6 our $VERSION_INTERNAL = "3.1";
7  
8 sub get
9 {
10 my $class= shift;
11 my %_param= @_;
12
13 my $self;
14 my $config =$_param{parameters}->{'config'};
15 my $session= $_param{'session'};
16 unless ($session) {
17 $self->{response} = 0; #0 time out
18 bless $self,$class;
19 return $self;
20 }
21  
22 my $complement;
23 my $dn = $session->{dn};
24 $dn =~ s/ //g;
25 my $major = $config->{ORGANIZATION};
26 if( !defined($major) ){
27 $major = "authz_headers";
28 }
29 # my $minor = lc($config->{APPLCODE});
30 my $minor = $config->{APPLCODE};
31 if ( defined($major) && defined($minor) && exists($session->{$major}->{$minor}))
32 {
33 $complement = $session->{$major}->{$minor};
34 #### begin: here for he compatibility with older lemonldap
35 $complement =~ s/#.*//;
36 ### end : here for he compatibility with older lemonldap
37 if ( defined($config->{REGEXPMATRIXPOLICY}) && $complement !~ $config->{REGEXPMATRIXPOLICY} ){
38 undef $complement;
39 }else{
40 $self->{response} = 200;
41 }
42 }
43
44 unless (defined $complement) {
45 $complement = '_DENY_';
46 $self->{response} = 403; #403 = FORBIDDEN 200 = OK
47 $complement = '_ALLOW_' && $self->{response} = '200' if lc($config->{ALLOW}) eq 'all';
48 undef $complement if ($self->{response} == '403' or $self->{response} == '503' );
49 }
50
51 $self->{response} = 503 if lc($config->{ALLOW}) eq 'disabled';
52 undef $complement if ($self->{response} == '403' or $self->{response} == '503' );
53 $self->{profil} = $complement ;
54 bless $self,$class;
55 return $self;
56 }
57  
58 1;