Plack/Middleware/DoormanAuthentication.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 6 / 6 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 92.5% 50 / 54 CC 6 SCAR 12.6
CC
6
Cov
95%
call
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.5
« Plack/Middleware/DoormanGoogleFederatedLogin.pm ↑ Summary Doorman/PlackMiddleware.pm »
1 package Plack::Middleware::DoormanAuthentication;
2 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 our $VERSION = "0.06";
6 2 our $AUTHORITY = "http://gugod.org";
7  
8 2 ▶use parent 'Doorman::PlackMiddleware';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Plack::Util::Accessor qw(authenticator);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Plack::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 6 ▶sub is_sign_in {
Subroutine is_sign_in: called CC=1 SCAR=0.0
Pod documented
14 6 $_[0]->session_get("authenticated");
15 }
16  
17 6 ▶sub call {
Subroutine call: called CC=6 SCAR=18.0
Pod documented
18 6 my ($self, $env) = @_;
19  
20 6 $self->prepare_call($env);
21  
22 6 $env->{ $self->fq } = $self;
23  
24 6 my $request = Plack::Request->new($env);
25  
26 6 ▶ if ($request->method eq 'POST' and $request->path eq $self->sign_in_path) {
Branch: 2 branches
BranchTrueFalseTotal
if ($request->method eq 'POST' and $request->path eq $self->sign_in_path) { } 2 4 6
elsif ($request->method eq 'GET' and $request->path eq $self->sign_out_path) { } 1 3 4
Condition66%2/3
$request->method eq "POST" and $request->path eq $self->sign_in_path
!ll&&!rl&&r
402
MC/DC50%1/2
$request->method eq "POST" and $request->path eq $self->sign_in_path
$request->method eq "POST" $request->path eq $self->sign_in_path
Truth table66%2/3
A and B
A= $request->method eq "POST"B= $request->path eq $self->sign_in_path
ABresult
0X0
100
111
27 2 my ($success, $error_message) = $self->authenticator->($self, $self->{env});
28 2 ▶ if ($success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($success) { } 1 1 2
29 1 $self->session_set("authenticated" => $success);
30 }
31 else {
32 1 $self->env_set("error" => $error_message);
33 }
34 }
35 ▶ elsif ($request->method eq 'GET' and $request->path eq $self->sign_out_path) {
Condition66%2/3
$request->method eq "GET" and $request->path eq $self->sign_out_path
!ll&&!rl&&r
031
MC/DC50%1/2
$request->method eq "GET" and $request->path eq $self->sign_out_path
$request->method eq "GET" $request->path eq $self->sign_out_path
Truth table66%2/3
A and B
A= $request->method eq "GET"B= $request->path eq $self->sign_out_path
ABresult
0X0
100
111
36 1 $self->session_remove("authenticated");
37 }
38  
39 6 return $self->app->($env);
40 }
41  
42 2 1;
43  
44 __END__
« Plack/Middleware/DoormanGoogleFederatedLogin.pm ↑ Summary Doorman/PlackMiddleware.pm »