blib/lib/Catalyst/Plugin/Session/State/Header.pm

filter: Statementstmt 54.7% 23 / 42 Branchbran 30.0% 3 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 55.5% 5 / 9 Podpod 100% 5 / 5 totaltotal 47.3% 36 / 76 CC 8 SCAR 28.3
CC
8
Cov
45%
get_session_id
42.0
uni_path
3.0
extend_session_id
2.0
CRAP 16.9
↑ Summary
1 package Catalyst::Plugin::Session::State::Header;
2 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 extends 'Catalyst::Plugin::Session::State';
5  
6 2 ▶use MRO::Compat;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Catalyst::Utils ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $VERSION = '0.02';
10  
11 0 ▶sub extend_session_id {
Subroutine extend_session_id: not called CC=1 SCAR=6.9
Pod documented
12 0 my ( $c, $sid, $expires ) = @_;
13  
14 0 $c->maybe::next::method( $sid, $expires );
15 }
16  
17 0 ▶sub set_session_id {
Subroutine set_session_id: not called CC=1 SCAR=6.9
Pod documented
18 0 my ( $c, $sid ) = @_;
19  
20 0 return $c->maybe::next::method($sid);
21 }
22  
23 0 ▶sub get_session_id {
Subroutine get_session_id: not called CC=6 SCAR=37.4
Pod documented
24 0 my $c = shift;
25  
26 0 my $path = uni_path($c->request->path());
27  
28 0 my $cfg = $c->_session_plugin_config();
29 0 ▶ if ($cfg->{allowed_uri} && $path !~ m/$cfg->{allowed_uri}/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{"allowed_uri"} and not $path =~ /$cfg->{"allowed_uri"}/s) 0 0 0
Condition0%0/3
$cfg->{"allowed_uri"} and not $path =~ /$cfg->{"allowed_uri"}/s
!ll&&!rl&&r
000
MC/DC0%0/2
$cfg->{"allowed_uri"} and not $path =~ /$cfg->{"allowed_uri"}/s
$cfg->{"allowed_uri"} not $path =~ /$cfg->{"allowed_uri"}/s
Truth table0%0/3
A and not(B)
A= $cfg->{"allowed_uri"}B= not $path =~ /$cfg->{"allowed_uri"}/s
ABresult
0X0
100
111
30 0 $c->log->debug("URI $path is not allowed for header authentication");
31 0 return $c->maybe::next::method(@_);
32 }
33  
34 0 ▶ if ($cfg->{auth_header} and my $sid = $c->request->header($cfg->{auth_header})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{"auth_header"} and my $sid = $c->request->header($cfg->{"auth_header"})) 0 0 0
Condition0%0/3
$cfg->{"auth_header"} and my $sid = $c->request->header($cfg->{"auth_header"})
!ll&&!rl&&r
000
MC/DC0%0/2
$cfg->{"auth_header"} and my $sid = $c->request->header($cfg->{"auth_header"})
$cfg->{"auth_header"} my $sid = $c->request->header($cfg->{"auth_header"})
Truth table0%0/3
A and B
A= $cfg->{"auth_header"}B= my $sid = $c->request->header($cfg->{"auth_header"})
ABresult
0X0
100
111
35 0 $c->log->debug("Header was found: $sid");
36 0 ▶ if (!$c->validate_session_id($sid)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($c->validate_session_id($sid)) 0 0 0
37 0 $c->log->debug("Session id, that was provided in header, is invalid");
38 0 return $c->maybe::next::method(@_);
39 }
40 0 return $sid;
41 }
42 0 return $c->maybe::next::method(@_);
43 }
44  
45 0 ▶sub delete_session_id {
Subroutine delete_session_id: not called CC=1 SCAR=6.9
Pod documented
46 0 my ( $c, $sid ) = @_;
47  
48 0 $c->maybe::next::method($sid);
49 }
50  
51  
52 7 ▶sub uni_path {
Subroutine uni_path: called CC=3 SCAR=11.0
Pod documented
53 7 my ($path) = @_;
54  
55 7 ▶ return '/' unless $path;
Branch: 1 branch
BranchTrueFalseTotal
unless $path 0 7 7
56 7 $path =~ s|\/{2,}|/|gs;
57 7 $path =~ s|^\/+||s;
58 7 $path =~ s|\/+$||s;
59 7 ▶ return '/' unless $path;
Branch: 1 branch
BranchTrueFalseTotal
unless $path 2 5 7
60 5 $path = '/' . $path . '/';
61 5 return $path;
62 }
63  
64 2 __PACKAGE__
65  
66 __END__
↑ Summary