Lemonldap/NG/Handler/Server/Traefik.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 6 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 92.4% 49 / 53 CC 5 SCAR 9.8
CC
5
Cov
98%
handler
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« Lemonldap/NG/Handler/ApacheMP2/Main.pm ↑ Summary Lemonldap/NG/Handler/Main/SharedVariables.pm »
1 package Lemonldap::NG::Handler::Server::Traefik;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Lemonldap::NG::Handler::Server::Main;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '2.19.0';
8  
9 1 extends 'Lemonldap::NG::Handler::PSGI';
10  
11 sub init {
12 1 ▶ my $self = shift;
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
13 1 $self->api('Lemonldap::NG::Handler::Server::Main');
14 1 my $tmp = $self->SUPER::init(@_);
15 }
16  
17 sub _run {
18 1 ▶ my $self = shift;
Subroutine _run: called CC=1 SCAR=0.0
19  
20 # Create regular _authAndTrace PSGI app
21 my $app = $self->psgiAdapter(
22 sub {
23 14 ▶ my $req = $_[0];
Subroutine __ANON__: called CC=1 SCAR=0.0
24 14 return $self->_authAndTrace($req);
25 }
26 1 );
27  
28 # Middleware to set correct values for Traefik
29 return sub {
30 14 ▶ my $env = $_[0];
Subroutine __ANON__: called CC=1 SCAR=0.0
31 14 $env->{HTTP_HOST} = $env->{HTTP_X_FORWARDED_HOST};
32 14 $env->{REQUEST_URI} = $env->{HTTP_X_FORWARDED_URI};
33 14 return $app->($env);
34 }
35 1 }
36  
37 sub handler {
38 7 ▶ my ( $self, $req ) = @_;
Subroutine handler: called CC=5 SCAR=16.1
Pod undocumented
39 my @convertedHdrs =
40 7 ▶ ( 'Content-Length' => 0, Cookie => ( $req->env->{HTTP_COOKIE} // '' ) );
Condition50%1/2
$req->env->{"HTTP_COOKIE"} // ""
l!l
07
MC/DC0%0/1
$req->env->{"HTTP_COOKIE"} // ""
$req->env->{"HTTP_COOKIE"}
Truth table50%1/2
A
A= $req->env->{"HTTP_COOKIE"}
Aresult
11
00
41 7 ▶ while ( my ( $k, $v ) = splice( @{ $req->{respHeaders} }, 0, 2 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@{$$req{"respHeaders"};}, 0, 2)) 34 7 41
42 34 ▶ if ( $k =~ /^(?:Deleteheader\d+|Cookie)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /^(?:Deleteheader\d+|Cookie)$/) { } 14 20 34
43 14 next;
44 }
45 else {
46 20 push @convertedHdrs, $k, $v;
47 }
48 }
49  
50 # Echo the Authorization header to compensate the fact that Traefik removes
51 # it from the incoming HTTP request
52 7 ▶ if ( my $authorization = $req->headers->header('Authorization') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $authorization = $req->headers->header("Authorization")) 1 6 7
53 1 push @convertedHdrs, "Authorization" => $authorization;
54 }
55  
56 7 return [ 200, \@convertedHdrs, [] ];
57 }
58  
59 1 1;
« Lemonldap/NG/Handler/ApacheMP2/Main.pm ↑ Summary Lemonldap/NG/Handler/Main/SharedVariables.pm »