line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Shared::Examples::Net::Amazon::S3::API; |
2
|
|
|
|
|
|
|
# ABSTRACT: used for testing and as example |
3
|
|
|
|
|
|
|
$Shared::Examples::Net::Amazon::S3::API::VERSION = '0.99'; |
4
|
90
|
|
|
90
|
|
125335
|
use strict; |
|
90
|
|
|
|
|
307
|
|
|
90
|
|
|
|
|
3216
|
|
5
|
90
|
|
|
90
|
|
542
|
use warnings; |
|
90
|
|
|
|
|
255
|
|
|
90
|
|
|
|
|
3254
|
|
6
|
|
|
|
|
|
|
|
7
|
90
|
|
|
90
|
|
551
|
use parent qw[ Exporter::Tiny ]; |
|
90
|
|
|
|
|
240
|
|
|
90
|
|
|
|
|
824
|
|
8
|
|
|
|
|
|
|
|
9
|
90
|
|
|
90
|
|
10967
|
use Hash::Util; |
|
90
|
|
|
|
|
3457
|
|
|
90
|
|
|
|
|
882
|
|
10
|
90
|
|
|
90
|
|
4624
|
use Test::Deep; |
|
90
|
|
|
|
|
246
|
|
|
90
|
|
|
|
|
818
|
|
11
|
90
|
|
|
90
|
|
30318
|
use Test::More; |
|
90
|
|
|
|
|
275
|
|
|
90
|
|
|
|
|
1149
|
|
12
|
|
|
|
|
|
|
|
13
|
90
|
|
|
90
|
|
30510
|
use Net::Amazon::S3; |
|
90
|
|
|
|
|
325
|
|
|
90
|
|
|
|
|
3072
|
|
14
|
90
|
|
|
90
|
|
1505
|
use Shared::Examples::Net::Amazon::S3; |
|
90
|
|
|
|
|
236
|
|
|
90
|
|
|
|
|
1144
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
17
|
|
|
|
|
|
|
qw[ expect_signed_uri ], |
18
|
|
|
|
|
|
|
qw[ expect_api_list_all_my_buckets ], |
19
|
|
|
|
|
|
|
qw[ expect_api_bucket_acl_get ], |
20
|
|
|
|
|
|
|
qw[ expect_api_bucket_acl_set ], |
21
|
|
|
|
|
|
|
qw[ expect_api_bucket_create ], |
22
|
|
|
|
|
|
|
qw[ expect_api_bucket_delete ], |
23
|
|
|
|
|
|
|
qw[ expect_api_bucket_objects_delete ], |
24
|
|
|
|
|
|
|
qw[ expect_api_bucket_objects_list ], |
25
|
|
|
|
|
|
|
qw[ expect_api_bucket_tags_add ], |
26
|
|
|
|
|
|
|
qw[ expect_api_bucket_tags_delete ], |
27
|
|
|
|
|
|
|
qw[ expect_api_object_acl_get ], |
28
|
|
|
|
|
|
|
qw[ expect_api_object_acl_set ], |
29
|
|
|
|
|
|
|
qw[ expect_api_object_create ], |
30
|
|
|
|
|
|
|
qw[ expect_api_object_delete ], |
31
|
|
|
|
|
|
|
qw[ expect_api_object_fetch ], |
32
|
|
|
|
|
|
|
qw[ expect_api_object_head ], |
33
|
|
|
|
|
|
|
qw[ expect_api_object_tags_add ], |
34
|
|
|
|
|
|
|
qw[ expect_api_object_tags_delete ], |
35
|
|
|
|
|
|
|
qw[ with_fixture ], |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
*with_fixture = *Shared::Examples::Net::Amazon::S3::with_fixture; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _exporter_expand_sub { |
41
|
20
|
|
|
20
|
|
22557
|
my ($self, $name, $args, $globals) = @_; |
42
|
|
|
|
|
|
|
|
43
|
20
|
|
|
|
|
71
|
my $s3_operation = $name; |
44
|
20
|
|
|
|
|
114
|
$s3_operation =~ s/_api_/_operation_/; |
45
|
|
|
|
|
|
|
|
46
|
20
|
|
|
107
|
|
1939
|
return +( $name => eval <<"GEN_SUB" ); |
|
107
|
|
|
|
|
81539
|
|
|
107
|
|
|
|
|
2759
|
|
47
|
|
|
|
|
|
|
sub { |
48
|
|
|
|
|
|
|
push \@_, -shared_examples => __PACKAGE__; |
49
|
|
|
|
|
|
|
goto \\& Shared::Examples::Net::Amazon::S3::$s3_operation; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
GEN_SUB |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _default_with_api { |
55
|
187
|
|
|
187
|
|
134557
|
my ($self, $params) = @_; |
56
|
|
|
|
|
|
|
|
57
|
187
|
|
66
|
|
|
1294
|
$params->{with_s3} ||= Shared::Examples::Net::Amazon::S3::s3_api_with_signature_2 (); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _mock_http_response { |
61
|
107
|
|
|
107
|
|
845
|
my (undef, $api, %params) = @_; |
62
|
|
|
|
|
|
|
|
63
|
107
|
|
|
|
|
1080
|
Shared::Examples::Net::Amazon::S3->s3_api_mock_http_response ( |
64
|
|
|
|
|
|
|
$api, |
65
|
|
|
|
|
|
|
%params, |
66
|
|
|
|
|
|
|
) |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub expect_signed_uri { |
70
|
4
|
|
|
4
|
0
|
21
|
my ($title, %params) = @_; |
71
|
|
|
|
|
|
|
|
72
|
4
|
|
|
|
|
11
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
73
|
|
|
|
|
|
|
|
74
|
4
|
|
|
|
|
24
|
Hash::Util::lock_keys %params, |
75
|
|
|
|
|
|
|
qw[ with_s3 ], |
76
|
|
|
|
|
|
|
qw[ with_bucket ], |
77
|
|
|
|
|
|
|
qw[ with_region ], |
78
|
|
|
|
|
|
|
qw[ with_key ], |
79
|
|
|
|
|
|
|
qw[ with_expire_at ], |
80
|
|
|
|
|
|
|
qw[ with_method ], |
81
|
|
|
|
|
|
|
qw[ expect_uri ], |
82
|
|
|
|
|
|
|
; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $got = Net::Amazon::S3::Bucket |
85
|
|
|
|
|
|
|
->new ({ |
86
|
|
|
|
|
|
|
account => $params{with_s3}, |
87
|
|
|
|
|
|
|
bucket => $params{with_bucket}, |
88
|
|
|
|
|
|
|
region => $params{with_region}, |
89
|
|
|
|
|
|
|
}) |
90
|
|
|
|
|
|
|
->query_string_authentication_uri ( |
91
|
|
|
|
|
|
|
$params{with_key}, |
92
|
|
|
|
|
|
|
$params{with_expire_at}, |
93
|
|
|
|
|
|
|
(method => $params{with_method}) x!! exists $params{with_method}, |
94
|
4
|
|
|
|
|
493
|
); |
95
|
|
|
|
|
|
|
|
96
|
4
|
|
|
|
|
149
|
cmp_deeply $got, $params{expect_uri}, $title; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub operation_list_all_my_buckets { |
100
|
4
|
|
|
4
|
0
|
26
|
my ($self, %params) = @_; |
101
|
|
|
|
|
|
|
|
102
|
4
|
|
|
|
|
30
|
$self->buckets; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub operation_bucket_acl_get { |
106
|
4
|
|
|
4
|
0
|
40
|
my ($self, %params) = @_; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$self |
109
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
110
|
4
|
|
|
|
|
45
|
->get_acl |
111
|
|
|
|
|
|
|
; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub operation_bucket_acl_set { |
115
|
9
|
|
|
9
|
0
|
52
|
my ($self, %params) = @_; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
$self |
118
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
119
|
|
|
|
|
|
|
->set_acl ({ |
120
|
|
|
|
|
|
|
(acl => $params{with_acl}) x!! exists $params{with_acl}, |
121
|
|
|
|
|
|
|
(acl_short => $params{with_acl_short}) x!! exists $params{with_acl_short}, |
122
|
|
|
|
|
|
|
(acl_xml => $params{with_acl_xml}) x!! exists $params{with_acl_xml}, |
123
|
|
|
|
|
|
|
}) |
124
|
9
|
|
|
|
|
46
|
; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub operation_bucket_create { |
128
|
15
|
|
|
15
|
0
|
91
|
my ($self, %params) = @_; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$self |
131
|
|
|
|
|
|
|
->add_bucket ({ |
132
|
|
|
|
|
|
|
bucket => $params{with_bucket}, |
133
|
|
|
|
|
|
|
(acl => $params{with_acl}) x!! exists $params{with_acl}, |
134
|
|
|
|
|
|
|
(acl_short => $params{with_acl_short}) x!! exists $params{with_acl_short}, |
135
|
|
|
|
|
|
|
(location_constraint => $params{with_region}) x!! exists $params{with_region}, |
136
|
|
|
|
|
|
|
(region => $params{with_region}) x!! exists $params{with_region}, |
137
|
|
|
|
|
|
|
}) |
138
|
15
|
|
|
|
|
158
|
; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub operation_bucket_delete { |
142
|
5
|
|
|
5
|
0
|
39
|
my ($self, %params) = @_; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
$self |
145
|
|
|
|
|
|
|
->delete_bucket ({ |
146
|
|
|
|
|
|
|
bucket => $params{with_bucket}, |
147
|
|
|
|
|
|
|
}) |
148
|
5
|
|
|
|
|
50
|
; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub operation_bucket_objects_list { |
152
|
8
|
|
|
8
|
0
|
81
|
my ($self, %params) = @_; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
$self |
155
|
|
|
|
|
|
|
->list_bucket ({ |
156
|
|
|
|
|
|
|
bucket => $params{with_bucket}, |
157
|
|
|
|
|
|
|
delimiter => $params{with_delimiter}, |
158
|
|
|
|
|
|
|
max_keys => $params{with_max_keys}, |
159
|
|
|
|
|
|
|
marker => $params{with_marker}, |
160
|
|
|
|
|
|
|
prefix => $params{with_prefix}, |
161
|
|
|
|
|
|
|
}) |
162
|
8
|
|
|
|
|
96
|
; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub operation_bucket_objects_delete { |
166
|
4
|
|
|
4
|
0
|
33
|
my ($self, %params) = @_; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$self |
169
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
170
|
4
|
|
|
|
|
32
|
->delete_multi_object (@{ $params{with_keys} }) |
|
4
|
|
|
|
|
27
|
|
171
|
|
|
|
|
|
|
; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub operation_object_acl_get { |
175
|
5
|
|
|
5
|
0
|
30
|
my ($self, %params) = @_; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
$self |
178
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
179
|
|
|
|
|
|
|
->get_acl ($params{with_key}) |
180
|
5
|
|
|
|
|
31
|
; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub operation_object_acl_set { |
184
|
9
|
|
|
9
|
0
|
53
|
my ($self, %params) = @_; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
$self |
187
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
188
|
|
|
|
|
|
|
->set_acl ({ |
189
|
|
|
|
|
|
|
key => $params{with_key}, |
190
|
|
|
|
|
|
|
(acl => $params{with_acl}) x!! exists $params{with_acl}, |
191
|
|
|
|
|
|
|
(acl_short => $params{with_acl_short}) x!! exists $params{with_acl_short}, |
192
|
|
|
|
|
|
|
(acl_xml => $params{with_acl_xml}) x!! exists $params{with_acl_xml}, |
193
|
|
|
|
|
|
|
}) |
194
|
9
|
|
|
|
|
54
|
; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub operation_object_create { |
198
|
10
|
|
|
10
|
0
|
90
|
my ($self, %params) = @_; |
199
|
|
|
|
|
|
|
|
200
|
10
|
50
|
|
|
|
35
|
my $headers = { %{ $params{with_headers} || {} } }; |
|
10
|
|
|
|
|
89
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
$headers->{$_} = $params{"with_$_"} |
203
|
10
|
|
|
|
|
132
|
for grep exists $params{"with_$_"}, |
204
|
|
|
|
|
|
|
qw[ cache_control ], |
205
|
|
|
|
|
|
|
qw[ content_disposition ], |
206
|
|
|
|
|
|
|
qw[ content_encoding ], |
207
|
|
|
|
|
|
|
qw[ content_type ], |
208
|
|
|
|
|
|
|
qw[ encryption ], |
209
|
|
|
|
|
|
|
qw[ expires ], |
210
|
|
|
|
|
|
|
qw[ acl_short ], |
211
|
|
|
|
|
|
|
qw[ acl ], |
212
|
|
|
|
|
|
|
; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
$headers->{x_amz_storage_class} = $params{with_storage_class} |
215
|
10
|
100
|
|
|
|
53
|
if $params{with_storage_class}; |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
$headers->{"x_amz_meta_\L$_"} = $params{with_user_metadata}{$_} |
218
|
10
|
100
|
|
|
|
29
|
for keys %{ $params{with_user_metadata} || {} }; |
|
10
|
|
|
|
|
80
|
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
$self |
221
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
222
|
|
|
|
|
|
|
->add_key ( |
223
|
|
|
|
|
|
|
$params{with_key}, |
224
|
|
|
|
|
|
|
$params{with_value}, |
225
|
10
|
|
|
|
|
95
|
$headers, |
226
|
|
|
|
|
|
|
) |
227
|
|
|
|
|
|
|
; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub operation_object_delete { |
231
|
5
|
|
|
5
|
0
|
44
|
my ($self, %params) = @_; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
$self |
234
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
235
|
|
|
|
|
|
|
->delete_key ($params{with_key}) |
236
|
5
|
|
|
|
|
38
|
; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub operation_object_fetch { |
240
|
7
|
|
|
7
|
0
|
46
|
my ($self, %params) = @_; |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
$self |
243
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
244
|
|
|
|
|
|
|
->get_key ( |
245
|
|
|
|
|
|
|
$params{with_key}, |
246
|
|
|
|
|
|
|
'GET', |
247
|
|
|
|
|
|
|
({ range => $params{with_range} }) x exists $params{with_range}, |
248
|
|
|
|
|
|
|
) |
249
|
7
|
|
|
|
|
42
|
; |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
sub operation_object_head { |
253
|
5
|
|
|
5
|
0
|
35
|
my ($self, %params) = @_; |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
$self |
256
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
257
|
|
|
|
|
|
|
->head_key ($params{with_key}) |
258
|
5
|
|
|
|
|
34
|
; |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
sub operation_bucket_tags_add { |
262
|
4
|
|
|
4
|
0
|
26
|
my ($self, %params) = @_; |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
$self |
265
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
266
|
|
|
|
|
|
|
->add_tags ({ |
267
|
|
|
|
|
|
|
tags => $params{with_tags}, |
268
|
|
|
|
|
|
|
}) |
269
|
4
|
|
|
|
|
27
|
; |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
sub operation_object_tags_add { |
273
|
4
|
|
|
4
|
0
|
23
|
my ($self, %params) = @_; |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
$self |
276
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
277
|
|
|
|
|
|
|
->add_tags ({ |
278
|
|
|
|
|
|
|
key => $params{with_key}, |
279
|
|
|
|
|
|
|
tags => $params{with_tags}, |
280
|
|
|
|
|
|
|
(version_id => $params{with_version_id}) x!! defined $params{with_version_id}, |
281
|
|
|
|
|
|
|
}) |
282
|
4
|
|
|
|
|
32
|
; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
sub operation_bucket_tags_delete { |
286
|
4
|
|
|
4
|
0
|
31
|
my ($self, %params) = @_; |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
$self |
289
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
290
|
4
|
|
|
|
|
28
|
->delete_tags |
291
|
|
|
|
|
|
|
; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
sub operation_object_tags_delete { |
295
|
5
|
|
|
5
|
0
|
33
|
my ($self, %params) = @_; |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
$self |
298
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
299
|
|
|
|
|
|
|
->delete_tags ({ |
300
|
|
|
|
|
|
|
key => $params{with_key}, |
301
|
|
|
|
|
|
|
(version_id => $params{with_version_id}) x!! defined $params{with_version_id}, |
302
|
|
|
|
|
|
|
}) |
303
|
5
|
|
|
|
|
33
|
; |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
1; |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
__END__ |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=pod |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=encoding UTF-8 |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=head1 NAME |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
Shared::Examples::Net::Amazon::S3::API - used for testing and as example |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=head1 VERSION |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
version 0.99 |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=head1 AUTHOR |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
Branislav Zahradník <barney@cpan.org> |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
331
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=cut |