| 1 | 4 | ▶ | use v5.42; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use JSON::PP qw[decode_json encode_json]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Digest::SHA; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Crypt::JWT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Crypt::PRNG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use experimental 'try'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | class At::UserAgent v1.8.0 { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | field $accessJwt : reader : param = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | field $refreshJwt : reader : param = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | field $token_type : reader : param = 'Bearer'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | field $dpop_key : reader : param = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | field $dpop_nonce; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | field $auth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | field $at_protocol_proxy : param = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | method at_protocol_proxy ( $new_val = undef ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
at_protocol_proxy: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | $at_protocol_proxy = $new_val if defined $new_val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | return $at_protocol_proxy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | method dpop_nonce ( $new_val = undef ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dpop_nonce: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | $dpop_nonce = $new_val if defined $new_val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return $dpop_nonce; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | method auth ( $new_val = undef ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auth: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $auth = $new_val if defined $new_val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | return $auth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | method set_tokens ( $access, $refresh, $type, $key ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_tokens: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | $accessJwt = $access; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $refreshJwt = $refresh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $token_type = $type // 'Bearer'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$type // "Bearer"
MC/DC0%0/1
$type // "Bearer"
$type
Truth table0%0/2
A
A= $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $dpop_key = $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ( defined $accessJwt ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $self->_set_auth_header( $token_type . ' ' . $accessJwt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->_set_auth_header(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | method _generate_dpop_proof( $url, $method, $skip_ath = 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_dpop_proof: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | return unless $dpop_key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $jwk_json = $dpop_key->export_key_jwk('public'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $jwk = JSON::PP::decode_json($jwk_json); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $htu = URI->new($url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $htu->query(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $htu->fragment(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $payload | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | = { jti => Crypt::PRNG::random_string_from( $chars, 32 ), htm => $method, htu => $htu->as_string, iat => $now, exp => $now + 60, }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | $payload->{nonce} = $dpop_nonce if defined $dpop_nonce; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ( $accessJwt && !$skip_ath ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$accessJwt and not $skip_ath
MC/DC0%0/2
$accessJwt and not $skip_ath
$accessJwt
not $skip_ath
Truth table0%0/3
A and not(B)
A= $accessJwtB= not $skip_ath
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $payload->{ath} = MIME::Base64::encode_base64url( Digest::SHA::sha256($accessJwt) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $payload->{ath} =~ s/=+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return Crypt::JWT::encode_jwt( payload => $payload, key => $dpop_key, alg => 'ES256', extra_headers => { typ => 'dpop+jwt', jwk => $jwk } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | method _set_auth_header ($token) { die "Abstract" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_auth_header: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | method get ( $url, $req = undef ) { die "Abstract" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | method post ( $url, $req = undef ) { die "Abstract" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | method websocket ( $url, $cb ) { die "Abstract" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
websocket: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } class # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | At::UserAgent::Tiny : isa(At::UserAgent) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | use HTTP::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | field $agent : param | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | = HTTP::Tiny->new( agent => 'At.pm/Tiny', default_headers => { 'Content-Type' => 'application/json', Accept => 'application/json' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | method get( $url, $req = {} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=43 SCAR=75.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $req //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$req //= {}
MC/DC0%0/1
$req //= {}
$req
Truth table0%0/2
A
A= $req
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $req->{headers}{DPoP} = $self->_generate_dpop_proof( $url, 'GET', $req->{skip_ath} ) if $self->token_type eq 'DPoP'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | my $res | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | = $agent->get( $url . ( defined $req->{content} && keys %{ $req->{content} } ? '?' . $agent->www_form_urlencode( $req->{content} ) : '' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | { defined $req->{headers} ? ( headers => $req->{headers} ) : () } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $req->{"content"} and keys %{$$req{"content"};}
MC/DC0%0/2
defined $req->{"content"} and keys %{$$req{"content"};}
defined $req->{"content"}
keys %{$$req{"content"};}
Truth table0%0/3
A and B
A= defined $req->{"content"}B= keys %{$$req{"content"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ( $res->{headers} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $nonce; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | foreach my $k ( keys %{ $res->{headers} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ( lc($k) eq 'dpop-nonce' ) { $nonce = $res->{headers}{$k}; last; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | $self->dpop_nonce($nonce) if defined $nonce && $nonce ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $nonce and $nonce ne ""
MC/DC0%0/2
defined $nonce and $nonce ne ""
defined $nonce
$nonce ne ""
Truth table0%0/3
A and B
A= defined $nonceB= $nonce ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $res->{content} = JSON::PP::decode_json( $res->{content} ) if $res->{content} && ( $res->{headers}{'content-type'} // '' ) =~ m[json]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$res->{"content"} and ($res->{"headers"}{"content-type"} // "") =~ /json/u
$res->{"headers"}{"content-type"} // ""
MC/DC0%0/2
$res->{"content"} and ($res->{"headers"}{"content-type"} // "") =~ /json/u
$res->{"content"}
$res->{"headers"}{"content-type"}
Truth table0%0/3
A and B
A= $res->{"content"}B= $res->{"headers"}{"content-type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | unless ( $res->{success} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $body = $res->{content}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ( ( $res->{status} == 401 || $res->{status} == 400 ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$res->{"status"} == 401 || $res->{"status"} == 400 and not ref $body and $body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop|DPoP.*nonce/iu
$res->{"status"} == 401 || $res->{"status"} == 400 and not ref $body
$res->{"status"} == 401 or $res->{"status"} == 400
MC/DC0%0/4
$res->{"status"} == 401 || $res->{"status"} == 400 and not ref $body and $body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop|DPoP.*nonce/iu
$res->{"status"} == 401
$res->{"status"} == 400
not ref $body
$body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop|DPoP.*nonce/iu
Truth table0%0/7
A or B and not(C) and D
A= $res->{"status"} == 401B= $res->{"status"} == 400C= not ref $bodyD= $body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop|DPoP.*nonce/iu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | !ref $body && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | $body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop|DPoP.*nonce/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | my $retry_headers = { %{ $req->{headers} // {} } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$req->{"headers"} // {}
MC/DC0%0/1
$req->{"headers"} // {}
$req->{"headers"}
Truth table0%0/2
A
A= $req->{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $retry_headers->{DPoP} = $self->_generate_dpop_proof( $url, 'GET', $req->{skip_ath} ) if $self->token_type eq 'DPoP'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | $res | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | = $agent->get( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $url . ( defined $req->{content} && keys %{ $req->{content} } ? '?' . $agent->www_form_urlencode( $req->{content} ) : '' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $req->{"content"} and keys %{$$req{"content"};}
MC/DC0%0/2
defined $req->{"content"} and keys %{$$req{"content"};}
defined $req->{"content"}
keys %{$$req{"content"};}
Truth table0%0/3
A and B
A= defined $req->{"content"}B= keys %{$$req{"content"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | { headers => $retry_headers } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ( $res->{headers} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my $nonce = $res->{headers}{'dpop-nonce'} || $res->{headers}{'DPoP-Nonce'} || $res->{headers}{'dpop_nonce'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$res->{'headers'}{'dpop-nonce'} || $res->{'headers'}{'DPoP-Nonce'} || $res->{'headers'}{'dpop_nonce'}
$res->{"headers"}{"dpop-nonce"} or $res->{"headers"}{"DPoP-Nonce"}
MC/DC0%0/3
$res->{'headers'}{'dpop-nonce'} || $res->{'headers'}{'DPoP-Nonce'} || $res->{'headers'}{'dpop_nonce'}
$res->{"headers"}{"dpop-nonce"}
$res->{"headers"}{"DPoP-Nonce"}
$res->{'headers'}{'dpop_nonce'}
Truth table0%0/4
A or B || C
A= $res->{"headers"}{"dpop-nonce"}B= $res->{"headers"}{"DPoP-Nonce"}C= $res->{'headers'}{'dpop_nonce'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | $self->dpop_nonce($nonce) if defined $nonce && $nonce ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $nonce and $nonce ne ""
MC/DC0%0/2
defined $nonce and $nonce ne ""
defined $nonce
$nonce ne ""
Truth table0%0/3
A and B
A= defined $nonceB= $nonce ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | $res->{content} = JSON::PP::decode_json( $res->{content} ) if $res->{content} && ( $res->{headers}{'content-type'} // '' ) =~ m[json]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$res->{"content"} and ($res->{"headers"}{"content-type"} // "") =~ /json/u
$res->{"headers"}{"content-type"} // ""
MC/DC0%0/2
$res->{"content"} and ($res->{"headers"}{"content-type"} // "") =~ /json/u
$res->{"content"}
$res->{"headers"}{"content-type"}
Truth table0%0/3
A and B
A= $res->{"content"}B= $res->{"headers"}{"content-type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | unless ( $res->{success} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my $msg = $res->{reason} // 'Unknown error'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$res->{"reason"} // "Unknown error"
MC/DC0%0/1
$res->{"reason"} // "Unknown error"
$res->{"reason"}
Truth table0%0/2
A
A= $res->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( ref $res->{content} eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $json = $res->{content}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | my $details = $json->{error} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$json->{"error"} // ""
MC/DC0%0/1
$json->{"error"} // ""
$json->{"error"}
Truth table0%0/2
A
A= $json->{"error"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if ( $json->{message} && $json->{message} ne $details ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$json->{"message"} and $json->{"message"} ne $details
MC/DC0%0/2
$json->{"message"} and $json->{"message"} ne $details
$json->{"message"}
$json->{"message"} ne $details
Truth table0%0/3
A and B
A= $json->{"message"}B= $json->{"message"} ne $details
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | $details .= ( $details ? ': ' : '' ) . $json->{message}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | $msg .= ": " . $details if $details; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | $msg .= " - " . $json->{error_description} if $json->{error_description}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | elsif ( $res->{content} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $msg .= " (" . $res->{content} . ")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $res->{content} = At::Error->new( message => $msg, fatal => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | wantarray ? ( $res->{content}, $res->{headers} ) : $res->{content}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | method post( $url, $req = {} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post: not called CC=45 SCAR=76.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | $req //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$req //= {}
MC/DC0%0/1
$req //= {}
$req
Truth table0%0/2
A
A= $req
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | $req->{headers}{DPoP} = $self->_generate_dpop_proof( $url, 'POST', $req->{skip_ath} ) if $self->token_type eq 'DPoP'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ( defined $req->{content} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ( $req->{encoding} && $req->{encoding} eq 'form' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$req->{"encoding"} and $req->{"encoding"} eq "form"
MC/DC0%0/2
$req->{"encoding"} and $req->{"encoding"} eq "form"
$req->{"encoding"}
$req->{"encoding"} eq "form"
Truth table0%0/3
A and B
A= $req->{"encoding"}B= $req->{"encoding"} eq "form"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $content = $agent->www_form_urlencode( $req->{content} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $req->{headers}{'Content-Type'} = 'application/x-www-form-urlencoded'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | elsif ( ref $req->{content} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $content = JSON::PP::encode_json( $req->{content} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $req->{headers}{'Content-Type'} = 'application/json'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $content = $req->{content}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | my $res = $agent->post( $url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | { defined $req->{headers} ? ( headers => $req->{headers} ) : (), defined $content ? ( content => $content ) : () } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if ( $res->{headers} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $nonce; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | foreach my $k ( keys %{ $res->{headers} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ( lc($k) eq 'dpop-nonce' ) { $nonce = $res->{headers}{$k}; last; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | $self->dpop_nonce($nonce) if defined $nonce && $nonce ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $nonce and $nonce ne ""
MC/DC0%0/2
defined $nonce and $nonce ne ""
defined $nonce
$nonce ne ""
Truth table0%0/3
A and B
A= defined $nonceB= $nonce ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $res->{content} = JSON::PP::decode_json( $res->{content} ) if $res->{content} && ( $res->{headers}{'content-type'} // '' ) =~ m[json]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$res->{"content"} and ($res->{"headers"}{"content-type"} // "") =~ /json/u
$res->{"headers"}{"content-type"} // ""
MC/DC0%0/2
$res->{"content"} and ($res->{"headers"}{"content-type"} // "") =~ /json/u
$res->{"content"}
$res->{"headers"}{"content-type"}
Truth table0%0/3
A and B
A= $res->{"content"}B= $res->{"headers"}{"content-type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | unless ( $res->{success} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $body = $res->{content}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if ( ( $res->{status} == 401 || $res->{status} == 400 ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$res->{"status"} == 401 || $res->{"status"} == 400 and not ref $body and $body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop|DPoP.*nonce/iu
$res->{"status"} == 401 || $res->{"status"} == 400 and not ref $body
$res->{"status"} == 401 or $res->{"status"} == 400
MC/DC0%0/4
$res->{"status"} == 401 || $res->{"status"} == 400 and not ref $body and $body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop|DPoP.*nonce/iu
$res->{"status"} == 401
$res->{"status"} == 400
not ref $body
$body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop|DPoP.*nonce/iu
Truth table0%0/7
A or B and not(C) and D
A= $res->{"status"} == 401B= $res->{"status"} == 400C= not ref $bodyD= $body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop|DPoP.*nonce/iu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | !ref $body && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | $body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop|DPoP.*nonce/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | my $retry_headers = { %{ $req->{headers} // {} } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$req->{"headers"} // {}
MC/DC0%0/1
$req->{"headers"} // {}
$req->{"headers"}
Truth table0%0/2
A
A= $req->{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | $retry_headers->{DPoP} = $self->_generate_dpop_proof( $url, 'POST', $req->{skip_ath} ) if $self->token_type eq 'DPoP'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $retry_content = $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | $res = $agent->post( $url, { headers => $retry_headers, defined $retry_content ? ( content => $retry_content ) : () } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if ( $res->{headers} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | my $nonce = $res->{headers}{'dpop-nonce'} || $res->{headers}{'DPoP-Nonce'} || $res->{headers}{'dpop_nonce'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$res->{'headers'}{'dpop-nonce'} || $res->{'headers'}{'DPoP-Nonce'} || $res->{'headers'}{'dpop_nonce'}
$res->{"headers"}{"dpop-nonce"} or $res->{"headers"}{"DPoP-Nonce"}
MC/DC0%0/3
$res->{'headers'}{'dpop-nonce'} || $res->{'headers'}{'DPoP-Nonce'} || $res->{'headers'}{'dpop_nonce'}
$res->{"headers"}{"dpop-nonce"}
$res->{"headers"}{"DPoP-Nonce"}
$res->{'headers'}{'dpop_nonce'}
Truth table0%0/4
A or B || C
A= $res->{"headers"}{"dpop-nonce"}B= $res->{"headers"}{"DPoP-Nonce"}C= $res->{'headers'}{'dpop_nonce'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | $self->dpop_nonce($nonce) if defined $nonce && $nonce ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $nonce and $nonce ne ""
MC/DC0%0/2
defined $nonce and $nonce ne ""
defined $nonce
$nonce ne ""
Truth table0%0/3
A and B
A= defined $nonceB= $nonce ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | $res->{content} = JSON::PP::decode_json( $res->{content} ) if $res->{content} && ( $res->{headers}{'content-type'} // '' ) =~ m[json]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$res->{"content"} and ($res->{"headers"}{"content-type"} // "") =~ /json/u
$res->{"headers"}{"content-type"} // ""
MC/DC0%0/2
$res->{"content"} and ($res->{"headers"}{"content-type"} // "") =~ /json/u
$res->{"content"}
$res->{"headers"}{"content-type"}
Truth table0%0/3
A and B
A= $res->{"content"}B= $res->{"headers"}{"content-type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | unless ( $res->{success} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | my $msg = $res->{reason} // 'Unknown error'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$res->{"reason"} // "Unknown error"
MC/DC0%0/1
$res->{"reason"} // "Unknown error"
$res->{"reason"}
Truth table0%0/2
A
A= $res->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if ( ref $res->{content} eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $json = $res->{content}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | my $details = $json->{error} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$json->{"error"} // ""
MC/DC0%0/1
$json->{"error"} // ""
$json->{"error"}
Truth table0%0/2
A
A= $json->{"error"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ( $json->{message} && $json->{message} ne $details ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$json->{"message"} and $json->{"message"} ne $details
MC/DC0%0/2
$json->{"message"} and $json->{"message"} ne $details
$json->{"message"}
$json->{"message"} ne $details
Truth table0%0/3
A and B
A= $json->{"message"}B= $json->{"message"} ne $details
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | $details .= ( $details ? ': ' : '' ) . $json->{message}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | $msg .= ": " . $details if $details; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | $msg .= " - " . $json->{error_description} if $json->{error_description}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | elsif ( $res->{content} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $msg .= " (" . $res->{content} . ")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $res->{content} = At::Error->new( message => $msg, fatal => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | wantarray ? ( $res->{content}, $res->{headers} ) : $res->{content}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | method websocket ( $url, $cb ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
websocket: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | die "At::UserAgent::Tiny does not support WebSockets. Please install Mojo::UserAgent."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | method _set_auth_header($token) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_auth_header: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $self->auth($token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $agent->{default_headers}{Authorization} = $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } class # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | At::UserAgent::Mojo : isa(At::UserAgent) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 4 | field $agent : param = do { require Mojo::UserAgent; Mojo::UserAgent->new }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | method get( $url, $req = {} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=34 SCAR=70.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | $req //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$req //= {}
MC/DC0%0/1
$req //= {}
$req
Truth table0%0/2
A
A= $req
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | my $headers = { %{ $req->{headers} // {} } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$req->{"headers"} // {}
MC/DC0%0/1
$req->{"headers"} // {}
$req->{"headers"}
Truth table0%0/2
A
A= $req->{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if ( $self->at_protocol_proxy ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $headers->{'atproto-proxy'} = $self->at_protocol_proxy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | $headers->{Authorization} = $self->auth if defined $self->auth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | $headers->{DPoP} = $self->_generate_dpop_proof( $url, 'GET', $req->{skip_ath} ) if $self->token_type eq 'DPoP'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if ( $ENV{DEBUG} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | say "[DEBUG] [At] GET $url"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | say "[DEBUG] [At] Headers: " . JSON::PP::encode_json($headers); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | my $tx = $agent->get( $url, $headers, defined $req->{content} ? ( form => $req->{content} ) : () ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my $res = $tx->result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if ( my $nonce = $res->headers->header('DPoP-Nonce') ) { $self->dpop_nonce($nonce); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if ( $ENV{DEBUG} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | say "[DEBUG] [At] Response Code: " . $res->code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | say "[DEBUG] [At] Response Headers: " . JSON::PP::encode_json( $res->headers->to_hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if ( $res->code == 401 || $res->code == 400 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->code == 401 or $res->code == 400
MC/DC0%0/2
$res->code == 401 or $res->code == 400
$res->code == 401
$res->code == 400
Truth table0%0/3
A or B
A= $res->code == 401B= $res->code == 400
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | my $body = $res->body // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$res->body // ""
MC/DC0%0/1
$res->body // ""
$res->body
Truth table0%0/2
A
A= $res->body
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | if ( $body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | say "[DEBUG] [At] Retrying with fresh DPoP nonce..." if $ENV{DEBUG}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | $headers->{DPoP} = $self->_generate_dpop_proof( $url, 'GET', $req->{skip_ath} ) if $self->token_type eq 'DPoP'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | if ( $ENV{DEBUG} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | say "[DEBUG] [At] GET (Retry) $url"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | say "[DEBUG] [At] Headers (Retry): " . JSON::PP::encode_json($headers); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | $tx = $agent->get( $url, $headers, defined $req->{content} ? ( form => $req->{content} ) : () ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $res = $tx->result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if ( my $nonce = $res->headers->header('DPoP-Nonce') ) { $self->dpop_nonce($nonce); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if ( $ENV{DEBUG} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | say "[DEBUG] [At] Response Code (Retry): " . $res->code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | say "[DEBUG] [At] Response Headers (Retry): " . JSON::PP::encode_json( $res->headers->to_hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if ( $res->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | my $content = $res->body ? ( $res->headers->content_type // '' ) =~ m[json] ? $res->json : $res->body : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
$res->headers->content_type // ""
MC/DC0%0/1
$res->headers->content_type // ""
$res->headers->content_type
Truth table0%0/2
A
A= $res->headers->content_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | return wantarray ? ( $content, $res->headers->to_hash ) : $content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $msg = $res->message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if ( my $body = $res->body ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my $json; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | try { $json = JSON::PP::decode_json($body) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | catch ($e) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if ($json) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | my $details = $json->{error} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$json->{"error"} // ""
MC/DC0%0/1
$json->{"error"} // ""
$json->{"error"}
Truth table0%0/2
A
A= $json->{"error"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if ( $json->{message} && $json->{message} ne $details ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$json->{"message"} and $json->{"message"} ne $details
MC/DC0%0/2
$json->{"message"} and $json->{"message"} ne $details
$json->{"message"}
$json->{"message"} ne $details
Truth table0%0/3
A and B
A= $json->{"message"}B= $json->{"message"} ne $details
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | $details .= ( $details ? ': ' : '' ) . $json->{message}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | $msg .= ": " . $details if $details; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | $msg .= " - " . $json->{error_description} if $json->{error_description}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $msg .= " (" . $body . ")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | return At::Error->new( message => $msg, fatal => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | method post( $url, $req = {} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post: not called CC=36 SCAR=71.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | $req //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$req //= {}
MC/DC0%0/1
$req //= {}
$req
Truth table0%0/2
A
A= $req
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | my $headers = { %{ $req->{headers} // {} } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$req->{"headers"} // {}
MC/DC0%0/1
$req->{"headers"} // {}
$req->{"headers"}
Truth table0%0/2
A
A= $req->{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if ( $self->at_protocol_proxy ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $headers->{'atproto-proxy'} = $self->at_protocol_proxy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | $headers->{Authorization} = $self->auth if defined $self->auth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | $headers->{DPoP} = $self->_generate_dpop_proof( $url, 'POST', $req->{skip_ath} ) if $self->token_type eq 'DPoP'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if ( $ENV{DEBUG} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | say "[DEBUG] [At] POST $url"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | say "[DEBUG] [At] Headers: " . JSON::PP::encode_json($headers); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if ( defined $req->{content} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ( $req->{encoding} && $req->{encoding} eq 'form' ) { $args{form} = $req->{content}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$req->{"encoding"} and $req->{"encoding"} eq "form"
MC/DC0%0/2
$req->{"encoding"} and $req->{"encoding"} eq "form"
$req->{"encoding"}
$req->{"encoding"} eq "form"
Truth table0%0/3
A and B
A= $req->{"encoding"}B= $req->{"encoding"} eq "form"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | elsif ( ref $req->{content} ) { $args{json} = $req->{content}; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | else { $args{content} = $req->{content}; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $tx = $agent->post( $url, $headers, %args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $res = $tx->result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ( my $nonce = $res->headers->header('DPoP-Nonce') ) { $self->dpop_nonce($nonce); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if ( $ENV{DEBUG} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | say "[DEBUG] [At] Response Code: " . $res->code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | say "[DEBUG] [At] Response Headers: " . JSON::PP::encode_json( $res->headers->to_hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | if ( $res->code == 401 || $res->code == 400 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->code == 401 or $res->code == 400
MC/DC0%0/2
$res->code == 401 or $res->code == 400
$res->code == 401
$res->code == 400
Truth table0%0/3
A or B
A= $res->code == 401B= $res->code == 400
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | my $body = $res->body // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$res->body // ""
MC/DC0%0/1
$res->body // ""
$res->body
Truth table0%0/2
A
A= $res->body
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if ( $body =~ /use_dpop_nonce|dpop_nonce|required nonce|nonce in dpop/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | say "[DEBUG] [At] Retrying with fresh DPoP nonce..." if $ENV{DEBUG}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | $headers->{DPoP} = $self->_generate_dpop_proof( $url, 'POST', $req->{skip_ath} ) if $self->token_type eq 'DPoP'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if ( $ENV{DEBUG} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | say "[DEBUG] [At] POST (Retry) $url"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | say "[DEBUG] [At] Headers (Retry): " . JSON::PP::encode_json($headers); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $tx = $agent->post( $url, $headers, %args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $res = $tx->result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if ( my $nonce = $res->headers->header('DPoP-Nonce') ) { $self->dpop_nonce($nonce); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | if ( $ENV{DEBUG} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | say "[DEBUG] [At] Response Code (Retry): " . $res->code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | say "[DEBUG] [At] Response Headers (Retry): " . JSON::PP::encode_json( $res->headers->to_hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if ( $res->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | my $content = $res->body ? ( $res->headers->content_type // '' ) =~ m[json] ? $res->json : $res->body : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
$res->headers->content_type // ""
MC/DC0%0/1
$res->headers->content_type // ""
$res->headers->content_type
Truth table0%0/2
A
A= $res->headers->content_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | return wantarray ? ( $content, $res->headers->to_hash ) : $content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $msg = $res->message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | if ( my $body = $res->body ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $json; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | try { $json = JSON::PP::decode_json($body) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | catch ($e) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ($json) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | my $details = $json->{error} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$json->{"error"} // ""
MC/DC0%0/1
$json->{"error"} // ""
$json->{"error"}
Truth table0%0/2
A
A= $json->{"error"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | if ( $json->{message} && $json->{message} ne $details ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$json->{"message"} and $json->{"message"} ne $details
MC/DC0%0/2
$json->{"message"} and $json->{"message"} ne $details
$json->{"message"}
$json->{"message"} ne $details
Truth table0%0/3
A and B
A= $json->{"message"}B= $json->{"message"} ne $details
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | $details .= ( $details ? ': ' : '' ) . $json->{message}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | $msg .= ": " . $details if $details; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | $msg .= " - " . $json->{error_description} if $json->{error_description}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $msg .= " (" . $body . ")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | return At::Error->new( message => $msg, fatal => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | method websocket( $url, $cb ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
websocket: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $agent->inactivity_timeout(0); # Disable inactivity timeout for firehose | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | $agent->websocket( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | $url => sub ( $ua, $tx ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ( !$tx->is_websocket ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $cb->( undef, At::Error->new( message => "WebSocket handshake failed", fatal => 0 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # Keep-alive heartbeat every 20 seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | my $id = Mojo::IOLoop->recurring( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | 20 => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | return unless $tx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $tx->send( [ 1, 0, 0, 0, 9, '' ] ); # Raw Ping frame | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # Activity watchdog: if we don't get a message for 10 seconds, close and reconnect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $watchdog; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | my $reset_watchdog = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | Mojo::IOLoop->remove($watchdog) if defined $watchdog; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | $watchdog = Mojo::IOLoop->timer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | 10 => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $tx->finish( 4000, "Watchdog timeout" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | $reset_watchdog->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | $tx->on( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | message => sub ( $tx, $msg ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $reset_watchdog->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $cb->( $msg, undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | $tx->on( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | finish => sub ( $tx, $code, $reason ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | Mojo::IOLoop->remove($id) if defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | Mojo::IOLoop->remove($watchdog) if defined $watchdog; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $cb->( undef, At::Error->new( message => "WebSocket finished: $code " . ( $reason // '' ), fatal => 0 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$reason // ""
MC/DC0%0/1
$reason // ""
$reason
Truth table0%0/2
A
A= $reason
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $tx = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | method _set_auth_header($token) { $self->auth($token); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_auth_header: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 4 | } 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||