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.99'; |
4
|
90
|
|
|
90
|
|
2156258
|
use strict; |
|
90
|
|
|
|
|
386
|
|
|
90
|
|
|
|
|
2894
|
|
5
|
90
|
|
|
90
|
|
583
|
use warnings; |
|
90
|
|
|
|
|
235
|
|
|
90
|
|
|
|
|
2909
|
|
6
|
|
|
|
|
|
|
|
7
|
90
|
|
|
90
|
|
525
|
use parent qw[ Exporter::Tiny ]; |
|
90
|
|
|
|
|
233
|
|
|
90
|
|
|
|
|
637
|
|
8
|
|
|
|
|
|
|
|
9
|
90
|
|
|
90
|
|
161561
|
use Hash::Util; |
|
90
|
|
|
|
|
107965
|
|
|
90
|
|
|
|
|
695
|
|
10
|
90
|
|
|
90
|
|
22718
|
use HTTP::Response; |
|
90
|
|
|
|
|
784545
|
|
|
90
|
|
|
|
|
2684
|
|
11
|
90
|
|
|
90
|
|
618
|
use HTTP::Status; |
|
90
|
|
|
|
|
251
|
|
|
90
|
|
|
|
|
30388
|
|
12
|
90
|
|
|
90
|
|
32247
|
use Sub::Override; |
|
90
|
|
|
|
|
73927
|
|
|
90
|
|
|
|
|
2809
|
|
13
|
90
|
|
|
90
|
|
650
|
use Test::Deep; |
|
90
|
|
|
|
|
263
|
|
|
90
|
|
|
|
|
750
|
|
14
|
90
|
|
|
90
|
|
25275
|
use Test::More; |
|
90
|
|
|
|
|
249
|
|
|
90
|
|
|
|
|
692
|
|
15
|
|
|
|
|
|
|
|
16
|
90
|
|
|
90
|
|
43751
|
use Net::Amazon::S3::Client; |
|
90
|
|
|
|
|
288
|
|
|
90
|
|
|
|
|
3494
|
|
17
|
90
|
|
|
90
|
|
21821
|
use Shared::Examples::Net::Amazon::S3; |
|
90
|
|
|
|
|
372
|
|
|
90
|
|
|
|
|
797
|
|
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
|
90
|
|
|
90
|
|
31506
|
my ($self, $name, $args, $globals) = @_; |
43
|
|
|
|
|
|
|
|
44
|
90
|
|
|
|
|
256
|
my $s3_operation = $name; |
45
|
90
|
|
|
|
|
282
|
$s3_operation =~ s/_client_/_operation_/; |
46
|
|
|
|
|
|
|
|
47
|
90
|
|
|
100
|
|
8018
|
return +( $name => eval <<"GEN_SUB" ); |
|
100
|
|
|
|
|
104535
|
|
|
100
|
|
|
|
|
1383
|
|
|
98
|
|
|
|
|
152509
|
|
|
98
|
|
|
|
|
1098
|
|
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
|
216
|
|
|
144
|
|
118391
|
my ($self, $params) = @_; |
57
|
|
|
|
|
|
|
|
58
|
216
|
|
66
|
|
|
2332
|
$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
|
103
|
|
|
103
|
|
1072
|
my ($self, $api, %params) = @_; |
65
|
|
|
|
|
|
|
|
66
|
103
|
|
|
|
|
3139
|
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
|
|
|
|
|
24
|
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
|
|
|
|
|
688
|
); |
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
|
|
|
250
|
$params{with_method} || 'GET', |
99
|
|
|
|
|
|
|
) |
100
|
|
|
|
|
|
|
; |
101
|
|
|
|
|
|
|
|
102
|
4
|
|
|
|
|
156
|
cmp_deeply $got, $params{expect_uri}, $title; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub operation_list_all_my_buckets { |
106
|
4
|
|
|
4
|
0
|
19
|
my ($self, %params) = @_; |
107
|
|
|
|
|
|
|
|
108
|
4
|
|
|
|
|
25
|
[ $_[0]->buckets ]; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub operation_bucket_acl_get { |
112
|
4
|
|
|
4
|
0
|
19
|
my ($self, %params) = @_; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$self |
115
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
116
|
4
|
|
|
|
|
18
|
->acl |
117
|
|
|
|
|
|
|
; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub operation_bucket_create { |
121
|
14
|
|
|
14
|
0
|
81
|
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
|
|
|
|
|
145
|
); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub operation_bucket_delete { |
132
|
5
|
|
|
5
|
0
|
24
|
my ($self, %params) = @_; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
$self |
135
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
136
|
5
|
|
|
|
|
25
|
->delete |
137
|
|
|
|
|
|
|
; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub operation_bucket_objects_list { |
141
|
7
|
|
|
7
|
0
|
36
|
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
|
|
|
|
|
54
|
; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub operation_bucket_objects_delete { |
156
|
4
|
|
|
4
|
0
|
23
|
my ($self, %params) = @_; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
$self |
159
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
160
|
4
|
|
|
|
|
64
|
->delete_multi_object (@{ $params{with_keys} }) |
|
4
|
|
|
|
|
23
|
|
161
|
|
|
|
|
|
|
; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub operation_object_create { |
165
|
10
|
|
|
10
|
0
|
54
|
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
|
|
|
|
65
|
->${\ (ref $params{with_value} ? 'put_filename' : 'put' ) } ( |
186
|
0
|
|
|
|
|
0
|
ref $params{with_value} ? ${ $params{with_value} } : $params{with_value} |
187
|
|
|
|
|
|
|
) |
188
|
10
|
50
|
|
|
|
41
|
; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub operation_object_delete { |
192
|
5
|
|
|
5
|
0
|
25
|
my ($self, %params) = @_; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
$self |
195
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
196
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
197
|
5
|
|
|
|
|
32
|
->delete |
198
|
|
|
|
|
|
|
; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub operation_object_fetch { |
202
|
6
|
|
|
6
|
0
|
30
|
my ($self, %params) = @_; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
my $object = $self |
205
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
206
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
207
|
6
|
|
|
|
|
28
|
; |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
$object = $object->range ($params{with_range}) |
210
|
6
|
100
|
|
|
|
26
|
if $params{with_range}; |
211
|
|
|
|
|
|
|
|
212
|
6
|
|
|
|
|
998
|
$object->get; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub operation_object_head { |
216
|
10
|
|
|
10
|
0
|
86
|
my ($self, %params) = @_; |
217
|
|
|
|
|
|
|
|
218
|
10
|
|
50
|
|
|
77
|
my $method = $params{-method} // 'exists'; |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
$self |
221
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
222
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
223
|
10
|
|
|
|
|
78
|
->$method |
224
|
|
|
|
|
|
|
; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub operation_bucket_acl_set { |
228
|
8
|
|
|
8
|
0
|
34
|
my ($self, %params) = @_; |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
$self |
231
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
232
|
|
|
|
|
|
|
->set_acl ( |
233
|
|
|
|
|
|
|
(acl => $params{with_acl}) x!! exists $params{with_acl}, |
234
|
|
|
|
|
|
|
(acl_short => $params{with_acl_short}) x!! exists $params{with_acl_short}, |
235
|
|
|
|
|
|
|
(acl_xml => $params{with_acl_xml}) x!! exists $params{with_acl_xml}, |
236
|
|
|
|
|
|
|
) |
237
|
8
|
|
|
|
|
34
|
; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
sub operation_object_acl_set { |
241
|
9
|
|
|
9
|
0
|
79
|
my ($self, %params) = @_; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
$self |
244
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
245
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
246
|
|
|
|
|
|
|
->set_acl ( |
247
|
|
|
|
|
|
|
(acl => $params{with_acl}) x!! exists $params{with_acl}, |
248
|
|
|
|
|
|
|
(acl_short => $params{with_acl_short}) x!! exists $params{with_acl_short}, |
249
|
|
|
|
|
|
|
(acl_xml => $params{with_acl_xml}) x!! exists $params{with_acl_xml}, |
250
|
|
|
|
|
|
|
) |
251
|
9
|
|
|
|
|
80
|
; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub operation_bucket_tags_add { |
255
|
4
|
|
|
4
|
0
|
35
|
my ($self, %params) = @_; |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
$self |
258
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
259
|
|
|
|
|
|
|
->add_tags ( |
260
|
|
|
|
|
|
|
tags => $params{with_tags}, |
261
|
|
|
|
|
|
|
) |
262
|
4
|
|
|
|
|
35
|
; |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
sub operation_object_tags_add { |
266
|
4
|
|
|
4
|
0
|
22
|
my ($self, %params) = @_; |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
$self |
269
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
270
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
271
|
|
|
|
|
|
|
->add_tags ( |
272
|
|
|
|
|
|
|
tags => $params{with_tags}, |
273
|
|
|
|
|
|
|
(version_id => $params{with_version_id}) x!! defined $params{with_version_id}, |
274
|
|
|
|
|
|
|
) |
275
|
4
|
|
|
|
|
19
|
; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
sub operation_bucket_tags_delete { |
279
|
4
|
|
|
4
|
0
|
29
|
my ($self, %params) = @_; |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
$self |
282
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
283
|
4
|
|
|
|
|
32
|
->delete_tags |
284
|
|
|
|
|
|
|
; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub operation_object_tags_delete { |
288
|
5
|
|
|
5
|
0
|
27
|
my ($self, %params) = @_; |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
$self |
291
|
|
|
|
|
|
|
->bucket (name => $params{with_bucket}) |
292
|
|
|
|
|
|
|
->object (key => $params{with_key}) |
293
|
|
|
|
|
|
|
->delete_tags ( |
294
|
|
|
|
|
|
|
(version_id => $params{with_version_id}) x!! defined $params{with_version_id}, |
295
|
|
|
|
|
|
|
) |
296
|
5
|
|
|
|
|
24
|
; |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
1; |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
__END__ |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=pod |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=encoding UTF-8 |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=head1 NAME |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
Shared::Examples::Net::Amazon::S3::Client - used for testing and as example |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=head1 VERSION |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
version 0.99 |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=head1 AUTHOR |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
Branislav Zahradník <barney@cpan.org> |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
324
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=cut |