line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Shared::Examples::Net::Amazon::S3::Client; |
2
|
|
|
|
|
|
|
# ABSTRACT: used for testing and as example |
3
|
|
|
|
|
|
|
$Shared::Examples::Net::Amazon::S3::Client::VERSION = '0.98'; |
4
|
89
|
|
|
89
|
|
2070644
|
use strict; |
|
89
|
|
|
|
|
338
|
|
|
89
|
|
|
|
|
2973
|
|
5
|
89
|
|
|
89
|
|
554
|
use warnings; |
|
89
|
|
|
|
|
217
|
|
|
89
|
|
|
|
|
2959
|
|
6
|
|
|
|
|
|
|
|
7
|
89
|
|
|
89
|
|
644
|
use parent qw[ Exporter::Tiny ]; |
|
89
|
|
|
|
|
212
|
|
|
89
|
|
|
|
|
660
|
|
8
|
|
|
|
|
|
|
|
9
|
89
|
|
|
89
|
|
159713
|
use Hash::Util; |
|
89
|
|
|
|
|
104012
|
|
|
89
|
|
|
|
|
629
|
|
10
|
89
|
|
|
89
|
|
22893
|
use HTTP::Response; |
|
89
|
|
|
|
|
770015
|
|
|
89
|
|
|
|
|
2685
|
|
11
|
89
|
|
|
89
|
|
662
|
use HTTP::Status; |
|
89
|
|
|
|
|
220
|
|
|
89
|
|
|
|
|
30180
|
|
12
|
89
|
|
|
89
|
|
34656
|
use Sub::Override; |
|
89
|
|
|
|
|
70421
|
|
|
89
|
|
|
|
|
2734
|
|
13
|
89
|
|
|
89
|
|
686
|
use Test::Deep; |
|
89
|
|
|
|
|
241
|
|
|
89
|
|
|
|
|
772
|
|
14
|
89
|
|
|
89
|
|
25675
|
use Test::More; |
|
89
|
|
|
|
|
240
|
|
|
89
|
|
|
|
|
747
|
|
15
|
|
|
|
|
|
|
|
16
|
89
|
|
|
89
|
|
45954
|
use Net::Amazon::S3::Client; |
|
89
|
|
|
|
|
321
|
|
|
89
|
|
|
|
|
4037
|
|
17
|
89
|
|
|
89
|
|
26949
|
use Shared::Examples::Net::Amazon::S3; |
|
89
|
|
|
|
|
304
|
|
|
89
|
|
|
|
|
848
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
20
|
|
|
|
|
|
|
qw[ expect_signed_uri ], |
21
|
|
|
|
|
|
|
qw[ expect_client_list_all_my_buckets ], |
22
|
|
|
|
|
|
|
qw[ expect_client_bucket_acl_get ], |
23
|
|
|
|
|
|
|
qw[ expect_client_bucket_acl_set ], |
24
|
|
|
|
|
|
|
qw[ expect_client_bucket_create ], |
25
|
|
|
|
|
|
|
qw[ expect_client_bucket_delete ], |
26
|
|
|
|
|
|
|
qw[ expect_client_bucket_objects_delete ], |
27
|
|
|
|
|
|
|
qw[ expect_client_bucket_objects_list ], |
28
|
|
|
|
|
|
|
qw[ expect_client_bucket_tags_add ], |
29
|
|
|
|
|
|
|
qw[ expect_client_bucket_tags_delete ], |
30
|
|
|
|
|
|
|
qw[ expect_client_object_acl_set ], |
31
|
|
|
|
|
|
|
qw[ expect_client_object_create ], |
32
|
|
|
|
|
|
|
qw[ expect_client_object_delete ], |
33
|
|
|
|
|
|
|
qw[ expect_client_object_fetch ], |
34
|
|
|
|
|
|
|
qw[ expect_client_object_head ], |
35
|
|
|
|
|
|
|
qw[ expect_client_object_tags_add], |
36
|
|
|
|
|
|
|
qw[ expect_client_object_tags_delete], |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
*with_fixture = *Shared::Examples::Net::Amazon::S3::with_fixture; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _exporter_expand_sub { |
42
|
87
|
|
|
87
|
|
31270
|
my ($self, $name, $args, $globals) = @_; |
43
|
|
|
|
|
|
|
|
44
|
87
|
|
|
|
|
201
|
my $s3_operation = $name; |
45
|
87
|
|
|
|
|
267
|
$s3_operation =~ s/_client_/_operation_/; |
46
|
|
|
|
|
|
|
|
47
|
87
|
|
|
98
|
|
7869
|
return +( $name => eval <<"GEN_SUB" ); |
|
98
|
|
|
|
|
106787
|
|
|
98
|
|
|
|
|
1416
|
|
|
118
|
|
|
|
|
149108
|
|
|
118
|
|
|
|
|
1579
|
|
48
|
|
|
|
|
|
|
sub { |
49
|
|
|
|
|
|
|
push \@_, -shared_examples => __PACKAGE__; |
50
|
|
|
|
|
|
|
goto \\& Shared::Examples::Net::Amazon::S3::$s3_operation; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
GEN_SUB |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _default_with_api { |
56
|
182
|
|
|
138
|
|
109131
|
my ($self, $params) = @_; |
57
|
|
|
|
|
|
|
|
58
|
182
|
|
66
|
|
|
1666
|
$params->{with_client} ||= Net::Amazon::S3::Client->new ( |
59
|
|
|
|
|
|
|
s3 => Shared::Examples::Net::Amazon::S3::s3_api_with_signature_2 () |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _mock_http_response { |
64
|
97
|
|
|
97
|
|
715
|
my ($self, $api, %params) = @_; |
65
|
|
|
|
|
|
|
|
66
|
97
|
|
|
|
|
3083
|
Shared::Examples::Net::Amazon::S3->s3_api_mock_http_response ( |
67
|
|
|
|
|
|
|
$api->s3, |
68
|
|
|
|
|
|
|
%params, |
69
|
|
|
|
|
|
|
) |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub expect_signed_uri { |
73
|
4
|
|
|
4
|
0
|
25
|
my ($title, %params) = @_; |
74
|
|
|
|
|
|
|
|
75
|
4
|
|
|
|
|
21
|
Hash::Util::lock_keys %params, |
76
|
|
|
|
|
|
|
qw[ with_client ], |
77
|
|
|
|
|
|
|
qw[ with_bucket ], |
78
|
|
|
|
|
|
|
qw[ with_region ], |
79
|
|
|
|
|
|
|
qw[ with_key ], |
80
|
|
|
|
|
|
|
qw[ with_expire_at ], |
81
|
|
|
|
|
|
|
qw[ with_method ], |
82
|
|
|
|
|
|
|
qw[ expect_uri ], |
83
|
|
|
|
|
|
|
; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $guard = Sub::Override->new ( |
86
|
3
|
|
|
3
|
|
82
|
'Net::Amazon::S3::Bucket::region' => sub { $params{with_region } }, |
87
|
4
|
|
|
|
|
332
|
); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $got = $params{with_client} |
90
|
|
|
|
|
|
|
->bucket ( |
91
|
|
|
|
|
|
|
name => $params{with_bucket}, |
92
|
|
|
|
|
|
|
) |
93
|
|
|
|
|
|
|
->object ( |
94
|
|
|
|
|
|
|
key => $params{with_key}, |
95
|
|
|
|
|
|
|
expires => $params{with_expire_at}, |
96
|
|
|
|
|
|
|
) |
97
|
|
|
|
|
|
|
->query_string_authentication_uri_for_method ( |
98
|
4
|
|
100
|
|
|
262
|
$params{with_method} || 'GET', |
99
|
|
|
|
|
|
|
) |
100
|
|
|
|
|
|
|
; |
101
|
|
|
|
|
|
|
|
102
|
4
|
|
|
|
|
146
|
cmp_deeply $got, $params{expect_uri}, $title; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub operation_list_all_my_buckets { |
106
|
4
|
|
|
4
|
0
|
23
|
my ($self, %params) = @_; |
107
|
|
|
|
|
|
|
|
108
|
4
|
|
|
|
|
24
|
[ $_[0]->buckets ]; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub operation_bucket_acl_get { |
112
|
4
|
|
|
4
|
0
|
21
|
my ($self, %params) = @_; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$self |
115
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
116
|
4
|
|
|
|
|
24
|
->acl |
117
|
|
|
|
|
|
|
; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub operation_bucket_create { |
121
|
14
|
|
|
14
|
0
|
76
|
my ($self, %params) = @_; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$self->create_bucket( |
124
|
|
|
|
|
|
|
name => $params{with_bucket}, |
125
|
|
|
|
|
|
|
(acl => $params{with_acl}) x!! exists $params{with_acl}, |
126
|
|
|
|
|
|
|
(acl_short => $params{with_acl_short}) x!! exists $params{with_acl_short}, |
127
|
|
|
|
|
|
|
(location_constraint => $params{with_region}) x!! exists $params{with_region}, |
128
|
14
|
|
|
|
|
142
|
); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub operation_bucket_delete { |
132
|
5
|
|
|
5
|
0
|
35
|
my ($self, %params) = @_; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
$self |
135
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
136
|
5
|
|
|
|
|
41
|
->delete |
137
|
|
|
|
|
|
|
; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub operation_bucket_objects_list { |
141
|
7
|
|
|
7
|
0
|
34
|
my ($self, %params) = @_; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
$self |
144
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
145
|
|
|
|
|
|
|
->list ({ |
146
|
|
|
|
|
|
|
bucket => $params{with_bucket}, |
147
|
|
|
|
|
|
|
delimiter => $params{with_delimiter}, |
148
|
|
|
|
|
|
|
max_keys => $params{with_max_keys}, |
149
|
|
|
|
|
|
|
marker => $params{with_marker}, |
150
|
|
|
|
|
|
|
prefix => $params{with_prefix}, |
151
|
|
|
|
|
|
|
}) |
152
|
7
|
|
|
|
|
31
|
; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub operation_bucket_objects_delete { |
156
|
4
|
|
|
4
|
0
|
36
|
my ($self, %params) = @_; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
$self |
159
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
160
|
4
|
|
|
|
|
34
|
->delete_multi_object (@{ $params{with_keys} }) |
|
4
|
|
|
|
|
31
|
|
161
|
|
|
|
|
|
|
; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub operation_object_create { |
165
|
10
|
|
|
10
|
0
|
69
|
my ($self, %params) = @_; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
$self |
168
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
169
|
|
|
|
|
|
|
->object ( |
170
|
|
|
|
|
|
|
key => $params{with_key}, |
171
|
|
|
|
|
|
|
map +($_ => $params{"with_$_"}), |
172
|
|
|
|
|
|
|
grep exists $params{"with_$_"}, ( |
173
|
|
|
|
|
|
|
qw[ cache_control ], |
174
|
|
|
|
|
|
|
qw[ content_disposition ], |
175
|
|
|
|
|
|
|
qw[ content_encoding ], |
176
|
|
|
|
|
|
|
qw[ content_type ], |
177
|
|
|
|
|
|
|
qw[ encryption ], |
178
|
|
|
|
|
|
|
qw[ expires ], |
179
|
|
|
|
|
|
|
qw[ storage_class ], |
180
|
|
|
|
|
|
|
qw[ user_metadata ], |
181
|
|
|
|
|
|
|
qw[ acl ], |
182
|
|
|
|
|
|
|
qw[ acl_short ], |
183
|
|
|
|
|
|
|
) |
184
|
|
|
|
|
|
|
) |
185
|
10
|
50
|
|
|
|
83
|
->${\ (ref $params{with_value} ? 'put_filename' : 'put' ) } ( |
186
|
0
|
|
|
|
|
0
|
ref $params{with_value} ? ${ $params{with_value} } : $params{with_value} |
187
|
|
|
|
|
|
|
) |
188
|
10
|
50
|
|
|
|
70
|
; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub operation_object_delete { |
192
|
5
|
|
|
5
|
0
|
23
|
my ($self, %params) = @_; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
$self |
195
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
196
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
197
|
5
|
|
|
|
|
28
|
->delete |
198
|
|
|
|
|
|
|
; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub operation_object_fetch { |
202
|
5
|
|
|
5
|
0
|
46
|
my ($self, %params) = @_; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
$self |
205
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
206
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
207
|
5
|
|
|
|
|
42
|
->get |
208
|
|
|
|
|
|
|
; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub operation_object_head { |
212
|
5
|
|
|
5
|
0
|
25
|
my ($self, %params) = @_; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
$self |
215
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
216
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
217
|
5
|
|
|
|
|
26
|
->exists |
218
|
|
|
|
|
|
|
; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub operation_bucket_acl_set { |
222
|
8
|
|
|
8
|
0
|
45
|
my ($self, %params) = @_; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
$self |
225
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
226
|
|
|
|
|
|
|
->set_acl ( |
227
|
|
|
|
|
|
|
(acl => $params{with_acl}) x!! exists $params{with_acl}, |
228
|
|
|
|
|
|
|
(acl_short => $params{with_acl_short}) x!! exists $params{with_acl_short}, |
229
|
|
|
|
|
|
|
(acl_xml => $params{with_acl_xml}) x!! exists $params{with_acl_xml}, |
230
|
|
|
|
|
|
|
) |
231
|
8
|
|
|
|
|
40
|
; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub operation_object_acl_set { |
235
|
9
|
|
|
9
|
0
|
95
|
my ($self, %params) = @_; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
$self |
238
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
239
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
240
|
|
|
|
|
|
|
->set_acl ( |
241
|
|
|
|
|
|
|
(acl => $params{with_acl}) x!! exists $params{with_acl}, |
242
|
|
|
|
|
|
|
(acl_short => $params{with_acl_short}) x!! exists $params{with_acl_short}, |
243
|
|
|
|
|
|
|
(acl_xml => $params{with_acl_xml}) x!! exists $params{with_acl_xml}, |
244
|
|
|
|
|
|
|
) |
245
|
9
|
|
|
|
|
42
|
; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub operation_bucket_tags_add { |
249
|
4
|
|
|
4
|
0
|
32
|
my ($self, %params) = @_; |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
$self |
252
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
253
|
|
|
|
|
|
|
->add_tags ( |
254
|
|
|
|
|
|
|
tags => $params{with_tags}, |
255
|
|
|
|
|
|
|
) |
256
|
4
|
|
|
|
|
39
|
; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
sub operation_object_tags_add { |
260
|
4
|
|
|
4
|
0
|
29
|
my ($self, %params) = @_; |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
$self |
263
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
264
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
265
|
|
|
|
|
|
|
->add_tags ( |
266
|
|
|
|
|
|
|
tags => $params{with_tags}, |
267
|
|
|
|
|
|
|
(version_id => $params{with_version_id}) x!! defined $params{with_version_id}, |
268
|
|
|
|
|
|
|
) |
269
|
4
|
|
|
|
|
28
|
; |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
sub operation_bucket_tags_delete { |
273
|
4
|
|
|
4
|
0
|
33
|
my ($self, %params) = @_; |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
$self |
276
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
277
|
4
|
|
|
|
|
36
|
->delete_tags |
278
|
|
|
|
|
|
|
; |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
sub operation_object_tags_delete { |
282
|
5
|
|
|
5
|
0
|
28
|
my ($self, %params) = @_; |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
$self |
285
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
286
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
287
|
|
|
|
|
|
|
->delete_tags ( |
288
|
|
|
|
|
|
|
(version_id => $params{with_version_id}) x!! defined $params{with_version_id}, |
289
|
|
|
|
|
|
|
) |
290
|
5
|
|
|
|
|
27
|
; |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
1; |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
__END__ |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=pod |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=encoding UTF-8 |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=head1 NAME |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
Shared::Examples::Net::Amazon::S3::Client - used for testing and as example |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head1 VERSION |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
version 0.98 |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=head1 AUTHOR |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
Branislav Zahradník <barney@cpan.org> |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
318
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
=cut |