OAuth/Message.pm

filter: Statementstmt 91.1% 206 / 226 Branchbran 79.6% 51 / 64 Conditioncond 64.4% 38 / 59 MC/DCmcdc 35.2% 12 / 34 Subroutinesub 94.8% 37 / 39 Podpod 3.7% 1 / 27 totaltotal 76.8% 345 / 449 CC 62 SCAR 18.7
CC
62
Cov
85%
gather_message_parameters
17.0
from_hash
10.2
check
7.2
CRAP 6.5
↑ Summary OAuth/Client.pm »
1 package Net::OAuth::Message;
2 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use base qw/Class::Data::Inheritable Class::Accessor/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use Net::OAuth;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use URI::QueryParam;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 13 ▶use constant OAUTH_PREFIX => 'oauth_';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 13 our $OAUTH_PREFIX_RE = do {my $p = OAUTH_PREFIX; qr/^$p/};
14  
15 13 __PACKAGE__->mk_classdata(extension_param_patterns => []);
16  
17 sub add_required_message_params {
18 20 ▶ my $class = shift;
Subroutine add_required_message_params: called CC=1 SCAR=0.0
Pod undocumented
19 20 $class->required_message_params([@{$class->required_message_params}, @_]);
20 20 $class->all_message_params([@{$class->all_message_params}, @_]);
21 20 $class->all_params([@{$class->all_params}, @_]);
22 20 $class->mk_accessors(@_);
23 }
24  
25 sub add_optional_message_params {
26 0 ▶ my $class = shift;
Subroutine add_optional_message_params: not called CC=1 SCAR=6.9
Pod undocumented
27 0 $class->optional_message_params([@{$class->optional_message_params}, @_]);
28 0 $class->all_message_params([@{$class->all_message_params}, @_]);
29 0 $class->all_params([@{$class->all_params}, @_]);
30 0 $class->mk_accessors(@_);
31 }
32  
33 sub add_required_api_params {
34 10 ▶ my $class = shift;
Subroutine add_required_api_params: called CC=1 SCAR=0.0
Pod undocumented
35 10 $class->required_api_params([@{$class->required_api_params}, @_]);
36 10 $class->all_api_params([@{$class->all_api_params}, @_]);
37 10 $class->all_params([@{$class->all_params}, @_]);
38 10 $class->mk_accessors(@_);
39 }
40  
41 sub add_extension_param_pattern {
42 1 ▶ my $class = shift;
Subroutine add_extension_param_pattern: called CC=1 SCAR=0.0
Pod undocumented
43 1 $class->extension_param_patterns([@{$class->extension_param_patterns}, @_]);
44 }
45  
46 sub add_to_signature {
47 0 ▶ my $class = shift;
Subroutine add_to_signature: not called CC=1 SCAR=6.9
Pod undocumented
48 0 $class->signature_elements([@{$class->signature_elements}, @_]);
49 }
50  
51 sub new {
52 45 ▶ my $proto = shift;
Subroutine new: called CC=2 SCAR=7.1
Pod documented
53 45 ▶ my $class = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
0450
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
54 45 my %params = @_;
55 45 $class = get_versioned_class($class, \%params);
56 45 my $self = bless \%params, $class;
57 45 $self->set_defaults;
58 45 $self->check;
59 42 return $self;
60 }
61  
62 sub get_versioned_class {
63 54 ▶ my $class = shift;
Subroutine get_versioned_class: called CC=6 SCAR=18.0
Pod undocumented
64 54 my $params = shift;
65 54 ▶ my $protocol_version = $params->{protocol_version} || $Net::OAuth::PROTOCOL_VERSION;
Condition66%2/3
$params->{'protocol_version'} || $Net::OAuth::PROTOCOL_VERSION
l!l&&r!l&&!r
7470
MC/DC0%0/2
$params->{'protocol_version'} || $Net::OAuth::PROTOCOL_VERSION
$params->{'protocol_version'} $Net::OAuth::PROTOCOL_VERSION
Truth table66%2/3
A || B
A= $params->{'protocol_version'}B= $Net::OAuth::PROTOCOL_VERSION
ABresult
1X1
011
000
66 54 ▶ if (defined $protocol_version and $protocol_version == Net::OAuth::PROTOCOL_VERSION_1_0A and $class !~ /\::V1_0A\::/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $protocol_version and $protocol_version == "1.001" and not $class =~ /\::V1_0A\::/) 13 41 54
Condition83%5/6
defined $protocol_version and $protocol_version == "1.001" and not $class =~ /\::V1_0A\::/
!ll&&!rl&&r
37413
defined $protocol_version and $protocol_version == "1.001"
!ll&&!rl&&r
03717
MC/DC66%2/3
defined $protocol_version and $protocol_version == "1.001" and not $class =~ /\::V1_0A\::/
defined $protocol_version $protocol_version == "1.001" not $class =~ /\::V1_0A\::/
Truth table75%3/4
A and B and not(C)
A= defined $protocol_versionB= $protocol_version == "1.001"C= not $class =~ /\::V1_0A\::/
ABCresult
0XX0
10X0
1100
1111
67 13 (my $versioned_class = $class) =~ s/::(\w+)$/::V1_0A::$1/;
68 13 ▶ return $versioned_class if Net::OAuth::smart_require($versioned_class);
Branch: 1 branch
BranchTrueFalseTotal
if Net::OAuth::smart_require($versioned_class) 11 2 13
69 }
70 43 return $class;
71 }
72  
73 sub set_defaults {
74 45 ▶ my $self = shift;
Subroutine set_defaults: called CC=4 SCAR=13.9
Pod undocumented
75 45 ▶ $self->{extra_params} ||= {};
Condition100%2/2
$self->{"extra_params"} ||= {}
l!l
1728
MC/DC100%1/1
$self->{"extra_params"} ||= {}
$self->{"extra_params"}
Truth table100%2/2
A
A= $self->{"extra_params"}
Aresult
11
00
76 45 ▶ $self->{version} ||= Net::OAuth::OAUTH_VERSION unless $self->{from_hash};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"from_hash"} 37 8 45
Condition50%1/2
$self->{"version"} ||= "1.0"
l!l
037
MC/DC0%0/1
$self->{"version"} ||= "1.0"
$self->{"version"}
Truth table50%1/2
A
A= $self->{"version"}
Aresult
11
00
77 }
78  
79 sub is_extension_param {
80 462 ▶ my $self = shift;
Subroutine is_extension_param: called CC=1 SCAR=0.0
Pod undocumented
81 462 my $param = shift;
82 462 return grep ($param =~ $_, @{$self->extension_param_patterns});
83 }
84  
85 sub check {
86 45 ▶ my $self = shift;
Subroutine check: called CC=7 SCAR=19.7
Pod undocumented
87 45 foreach my $k (@{$self->required_message_params}, @{$self->required_api_params}) {
88 289 ▶ if (not defined $self->{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{$k}) 3 286 289
89 3 croak "Missing required parameter '$k'";
90 }
91 }
92 42 ▶ if ($self->{extra_params} and $self->allow_extra_params) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"extra_params"} and $self->allow_extra_params) 35 7 42
Condition66%2/3
$self->{"extra_params"} and $self->allow_extra_params
!ll&&!rl&&r
0735
MC/DC50%1/2
$self->{"extra_params"} and $self->allow_extra_params
$self->{"extra_params"} $self->allow_extra_params
Truth table66%2/3
A and B
A= $self->{"extra_params"}B= $self->allow_extra_params
ABresult
0X0
100
111
93 35 foreach my $k (keys %{$self->{extra_params}}) {
94 24 ▶ if ($k =~ $OAUTH_PREFIX_RE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /$Net::OAuth::Message::OAUTH_PREFIX_RE/) 0 24 24
95 0 croak "Parameter '$k' not allowed in arbitrary params"
96 }
97 }
98 }
99 }
100  
101 sub encode {
102 1207 ▶ my $str = shift;
Subroutine encode: called CC=5 SCAR=16.1
Pod undocumented
103 1207 ▶ $str = "" unless defined $str;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 18 1189 1207
104 1207 ▶ unless($Net::OAuth::SKIP_UTF8_DOUBLE_ENCODE_CHECK) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Net::OAuth::SKIP_UTF8_DOUBLE_ENCODE_CHECK) 1207 0 1207
105 1207 ▶ if ($str =~ /[\x80-\xFF]/ and !utf8::is_utf8($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /[\x80-\xFF]/ and not utf8::is_utf8($str)) 1 1206 1207
Condition100%3/3
$str =~ /[\x80-\xFF]/ and not utf8::is_utf8($str)
!ll&&!rl&&r
120421
MC/DC100%2/2
$str =~ /[\x80-\xFF]/ and not utf8::is_utf8($str)
$str =~ /[\x80-\xFF]/ not utf8::is_utf8($str)
Truth table100%3/3
A and not(B)
A= $str =~ /[\x80-\xFF]/B= not utf8::is_utf8($str)
ABresult
0X0
100
111
106 1 warn "Net::OAuth warning: your OAuth message appears to contain some multi-byte characters that need to be decoded via Encode.pm or a PerlIO layer first. This may result in an incorrect signature.";
107 }
108 }
109 1207 return URI::Escape::uri_escape_utf8($str);
110 }
111  
112 sub decode {
113 62 ▶ my $str = shift;
Subroutine decode: called CC=1 SCAR=0.0
Pod undocumented
114 62 return uri_unescape($str);
115 }
116  
117 46 ▶sub allow_extra_params {1}
Subroutine allow_extra_params: called CC=1 SCAR=0.0
Pod undocumented
118  
119 10 ▶sub sign_message {0}
Subroutine sign_message: called CC=1 SCAR=0.0
Pod undocumented
120  
121 sub gather_message_parameters {
122 77 ▶ my $self = shift;
Subroutine gather_message_parameters: called CC=17 SCAR=28.3
Pod undocumented
123 77 my %opts = @_;
124 77 ▶ $opts{quote} = "" unless defined $opts{quote};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{"quote"} 73 4 77
125 77 ▶ $opts{params} ||= [];
Condition50%1/2
$opts{"params"} ||= []
l!l
077
MC/DC0%0/1
$opts{"params"} ||= []
$opts{"params"}
Truth table50%1/2
A
A= $opts{"params"}
Aresult
11
00
126 77 my %params;
127 77 foreach my $k (@{$self->required_message_params}, @{$self->optional_message_params}, @{$opts{add}}) {
128 512 ▶ next if $k eq 'signature' and (!$self->sign_message or !grep ($_ eq 'signature', @{$opts{add}}));
Branch: 1 branch
BranchTrueFalseTotal
if $k eq "signature" and not $self->sign_message && grep(($_ eq "signature"), @{$opts{"add"};}) 52 460 512
Condition100%6/6
$k eq "signature" and not $self->sign_message && grep(($_ eq "signature"), @{$opts{"add"};})
!ll&&!rl&&r
4105052
$self->sign_message && grep(($_ eq 'signature'), @{$opts{'add'};})
!ll&&!rl&&r
104250
MC/DC100%3/3
$k eq "signature" and not $self->sign_message && grep(($_ eq "signature"), @{$opts{"add"};})
$k eq "signature" $self->sign_message grep(($_ eq 'signature'), @{$opts{'add'};})
Truth table100%4/4
A and not(B && C)
A= $k eq "signature"B= $self->sign_messageC= grep(($_ eq 'signature'), @{$opts{'add'};})
ABCresult
0XX0
1110
10X1
1101
129 460 ▶ my $message_key = $self->is_extension_param($k) ? $k : OAUTH_PREFIX . $k;
Branch: 1 branch
BranchTrueFalseTotal
$self->is_extension_param($k) ? : 3 457 460
130 460 my $v = $self->$k;
131 460 ▶ $params{$message_key} = $v if defined $v;
Branch: 1 branch
BranchTrueFalseTotal
if defined $v 459 1 460
132 }
133 77 ▶ if ($self->{extra_params} and !$opts{no_extra} and $self->allow_extra_params) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"extra_params"} and not $opts{"no_extra"} and $self->allow_extra_params) 61 16 77
Condition83%5/6
$self->{"extra_params"} and not $opts{"no_extra"} and $self->allow_extra_params
!ll&&!rl&&r
41261
$self->{"extra_params"} and not $opts{"no_extra"}
!ll&&!rl&&r
0473
MC/DC66%2/3
$self->{"extra_params"} and not $opts{"no_extra"} and $self->allow_extra_params
$self->{"extra_params"} not $opts{"no_extra"} $self->allow_extra_params
Truth table75%3/4
A and not(B) and C
A= $self->{"extra_params"}B= not $opts{"no_extra"}C= $self->allow_extra_params
ABCresult
0XX0
10X0
1100
1111
134 61 foreach my $k (keys %{$self->{extra_params}}) {
135 45 $params{$k} = $self->{extra_params}{$k};
136 }
137 61 ▶ if ($self->can('request_url')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can("request_url")) 51 10 61
138 51 my $url = $self->request_url;
139 51 _ensure_uri_object($url);
140 51 foreach my $k ($url->query_param) {
141 12 $params{$k} = $url->query_param($k);
142 }
143 }
144 }
145 77 ▶ if ($opts{hash}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"hash"}) 15 62 77
146 15 return \%params;
147 }
148 62 my @pairs;
149 62 ▶ while (my ($k,$v) = each %params) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %params) 393 62 455
150 393 push @pairs, join('=', encode($k), $opts{quote} . encode($v) . $opts{quote});
151 }
152 62 return sort(@pairs);
153 }
154  
155 sub normalized_message_parameters {
156 42 ▶ my $self = shift;
Subroutine normalized_message_parameters: called CC=1 SCAR=0.0
Pod undocumented
157 42 return join('&', $self->gather_message_parameters);
158 }
159  
160 sub signature_base_string {
161 42 ▶ my $self = shift;
Subroutine signature_base_string: called CC=1 SCAR=0.0
Pod undocumented
162 42 return join('&', map(encode($self->$_), @{$self->signature_elements}));
163 }
164  
165 sub sign {
166 25 ▶ my $self = shift;
Subroutine sign: called CC=1 SCAR=0.0
Pod undocumented
167 25 my $class = $self->_signature_method_class;
168 25 $self->signature($class->sign($self, @_));
169 }
170  
171 sub verify {
172 20 ▶ my $self = shift;
Subroutine verify: called CC=1 SCAR=0.0
Pod undocumented
173 20 my $class = $self->_signature_method_class;
174 20 return $class->verify($self, @_);
175 }
176  
177 sub _signature_method_class {
178 45 ▶ my $self = shift;
Subroutine _signature_method_class: called CC=2 SCAR=7.0
179 45 (my $signature_method = $self->signature_method) =~ s/\W+/_/g;
180 45 my $sm_class = 'Net::OAuth::SignatureMethod::' . $signature_method;
181 45 ▶ croak "Unable to load $signature_method plugin" unless Net::OAuth::smart_require($sm_class);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::OAuth::smart_require($sm_class) 0 45 45
182 45 return $sm_class;
183 }
184  
185 sub to_authorization_header {
186 4 ▶ my $self = shift;
Subroutine to_authorization_header: called CC=3 SCAR=11.6
Pod undocumented
187 4 my $realm = shift;
188 4 ▶ my $sep = shift || ",";
Condition50%1/2
shift() || ','
l!l
40
MC/DC0%0/1
shift() || ','
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
189 4 ▶ if (defined $realm) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $realm) { } 4 0 4
190 4 $realm = "realm=\"$realm\"$sep";
191 }
192 else {
193 0 $realm = "";
194 }
195 4 return "OAuth $realm" .
196 join($sep, $self->gather_message_parameters(quote => '"', add => [qw/signature/], no_extra => 1));
197 }
198  
199 sub from_authorization_header {
200 1 ▶ my $proto = shift;
Subroutine from_authorization_header: called CC=4 SCAR=14.8
Pod undocumented
201 1 my $header = shift;
202 1 ▶ my $class = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
100
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
203 1 ▶ croak "Header must start with \"OAuth \"" unless $header =~ s/OAuth //;
Branch: 1 branch
BranchTrueFalseTotal
unless $header =~ s/OAuth // 0 1 1
204 1 my @header = split /[\s]*,[\s]*/, $header;
205 1 ▶ shift @header if $header[0] =~ /^realm=/i;
Branch: 1 branch
BranchTrueFalseTotal
if $header[0] =~ /^realm=/i 1 0 1
206 1 return $class->_from_pairs(\@header, @_)
207 }
208  
209 sub _from_pairs() {
210 4 ▶ my $class = shift;
Subroutine _from_pairs: called CC=5 SCAR=17.0
211 4 my $pairs = shift;
212 4 ▶ if (ref $pairs ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $pairs ne "ARRAY") 0 4 4
213 0 croak 'Expected an array!';
214 }
215 4 my %params;
216 4 foreach my $pair (@$pairs) {
217 16 my ($k,$v) = split /=/, $pair;
218 16 ▶ if (defined $k and defined $v) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $k and defined $v) 16 0 16
Condition33%1/3
defined $k and defined $v
!ll&&!rl&&r
0016
MC/DC0%0/2
defined $k and defined $v
defined $k defined $v
Truth table33%1/3
A and B
A= defined $kB= defined $v
ABresult
0X0
100
111
219 16 $v =~ s/(^"|"$)//g;
220 16 ($k,$v) = map decode($_), $k, $v;
221 16 $params{$k} = $v;
222 }
223 }
224 4 return $class->from_hash(\%params, @_);
225 }
226  
227 sub from_hash {
228 9 ▶ my $proto = shift;
Subroutine from_hash: called CC=8 SCAR=23.2
Pod undocumented
229 9 ▶ my $class = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
090
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
230 9 my $hash = shift;
231 9 ▶ if (ref $hash ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $hash ne "HASH") 0 9 9
232 0 croak 'Expected a hash!';
233 }
234 9 my %api_params = @_;
235 # need to do this earlier than Message->new because
236 # the below validation step needs the correct class.
237 # https://rt.cpan.org/Public/Bug/Display.html?id=47293
238 9 $class = get_versioned_class($class, \%api_params);
239 9 my %msg_params;
240 9 foreach my $k (keys %$hash) {
241 46 ▶ if ($k =~ s/$OAUTH_PREFIX_RE//) {
Branch: 2 branches
BranchTrueFalseTotal
if ($k =~ s/$Net::OAuth::Message::OAUTH_PREFIX_RE//) { } 44 2 46
elsif ($class->is_extension_param($k)) { } 0 2 2
242 44 ▶ if (!grep ($_ eq $k, @{$class->all_message_params})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not grep(($_ eq $k), @{$class->all_message_params;})) { } 1 43 44
243 1 croak "Parameter ". OAUTH_PREFIX ."$k not valid for a message of type $class";
244 }
245 else {
246 43 $msg_params{$k} = $hash->{OAUTH_PREFIX . $k};
247 }
248 }
249 elsif ($class->is_extension_param($k)) {
250 0 ▶ if (!grep ($_ eq $k, @{$class->all_message_params})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not grep(($_ eq $k), @{$class->all_message_params;})) { } 0 0 0
251 0 croak "Parameter $k not valid for a message of type $class";
252 }
253 else {
254 0 $msg_params{$k} = $hash->{$k};
255 }
256 }
257 else {
258 2 $msg_params{extra_params}->{$k} = $hash->{$k};
259 }
260 }
261 8 $api_params{from_hash} = 1;
262 8 return $class->new(%msg_params, %api_params);
263 }
264  
265 sub _ensure_uri_object {
266 110 ▶ $_[0] = UNIVERSAL::isa($_[0], 'URI') ? $_[0] : URI->new($_[0]);
Subroutine _ensure_uri_object: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[0], 'URI') ? : 23 87 110
267 }
268  
269 sub from_url {
270 2 ▶ my $proto = shift;
Subroutine from_url: called CC=2 SCAR=7.2
Pod undocumented
271 2 ▶ my $class = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
200
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
272 2 my $url = shift;
273 2 _ensure_uri_object($url);
274 2 return $class->from_hash($url->query_form_hash, @_);
275 }
276  
277 sub to_post_body {
278 16 ▶ my $self = shift;
Subroutine to_post_body: called CC=1 SCAR=0.0
Pod undocumented
279 16 return join('&', $self->gather_message_parameters(add => [qw/signature/]));
280 }
281  
282 sub from_post_body {
283 3 ▶ my $proto = shift;
Subroutine from_post_body: called CC=2 SCAR=7.4
Pod undocumented
284 3 ▶ my $class = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
030
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
285 3 my @pairs = split '&', shift;
286 3 return $class->_from_pairs(\@pairs, @_);
287 }
288  
289 sub to_hash {
290 15 ▶ my $self = shift;
Subroutine to_hash: called CC=1 SCAR=0.0
Pod undocumented
291 15 return $self->gather_message_parameters(hash => 1, add => [qw/signature/]);
292 }
293  
294 sub to_url {
295 15 ▶ my $self = shift;
Subroutine to_url: called CC=7 SCAR=19.7
Pod undocumented
296 15 my $url = shift;
297 15 ▶ if (!defined $url and $self->can('request_url') and defined $self->request_url) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $url and $self->can("request_url") and defined $self->request_url) 12 3 15
Condition66%4/6
not defined $url and $self->can("request_url") and defined $self->request_url
!ll&&!rl&&r
3012
not defined $url and $self->can("request_url")
!ll&&!rl&&r
3012
MC/DC33%1/3
not defined $url and $self->can("request_url") and defined $self->request_url
not defined $url $self->can("request_url") defined $self->request_url
Truth table50%2/4
not(A) and B and C
A= not defined $urlB= $self->can("request_url")C= defined $self->request_url
ABCresult
0XX0
10X0
1100
1111
298 12 $url = $self->request_url;
299 }
300 15 ▶ if (defined $url) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $url) { } 15 0 15
301 15 _ensure_uri_object($url);
302 15 $url = $url->clone; # don't modify the URL that was passed in
303 15 $url->query(undef); # remove any existing query params, as these may cause the signature to break
304 15 my $params = $self->to_hash;
305 15 my $sep = '?';
306 15 foreach my $k (sort keys %$params) {
307 98 $url .= $sep . encode($k) . '=' . encode( $params->{$k} );
308 98 ▶ $sep = '&' if $sep eq '?';
Branch: 1 branch
BranchTrueFalseTotal
if $sep eq "?" 15 83 98
309 }
310 15 return $url;
311 }
312 else {
313 0 return $self->to_post_body;
314 }
315 }
316  
317 =head1 NAME
318  
319 Net::OAuth::Message - base class for OAuth messages
320  
321 =head1 SEE ALSO
322  
323 L<Net::OAuth>, L<http://oauth.net>
324  
325 =head1 AUTHOR
326  
327 Originally by Keith Grennan <foss@nearlyfree.org>
328  
329 Currently maintained by Robert Rothenberg <perl@rhizomnic.com>
330  
331 =head1 COPYRIGHT & LICENSE
332  
333 Copyright 2007-2012, 2024-2025 Keith Grennan
334  
335 This program is free software; you can redistribute it and/or modify it
336 under the same terms as Perl itself.
337  
338 =cut
339  
340 13 1;
↑ Summary OAuth/Client.pm »