Signature.pm

filter: Statementstmt 94.7% 18 / 19 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 83.8% 26 / 31 CC 4 SCAR 10.7
CC
4
Cov
84%
new
4.4
BEGIN
1.0
BEGIN
1.0
CRAP 2.9
« Signature/v4.pm ↑ Summary
1 package WebService::Amazon::Signature;
2 # ABSTRACT: support for various ways to sign AWS requests
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = '0.001';
7  
8 =head1 NAME
9  
10 WebService::Amazon::Signature - handle signatures for Amazon webservices
11  
12 =head1 VERSION
13  
14 version 0.001
15  
16 =head1 SYNOPSIS
17  
18 my $req = 'GET / HTTP/1.1 ...';
19 my $amz = WebService::Amazon::Signature->new(
20 version => 4,
21 algorithm => 'AWS4-HMAC-SHA256',
22 scope => '20110909/us-east-1/host/aws4_request',
23 access_key => 'AKIDEXAMPLE',
24 secret_key => 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY',
25 host_port => 'localhost:8000',
26 );
27 $amz->parse_request($req)
28 my $signed_req = $amz->signed_request($req);
29  
30 =head1 DESCRIPTION
31  
32 Provides methods for signing requests and verifying responses for Amazon webservices,
33 as described in L<http://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html>.
34  
35 =cut
36  
37 3 ▶use WebService::Amazon::Signature::v4;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 =head1 METHODS
40  
41 =head2 new
42  
43 Instantiate a signing object.
44  
45 Will extract the C<version> named parameter, if it exists, and use that
46 to select the appropriate subclass for instantiation. Other parameters
47 are as defined by the subclass.
48  
49 =over 4
50  
51 =item * L<WebService::Amazon::Signature::v2/new>
52  
53 =item * L<WebService::Amazon::Signature::v4/new>
54  
55 =back
56  
57 =cut
58  
59 sub new {
60 1 ▶ my $class = shift;
Subroutine new: called CC=4 SCAR=14.8
Pod documented
61 1 my %args = @_;
62 1 ▶ my $version = delete $args{version} || 4;
Condition50%1/2
delete $args{'version'} || 4
l!l
10
MC/DC0%0/1
delete $args{'version'} || 4
delete $args{'version'}
Truth table50%1/2
A
A= delete $args{'version'}
Aresult
11
00
63 1 my $pkg = 'WebService::Amazon::Signature::v' . $version;
64 1 ▶ if(my $code = $pkg->can('new')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $pkg->can("new")) 1 0 1
65 1 ▶ $class = $pkg if $class eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $class eq __PACKAGE__ 1 0 1
66 1 return $code->($class, %args)
67 }
68 0 die "No support for version $version";
69 }
70  
71 3 1;
72  
73 __END__
« Signature/v4.pm ↑ Summary