APIClient/Utils/HTTPSession.pm

filter: Statementstmt 90.0% 18 / 20 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 72.2% 26 / 36 CC 4 SCAR 8.4
CC
4
Cov
78%
parse_token
3.8
get_login_request_pieces
2.0
BEGIN
1.0
CRAP 2.3
« APIClient/Transport/HTTPSync.pm ↑ Summary APIClient/TransportBase/TLSVerificationBase.pm »
1 package cPanel::APIClient::Utils::HTTPSession;
2  
3 # Copyright 2020 cPanel, L. L. C.
4 # All rights reserved.
5 # http://cpanel.net
6 #
7 # This is free software; you can redistribute it and/or modify it under the
8 # same terms as Perl itself. See L<perlartistic>.
9  
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use cPanel::APIClient::Utils::HTTPRequest ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶sub get_login_request_pieces {
Subroutine get_login_request_pieces: called CC=2 SCAR=7.0
Pod undocumented
16 1 my ( $username, $password, $tfa_token ) = @_;
17  
18 1 my %payload = (
19 user => $username,
20 pass => $password,
21 login_only => 1,
22 );
23  
24 1 ▶ $payload{'tfa_token'} = $tfa_token if $tfa_token;
Branch: 1 branch
BranchTrueFalseTotal
if $tfa_token 1 0 1
25  
26 return (
27 1 'POST',
28 '/login',
29 cPanel::APIClient::Utils::HTTPRequest::encode_form(\%payload),
30 );
31 }
32  
33 1 ▶sub parse_token {
Subroutine parse_token: called CC=3 SCAR=13.5
Pod undocumented
34 1 my ($response_obj) = @_;
35  
36 1 ▶ my $loc = $response_obj->header('location') || do {
Condition33%1/3
$response_obj->header('location') || do { die "No \342\200\234Location\342\200\235 header given: " . $response_obj->as_string }
l!l&&r!l&&!r
100
MC/DC0%0/2
$response_obj->header('location') || do { die "No \342\200\234Location\342\200\235 header given: " . $response_obj->as_string }
$response_obj->header('location') do { die "No \342\200\234Location\342\200\235 header given: " . $response_obj->as_string }
Truth table33%1/3
A || B
A= $response_obj->header('location')B= do { die "No \342\200\234Location\342\200\235 header given: " . $response_obj->as_string }
ABresult
1X1
011
000
37 0 die "No “Location” header given: " . $response_obj->as_string();
38 };
39  
40 1 ▶ $loc =~ m<\A(/[^/]+)> or do {
Branch: 1 branch
BranchTrueFalseTotal
$loc =~ m[\A(/[^/]+)] or do { die "Unrecognized \342\200\234Location\342\200\235 header: $loc" } 1 0 1
41 0 die "Unrecognized “Location” header: $loc";
42 };
43  
44 1 return $1;
45 }
46  
47 1 1;
« APIClient/Transport/HTTPSync.pm ↑ Summary APIClient/TransportBase/TLSVerificationBase.pm »