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.98'; |
4
|
89
|
|
|
89
|
|
119057
|
use strict; |
|
89
|
|
|
|
|
339
|
|
|
89
|
|
|
|
|
3638
|
|
5
|
89
|
|
|
89
|
|
578
|
use warnings; |
|
89
|
|
|
|
|
235
|
|
|
89
|
|
|
|
|
3767
|
|
6
|
|
|
|
|
|
|
|
7
|
89
|
|
|
89
|
|
547
|
use parent qw[ Exporter::Tiny ]; |
|
89
|
|
|
|
|
229
|
|
|
89
|
|
|
|
|
968
|
|
8
|
|
|
|
|
|
|
|
9
|
89
|
|
|
89
|
|
11189
|
use Hash::Util; |
|
89
|
|
|
|
|
3253
|
|
|
89
|
|
|
|
|
902
|
|
10
|
89
|
|
|
89
|
|
5333
|
use Test::Deep; |
|
89
|
|
|
|
|
248
|
|
|
89
|
|
|
|
|
988
|
|
11
|
89
|
|
|
89
|
|
30167
|
use Test::More; |
|
89
|
|
|
|
|
245
|
|
|
89
|
|
|
|
|
1338
|
|
12
|
|
|
|
|
|
|
|
13
|
89
|
|
|
89
|
|
33636
|
use Net::Amazon::S3; |
|
89
|
|
|
|
|
276
|
|
|
89
|
|
|
|
|
2672
|
|
14
|
89
|
|
|
89
|
|
1252
|
use Shared::Examples::Net::Amazon::S3; |
|
89
|
|
|
|
|
263
|
|
|
89
|
|
|
|
|
1332
|
|
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
|
|
22431
|
my ($self, $name, $args, $globals) = @_; |
42
|
|
|
|
|
|
|
|
43
|
20
|
|
|
|
|
60
|
my $s3_operation = $name; |
44
|
20
|
|
|
|
|
117
|
$s3_operation =~ s/_api_/_operation_/; |
45
|
|
|
|
|
|
|
|
46
|
20
|
|
|
106
|
|
1996
|
return +( $name => eval <<"GEN_SUB" ); |
|
106
|
|
|
|
|
75144
|
|
|
106
|
|
|
|
|
2739
|
|
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
|
186
|
|
|
186
|
|
132914
|
my ($self, $params) = @_; |
56
|
|
|
|
|
|
|
|
57
|
186
|
|
66
|
|
|
1254
|
$params->{with_s3} ||= Shared::Examples::Net::Amazon::S3::s3_api_with_signature_2 (); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _mock_http_response { |
61
|
106
|
|
|
106
|
|
790
|
my (undef, $api, %params) = @_; |
62
|
|
|
|
|
|
|
|
63
|
106
|
|
|
|
|
993
|
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
|
23
|
my ($title, %params) = @_; |
71
|
|
|
|
|
|
|
|
72
|
4
|
|
|
|
|
12
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
73
|
|
|
|
|
|
|
|
74
|
4
|
|
|
|
|
22
|
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
|
|
|
|
|
500
|
); |
95
|
|
|
|
|
|
|
|
96
|
4
|
|
|
|
|
127
|
cmp_deeply $got, $params{expect_uri}, $title; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub operation_list_all_my_buckets { |
100
|
4
|
|
|
4
|
0
|
16
|
my ($self, %params) = @_; |
101
|
|
|
|
|
|
|
|
102
|
4
|
|
|
|
|
16
|
$self->buckets; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub operation_bucket_acl_get { |
106
|
4
|
|
|
4
|
0
|
26
|
my ($self, %params) = @_; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$self |
109
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
110
|
4
|
|
|
|
|
24
|
->get_acl |
111
|
|
|
|
|
|
|
; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub operation_bucket_acl_set { |
115
|
9
|
|
|
9
|
0
|
78
|
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
|
|
|
|
|
51
|
; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub operation_bucket_create { |
128
|
15
|
|
|
15
|
0
|
92
|
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
|
|
|
|
|
159
|
; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub operation_bucket_delete { |
142
|
5
|
|
|
5
|
0
|
32
|
my ($self, %params) = @_; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
$self |
145
|
|
|
|
|
|
|
->delete_bucket ({ |
146
|
|
|
|
|
|
|
bucket => $params{with_bucket}, |
147
|
|
|
|
|
|
|
}) |
148
|
5
|
|
|
|
|
40
|
; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub operation_bucket_objects_list { |
152
|
8
|
|
|
8
|
0
|
43
|
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
|
|
|
|
|
78
|
; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub operation_bucket_objects_delete { |
166
|
4
|
|
|
4
|
0
|
38
|
my ($self, %params) = @_; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$self |
169
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
170
|
4
|
|
|
|
|
29
|
->delete_multi_object (@{ $params{with_keys} }) |
|
4
|
|
|
|
|
29
|
|
171
|
|
|
|
|
|
|
; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub operation_object_acl_get { |
175
|
5
|
|
|
5
|
0
|
45
|
my ($self, %params) = @_; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
$self |
178
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
179
|
|
|
|
|
|
|
->get_acl ($params{with_key}) |
180
|
5
|
|
|
|
|
45
|
; |
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
|
|
|
|
|
48
|
; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub operation_object_create { |
198
|
10
|
|
|
10
|
0
|
60
|
my ($self, %params) = @_; |
199
|
|
|
|
|
|
|
|
200
|
10
|
50
|
|
|
|
22
|
my $headers = { %{ $params{with_headers} || {} } }; |
|
10
|
|
|
|
|
59
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
$headers->{$_} = $params{"with_$_"} |
203
|
10
|
|
|
|
|
97
|
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
|
|
|
|
33
|
if $params{with_storage_class}; |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
$headers->{"x_amz_meta_\L$_"} = $params{with_user_metadata}{$_} |
218
|
10
|
100
|
|
|
|
13
|
for keys %{ $params{with_user_metadata} || {} }; |
|
10
|
|
|
|
|
53
|
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
$self |
221
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
222
|
|
|
|
|
|
|
->add_key ( |
223
|
|
|
|
|
|
|
$params{with_key}, |
224
|
|
|
|
|
|
|
$params{with_value}, |
225
|
10
|
|
|
|
|
49
|
$headers, |
226
|
|
|
|
|
|
|
) |
227
|
|
|
|
|
|
|
; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub operation_object_delete { |
231
|
5
|
|
|
5
|
0
|
52
|
my ($self, %params) = @_; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
$self |
234
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
235
|
|
|
|
|
|
|
->delete_key ($params{with_key}) |
236
|
5
|
|
|
|
|
45
|
; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub operation_object_fetch { |
240
|
6
|
|
|
6
|
0
|
37
|
my ($self, %params) = @_; |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
$self |
243
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
244
|
6
|
|
|
|
|
34
|
->get_key ($params{with_key}, 'GET') |
245
|
|
|
|
|
|
|
; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub operation_object_head { |
249
|
5
|
|
|
5
|
0
|
30
|
my ($self, %params) = @_; |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
$self |
252
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
253
|
|
|
|
|
|
|
->head_key ($params{with_key}) |
254
|
5
|
|
|
|
|
26
|
; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub operation_bucket_tags_add { |
258
|
4
|
|
|
4
|
0
|
24
|
my ($self, %params) = @_; |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
$self |
261
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
262
|
|
|
|
|
|
|
->add_tags ({ |
263
|
|
|
|
|
|
|
tags => $params{with_tags}, |
264
|
|
|
|
|
|
|
}) |
265
|
4
|
|
|
|
|
20
|
; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
sub operation_object_tags_add { |
269
|
4
|
|
|
4
|
0
|
27
|
my ($self, %params) = @_; |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
$self |
272
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
273
|
|
|
|
|
|
|
->add_tags ({ |
274
|
|
|
|
|
|
|
key => $params{with_key}, |
275
|
|
|
|
|
|
|
tags => $params{with_tags}, |
276
|
|
|
|
|
|
|
(version_id => $params{with_version_id}) x!! defined $params{with_version_id}, |
277
|
|
|
|
|
|
|
}) |
278
|
4
|
|
|
|
|
26
|
; |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
sub operation_bucket_tags_delete { |
282
|
4
|
|
|
4
|
0
|
23
|
my ($self, %params) = @_; |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
$self |
285
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
286
|
4
|
|
|
|
|
29
|
->delete_tags |
287
|
|
|
|
|
|
|
; |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
sub operation_object_tags_delete { |
291
|
5
|
|
|
5
|
0
|
46
|
my ($self, %params) = @_; |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
$self |
294
|
|
|
|
|
|
|
->bucket ($params{with_bucket}) |
295
|
|
|
|
|
|
|
->delete_tags ({ |
296
|
|
|
|
|
|
|
key => $params{with_key}, |
297
|
|
|
|
|
|
|
(version_id => $params{with_version_id}) x!! defined $params{with_version_id}, |
298
|
|
|
|
|
|
|
}) |
299
|
5
|
|
|
|
|
39
|
; |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
1; |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
__END__ |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=pod |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=encoding UTF-8 |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=head1 NAME |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
Shared::Examples::Net::Amazon::S3::API - used for testing and as example |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=head1 VERSION |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
version 0.98 |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=head1 AUTHOR |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
Branislav Zahradník <barney@cpan.org> |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
327
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=cut |