line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: used for testing and as example |
2
|
|
|
|
|
|
|
$Shared::Examples::Net::Amazon::S3::Request::VERSION = '0.991'; |
3
|
|
|
|
|
|
|
use strict; |
4
|
97
|
|
|
97
|
|
2401
|
use warnings; |
|
97
|
|
|
|
|
219
|
|
|
97
|
|
|
|
|
2299
|
|
5
|
97
|
|
|
97
|
|
524
|
|
|
97
|
|
|
|
|
1369
|
|
|
97
|
|
|
|
|
2536
|
|
6
|
|
|
|
|
|
|
use parent qw[ Exporter::Tiny ]; |
7
|
97
|
|
|
96
|
|
501
|
|
|
97
|
|
|
|
|
273
|
|
|
96
|
|
|
|
|
1547
|
|
8
|
|
|
|
|
|
|
use Test::More; |
9
|
96
|
|
|
94
|
|
4334
|
use Test::Deep; |
|
96
|
|
|
|
|
226
|
|
|
96
|
|
|
|
|
598
|
|
10
|
94
|
|
|
90
|
|
19805
|
|
|
94
|
|
|
|
|
7372
|
|
|
94
|
|
|
|
|
463
|
|
11
|
|
|
|
|
|
|
use Moose qw[]; |
12
|
94
|
|
|
90
|
|
18458
|
use Moose::Object; |
|
90
|
|
|
|
|
225
|
|
|
90
|
|
|
|
|
1460
|
|
13
|
90
|
|
|
90
|
|
445
|
use Moose::Util; |
|
90
|
|
|
|
|
199
|
|
|
90
|
|
|
|
|
1843
|
|
14
|
90
|
|
|
90
|
|
433
|
use XML::LibXML; |
|
90
|
|
|
|
|
191
|
|
|
90
|
|
|
|
|
801
|
|
15
|
90
|
|
|
90
|
|
20521
|
|
|
90
|
|
|
|
|
210
|
|
|
90
|
|
|
|
|
978
|
|
16
|
|
|
|
|
|
|
use Net::Amazon::S3; |
17
|
90
|
|
|
90
|
|
12911
|
use Net::Amazon::S3::Bucket; |
|
90
|
|
|
|
|
228
|
|
|
90
|
|
|
|
|
1855
|
|
18
|
90
|
|
|
90
|
|
489
|
|
|
90
|
|
|
|
|
202
|
|
|
90
|
|
|
|
|
1802
|
|
19
|
|
|
|
|
|
|
use Shared::Examples::Net::Amazon::S3; |
20
|
90
|
|
|
90
|
|
850
|
|
|
90
|
|
|
|
|
195
|
|
|
90
|
|
|
|
|
545
|
|
21
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
22
|
|
|
|
|
|
|
qw[ behaves_like_net_amazon_s3_request ], |
23
|
|
|
|
|
|
|
qw[ expect_request_class ], |
24
|
|
|
|
|
|
|
qw[ expect_request_instance ], |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my ($xml) = @_; |
28
|
|
|
|
|
|
|
|
29
|
208
|
|
|
208
|
|
1107
|
return $xml unless $xml; |
30
|
|
|
|
|
|
|
return $xml if ref $xml; |
31
|
208
|
100
|
|
|
|
653
|
|
32
|
78
|
50
|
|
|
|
186
|
my $canonical = eval { |
33
|
|
|
|
|
|
|
XML::LibXML->load_xml ( |
34
|
78
|
|
|
|
|
133
|
string => $xml, |
35
|
78
|
|
|
|
|
409
|
no_blanks => 1, |
36
|
|
|
|
|
|
|
)->toStringC14N |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return $xml unless defined $canonical; |
40
|
|
|
|
|
|
|
return $canonical; |
41
|
78
|
100
|
|
|
|
25665
|
} |
42
|
42
|
|
|
|
|
171
|
|
43
|
|
|
|
|
|
|
my ($self, %params) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return $self->_build_signed_request (%params); |
46
|
206
|
|
|
206
|
|
479
|
} |
47
|
|
|
|
|
|
|
|
48
|
206
|
|
|
|
|
800
|
my ($request_class, %params) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$params{superclasses} ||= []; |
51
|
|
|
|
|
|
|
$params{methods}{_build_http_request} = \& _test_meta_build_http_request; |
52
|
70
|
|
|
70
|
|
196
|
|
53
|
|
|
|
|
|
|
push @{ $params{superclasses} }, $request_class; |
54
|
70
|
|
50
|
|
|
379
|
|
55
|
70
|
|
|
|
|
261
|
return Moose::Meta::Class->create_anon_class (%params); |
56
|
|
|
|
|
|
|
} |
57
|
70
|
|
|
|
|
164
|
|
|
70
|
|
|
|
|
203
|
|
58
|
|
|
|
|
|
|
my ($request_class) = @_; |
59
|
70
|
|
|
|
|
477
|
|
60
|
|
|
|
|
|
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return use_ok $request_class; |
63
|
67
|
|
|
67
|
0
|
606
|
} |
64
|
|
|
|
|
|
|
|
65
|
67
|
|
|
|
|
158
|
my (%params) = @_; |
66
|
|
|
|
|
|
|
|
67
|
67
|
|
|
24
|
|
260
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
|
24
|
|
|
10
|
|
4366
|
|
|
24
|
|
|
9
|
|
52
|
|
|
24
|
|
|
|
|
51
|
|
|
24
|
|
|
|
|
858
|
|
|
10
|
|
|
|
|
1791
|
|
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
114
|
|
|
9
|
|
|
|
|
1673
|
|
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
127
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my %with = map +( substr ($_, 5) => delete $params{$_} ), |
70
|
|
|
|
|
|
|
grep m/^with_/, |
71
|
70
|
|
|
70
|
0
|
2389
|
keys %params |
72
|
|
|
|
|
|
|
; |
73
|
70
|
|
|
|
|
192
|
|
74
|
|
|
|
|
|
|
$with{s3} = Shared::Examples::Net::Amazon::S3::s3_api_with_signature_2 ( |
75
|
70
|
|
|
|
|
823
|
host => $params{with_host} || 's3.amazonaws.com', |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $test_class = _test_class $params{request_class}, |
79
|
|
|
|
|
|
|
map +( $_ => $params{$_} ), |
80
|
|
|
|
|
|
|
grep exists $params{$_}, |
81
|
70
|
|
50
|
|
|
654
|
qw [ roles ], |
82
|
|
|
|
|
|
|
; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $request = eval { $test_class->name->new (%with) }; |
85
|
|
|
|
|
|
|
my $error = $@; |
86
|
70
|
|
|
|
|
374
|
|
87
|
|
|
|
|
|
|
if (exists $params{throws}) { |
88
|
|
|
|
|
|
|
if (defined $request) { |
89
|
|
|
|
|
|
|
fail "create instance should fail"; |
90
|
70
|
|
|
|
|
407900
|
} else { |
|
70
|
|
|
|
|
3032
|
|
91
|
70
|
|
|
|
|
96449
|
cmp_deeply $error, $params{throws}, "create instance should fail"; |
92
|
|
|
|
|
|
|
} |
93
|
70
|
100
|
|
|
|
415
|
} else { |
94
|
6
|
50
|
|
|
|
28
|
ok defined $request, "should create (mocked) instance of $params{request_class}" |
95
|
0
|
|
|
|
|
0
|
or diag $error; |
96
|
|
|
|
|
|
|
} |
97
|
6
|
|
|
|
|
40
|
|
98
|
|
|
|
|
|
|
return $request; |
99
|
|
|
|
|
|
|
} |
100
|
64
|
50
|
|
|
|
450
|
|
101
|
|
|
|
|
|
|
my ($request, $expected) = @_; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
104
|
70
|
|
|
|
|
37238
|
|
105
|
|
|
|
|
|
|
return cmp_deeply |
106
|
|
|
|
|
|
|
$request->http_request->request_uri, |
107
|
|
|
|
|
|
|
$expected, |
108
|
54
|
|
|
54
|
0
|
148
|
"it builds expected request uri" |
109
|
|
|
|
|
|
|
; |
110
|
54
|
|
|
|
|
130
|
} |
111
|
|
|
|
|
|
|
|
112
|
54
|
|
|
|
|
488
|
my ($request, $expected) = @_; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
return cmp_deeply |
117
|
|
|
|
|
|
|
$request->http_request->method, |
118
|
|
|
|
|
|
|
$expected, |
119
|
|
|
|
|
|
|
"it builds expected request method" |
120
|
58
|
|
|
58
|
0
|
155
|
; |
121
|
|
|
|
|
|
|
} |
122
|
58
|
|
|
|
|
153
|
|
123
|
|
|
|
|
|
|
my ($request, $expected) = @_; |
124
|
58
|
|
|
|
|
233
|
|
125
|
|
|
|
|
|
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
return cmp_deeply |
128
|
|
|
|
|
|
|
$request->http_request->headers, |
129
|
|
|
|
|
|
|
$expected, |
130
|
|
|
|
|
|
|
"it builds expected request headers" |
131
|
|
|
|
|
|
|
; |
132
|
54
|
|
|
54
|
0
|
146
|
} |
133
|
|
|
|
|
|
|
|
134
|
54
|
|
|
|
|
135
|
my ($request, $expected) = @_; |
135
|
|
|
|
|
|
|
|
136
|
54
|
|
|
|
|
198
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# XML builders doesn't need to produce whitespaces for readability |
139
|
|
|
|
|
|
|
# wherease test expectation should be as readable as possible |
140
|
|
|
|
|
|
|
# compare canonicalized xml strings than |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
return is |
143
|
|
|
|
|
|
|
_canonical_xml ($request->http_request->content), |
144
|
40
|
|
|
40
|
0
|
129
|
_canonical_xml ($expected), |
145
|
|
|
|
|
|
|
"it builds expected request XML content" |
146
|
40
|
|
|
|
|
113
|
; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
my ($title, %params) = @_; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
152
|
40
|
|
|
|
|
158
|
|
153
|
|
|
|
|
|
|
subtest $title => sub { |
154
|
|
|
|
|
|
|
plan tests => 2 + scalar grep exists $params{$_}, |
155
|
|
|
|
|
|
|
qw[ expect_request_uri ], |
156
|
|
|
|
|
|
|
qw[ expect_request_method ], |
157
|
|
|
|
|
|
|
qw[ expect_request_headers ], |
158
|
|
|
|
|
|
|
qw[ expect_request_content ], |
159
|
|
|
|
|
|
|
; |
160
|
64
|
|
|
64
|
0
|
83473
|
|
161
|
|
|
|
|
|
|
expect_request_class $params{request_class}; |
162
|
64
|
|
|
|
|
176
|
my $request = expect_request_instance %params; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
expect_request_uri $request => $params{expect_request_uri} |
165
|
64
|
|
|
64
|
|
65153
|
if exists $params{expect_request_uri}; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
expect_request_method $request => $params{expect_request_method} |
168
|
|
|
|
|
|
|
if exists $params{expect_request_method}; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
expect_request_headers $request => $params{expect_request_headers} |
171
|
|
|
|
|
|
|
if exists $params{expect_request_headers}; |
172
|
64
|
|
|
|
|
45499
|
|
173
|
64
|
|
|
|
|
26888
|
expect_request_content $request => $params{expect_request_content} |
174
|
|
|
|
|
|
|
if exists $params{expect_request_content}; |
175
|
|
|
|
|
|
|
}; |
176
|
64
|
100
|
|
|
|
1399
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |
179
|
64
|
100
|
|
|
|
28765
|
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=pod |
182
|
64
|
100
|
|
|
|
28468
|
|
183
|
|
|
|
|
|
|
=encoding UTF-8 |
184
|
|
|
|
|
|
|
|
185
|
64
|
100
|
|
|
|
223965
|
=head1 NAME |
186
|
64
|
|
|
|
|
447
|
|
187
|
|
|
|
|
|
|
Shared::Examples::Net::Amazon::S3::Request - used for testing and as example |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 VERSION |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
version 0.991 |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 AUTHOR |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Branislav Zahradník <barney@cpan.org> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
202
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |