blib/lib/Authen/ModAuthToken.pm

filter: Statementstmt 100% 33 / 33 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 90.2% 46 / 51 CC 7 SCAR 15.4
CC
7
Cov
91%
generate_mod_auth_token
7.3
BEGIN
1.0
BEGIN
1.0
CRAP 4.7
↑ Summary
1 package Authen::ModAuthToken;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 require Exporter;
5 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Digest::MD5 qw/md5_hex/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 our @ISA = qw(Exporter);
10 3 our @EXPORT_OK = qw/generate_mod_auth_token/;
11  
12 3 our $VERSION = '0.03';
13  
14 sub generate_mod_auth_token
15 1 ▶{
Subroutine generate_mod_auth_token: called CC=7 SCAR=19.8
Pod documented
16 1 my %args = @_;
17  
18 1 ▶ my $secret = $args{secret} or croak "Missing 'secret' key value";
Branch: 1 branch
BranchTrueFalseTotal
my $secret = $args{"secret"} or croak("Missing 'secret' key value") 1 0 1
19 1 ▶ my $remote_addr = $args{remote_addr} || "";
Condition50%1/2
$args{'remote_addr'} || ''
l!l
01
MC/DC0%0/1
$args{'remote_addr'} || ''
$args{'remote_addr'}
Truth table50%1/2
A
A= $args{'remote_addr'}
Aresult
11
00
20 1 ▶ my $filepath = $args{filepath} or croak "Missing 'filepath' key value";
Branch: 1 branch
BranchTrueFalseTotal
my $filepath = $args{"filepath"} or croak("Missing 'filepath' key value") 1 0 1
21 1 ▶ die "'filepath' key value should start with '/'" unless substr($filepath,0,1) eq "/";
Branch: 1 branch
BranchTrueFalseTotal
unless substr($filepath, 0, 1) eq "/" 0 1 1
22  
23 1 my $hexTime = sprintf("%08x", time());
24 1 my $token_md5 = md5_hex ( $secret . $filepath . $hexTime . $remote_addr);
25  
26 1 my $encoded_url = "";
27 1 foreach my $part ( split '/', $filepath ) {
28 2 ▶ next unless $part;
Branch: 1 branch
BranchTrueFalseTotal
unless $part 1 1 2
29 1 $encoded_url .= "/" . uri_escape($part) ;
30 }
31  
32 1 my $url = "/" . $token_md5 . "/" . $hexTime . $encoded_url;
33  
34 1 return $url;
35 }
36  
37 # ABSTRACT: A Module to generate Mod-Auth-Token compatible URLs
38  
39 3 1;
40 __END__
↑ Summary