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
« OAuth/Client.pm ↑ Summary OAuth/SignatureMethod/RSA_SHA1.pm »
1 package Net::OAuth::Message;
2 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use base qw/Class::Data::Inheritable Class::Accessor/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use Net::OAuth;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use URI::QueryParam;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 12 ▶use constant OAUTH_PREFIX => 'oauth_';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 12 our $OAUTH_PREFIX_RE = do {my $p = OAUTH_PREFIX; qr/^$p/};
14  
15 12 __PACKAGE__->mk_classdata(extension_param_patterns => []);
16  
17 sub add_required_message_params {
18 17 ▶ my $class = shift;
Subroutine add_required_message_params: called CC=1 SCAR=0.0
Pod undocumented
19 17 $class->required_message_params([@{$class->required_message_params}, @_]);
20 17 $class->all_message_params([@{$class->all_message_params}, @_]);
21 17 $class->all_params([@{$class->all_params}, @_]);
22 17 $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 9 ▶ my $class = shift;
Subroutine add_required_api_params: called CC=1 SCAR=0.0
Pod undocumented
35 9 $class->required_api_params([@{$class->required_api_params}, @_]);
36 9 $class->all_api_params([@{$class->all_api_params}, @_]);
37 9 $class->all_params([@{$class->all_params}, @_]);
38 9 $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 37 ▶ my $proto = shift;
Subroutine new: called CC=2 SCAR=7.1
Pod documented
53 37 ▶ my $class = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
0370
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 37 my %params = @_;
55 37 $class = get_versioned_class($class, \%params);
56 37 my $self = bless \%params, $class;
57 37 $self->set_defaults;
58 37 $self->check;
59 34 return $self;
60 }
61  
62 sub get_versioned_class {
63 46 ▶ my $class = shift;
Subroutine get_versioned_class: called CC=6 SCAR=18.0
Pod undocumented
64 46 my $params = shift;
65 46 ▶ 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
3430
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 46 ▶ 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\::/) 9 37 46
Condition83%5/6
defined $protocol_version and $protocol_version == "1.001" and not $class =~ /\::V1_0A\::/
!ll&&!rl&&r
3349
defined $protocol_version and $protocol_version == "1.001"
!ll&&!rl&&r
03313
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 9 (my $versioned_class = $class) =~ s/::(\w+)$/::V1_0A::$1/;
68 9 ▶ return $versioned_class if Net::OAuth::smart_require($versioned_class);
Branch: 1 branch
BranchTrueFalseTotal
if Net::OAuth::smart_require($versioned_class) 7 2 9
69 }
70 39 return $class;
71 }
72  
73 sub set_defaults {
74 37 ▶ my $self = shift;
Subroutine set_defaults: called CC=4 SCAR=13.9
Pod undocumented
75 37 ▶ $self->{extra_params} ||= {};
Condition100%2/2
$self->{"extra_params"} ||= {}
l!l
1621
MC/DC100%1/1
$self->{"extra_params"} ||= {}
$self->{"extra_params"}
Truth table100%2/2
A
A= $self->{"extra_params"}
Aresult
11
00
76 37 ▶ $self->{version} ||= Net::OAuth::OAUTH_VERSION unless $self->{from_hash};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"from_hash"} 29 8 37
Condition50%1/2
$self->{"version"} ||= "1.0"
l!l
029
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 346 ▶ my $self = shift;
Subroutine is_extension_param: called CC=1 SCAR=0.0
Pod undocumented
81 346 my $param = shift;
82 346 return grep ($param =~ $_, @{$self->extension_param_patterns});
83 }
84  
85 sub check {
86 37 ▶ my $self = shift;
Subroutine check: called CC=7 SCAR=19.7
Pod undocumented
87 37 foreach my $k (@{$self->required_message_params}, @{$self->required_api_params}) {
88 221 ▶ if (not defined $self->{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{$k}) 3 218 221
89 3 croak "Missing required parameter '$k'";
90 }
91 }
92 34 ▶ if ($self->{extra_params} and $self->allow_extra_params) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"extra_params"} and $self->allow_extra_params) 30 4 34
Condition66%2/3
$self->{"extra_params"} and $self->allow_extra_params
!ll&&!rl&&r
0430
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 30 foreach my $k (keys %{$self->{extra_params}}) {
94 22 ▶ if ($k =~ $OAUTH_PREFIX_RE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /$Net::OAuth::Message::OAUTH_PREFIX_RE/) 0 22 22
95 0 croak "Parameter '$k' not allowed in arbitrary params"
96 }
97 }
98 }
99 }
100  
101 sub encode {
102 933 ▶ my $str = shift;
Subroutine encode: called CC=5 SCAR=16.1
Pod undocumented
103 933 ▶ $str = "" unless defined $str;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 14 919 933
104 933 ▶ unless($Net::OAuth::SKIP_UTF8_DOUBLE_ENCODE_CHECK) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Net::OAuth::SKIP_UTF8_DOUBLE_ENCODE_CHECK) 933 0 933
105 933 ▶ if ($str =~ /[\x80-\xFF]/ and !utf8::is_utf8($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /[\x80-\xFF]/ and not utf8::is_utf8($str)) 1 932 933
Condition100%3/3
$str =~ /[\x80-\xFF]/ and not utf8::is_utf8($str)
!ll&&!rl&&r
93021
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 933 return URI::Escape::uri_escape_utf8($str);
110 }
111  
112 sub decode {
113 32 ▶ my $str = shift;
Subroutine decode: called CC=1 SCAR=0.0
Pod undocumented
114 32 return uri_unescape($str);
115 }
116  
117 34 ▶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 60 ▶ my $self = shift;
Subroutine gather_message_parameters: called CC=17 SCAR=28.3
Pod undocumented
123 60 my %opts = @_;
124 60 ▶ $opts{quote} = "" unless defined $opts{quote};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{"quote"} 56 4 60
125 60 ▶ $opts{params} ||= [];
Condition50%1/2
$opts{"params"} ||= []
l!l
060
MC/DC0%0/1
$opts{"params"} ||= []
$opts{"params"}
Truth table50%1/2
A
A= $opts{"params"}
Aresult
11
00
126 60 my %params;
127 60 foreach my $k (@{$self->required_message_params}, @{$self->optional_message_params}, @{$opts{add}}) {
128 386 ▶ 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"};}) 42 344 386
Condition100%6/6
$k eq "signature" and not $self->sign_message && grep(($_ eq "signature"), @{$opts{"add"};})
!ll&&!rl&&r
3083642
$self->sign_message && grep(($_ eq 'signature'), @{$opts{'add'};})
!ll&&!rl&&r
103236
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 344 ▶ my $message_key = $self->is_extension_param($k) ? $k : OAUTH_PREFIX . $k;
Branch: 1 branch
BranchTrueFalseTotal
$self->is_extension_param($k) ? : 3 341 344
130 344 my $v = $self->$k;
131 344 ▶ $params{$message_key} = $v if defined $v;
Branch: 1 branch
BranchTrueFalseTotal
if defined $v 343 1 344
132 }
133 60 ▶ 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) 50 10 60
Condition83%5/6
$self->{"extra_params"} and not $opts{"no_extra"} and $self->allow_extra_params
!ll&&!rl&&r
4650
$self->{"extra_params"} and not $opts{"no_extra"}
!ll&&!rl&&r
0456
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 50 foreach my $k (keys %{$self->{extra_params}}) {
135 39 $params{$k} = $self->{extra_params}{$k};
136 }
137 50 ▶ if ($self->can('request_url')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can("request_url")) 40 10 50
138 40 my $url = $self->request_url;
139 40 _ensure_uri_object($url);
140 40 foreach my $k ($url->query_param) {
141 12 $params{$k} = $url->query_param($k);
142 }
143 }
144 }
145 60 ▶ if ($opts{hash}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"hash"}) 8 52 60
146 8 return \%params;
147 }
148 52 my @pairs;
149 52 ▶ while (my ($k,$v) = each %params) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %params) 327 52 379
150 327 push @pairs, join('=', encode($k), $opts{quote} . encode($v) . $opts{quote});
151 }
152 52 return sort(@pairs);
153 }
154  
155 sub normalized_message_parameters {
156 32 ▶ my $self = shift;
Subroutine normalized_message_parameters: called CC=1 SCAR=0.0
Pod undocumented
157 32 return join('&', $self->gather_message_parameters);
158 }
159  
160 sub signature_base_string {
161 32 ▶ my $self = shift;
Subroutine signature_base_string: called CC=1 SCAR=0.0
Pod undocumented
162 32 return join('&', map(encode($self->$_), @{$self->signature_elements}));
163 }
164  
165 sub sign {
166 17 ▶ my $self = shift;
Subroutine sign: called CC=1 SCAR=0.0
Pod undocumented
167 17 my $class = $self->_signature_method_class;
168 17 $self->signature($class->sign($self, @_));
169 }
170  
171 sub verify {
172 19 ▶ my $self = shift;
Subroutine verify: called CC=1 SCAR=0.0
Pod undocumented
173 19 my $class = $self->_signature_method_class;
174 19 return $class->verify($self, @_);
175 }
176  
177 sub _signature_method_class {
178 36 ▶ my $self = shift;
Subroutine _signature_method_class: called CC=2 SCAR=7.0
179 36 (my $signature_method = $self->signature_method) =~ s/\W+/_/g;
180 36 my $sm_class = 'Net::OAuth::SignatureMethod::' . $signature_method;
181 36 ▶ 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 36 36
182 36 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 48 ▶ if ($k =~ s/$OAUTH_PREFIX_RE//) {
Branch: 2 branches
BranchTrueFalseTotal
if ($k =~ s/$Net::OAuth::Message::OAUTH_PREFIX_RE//) { } 46 2 48
elsif ($class->is_extension_param($k)) { } 0 2 2
242 46 ▶ if (!grep ($_ eq $k, @{$class->all_message_params})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not grep(($_ eq $k), @{$class->all_message_params;})) { } 1 45 46
243 1 croak "Parameter ". OAUTH_PREFIX ."$k not valid for a message of type $class";
244 }
245 else {
246 45 $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 82 ▶ $_[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') ? : 1 81 82
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 8 ▶ my $self = shift;
Subroutine to_hash: called CC=1 SCAR=0.0
Pod undocumented
291 8 return $self->gather_message_parameters(hash => 1, add => [qw/signature/]);
292 }
293  
294 sub to_url {
295 8 ▶ my $self = shift;
Subroutine to_url: called CC=7 SCAR=19.7
Pod undocumented
296 8 my $url = shift;
297 8 ▶ 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) 5 3 8
Condition66%4/6
not defined $url and $self->can("request_url") and defined $self->request_url
!ll&&!rl&&r
305
not defined $url and $self->can("request_url")
!ll&&!rl&&r
305
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 5 $url = $self->request_url;
299 }
300 8 ▶ if (defined $url) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $url) { } 8 0 8
301 8 _ensure_uri_object($url);
302 8 $url = $url->clone; # don't modify the URL that was passed in
303 8 $url->query(undef); # remove any existing query params, as these may cause the signature to break
304 8 my $params = $self->to_hash;
305 8 my $sep = '?';
306 8 foreach my $k (sort keys %$params) {
307 49 $url .= $sep . encode($k) . '=' . encode( $params->{$k} );
308 49 ▶ $sep = '&' if $sep eq '?';
Branch: 1 branch
BranchTrueFalseTotal
if $sep eq "?" 8 41 49
309 }
310 8 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 <kgrennan@cpan.org>
328  
329 Currently maintained by Robert Rothenberg <rrwo@cpan.org>
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 12 1;
« OAuth/Client.pm ↑ Summary OAuth/SignatureMethod/RSA_SHA1.pm »