Skip to content

Commit 2050bc3

Browse files
authored
Fix S3Control unit tests for outposts (#2192)
* fix unit tests * previous commit reordered a test, which makes the PR diff harder to review. moved back to original order * reordered tests * remove typo
1 parent 62a910d commit 2050bc3

File tree

1 file changed

+58
-42
lines changed

1 file changed

+58
-42
lines changed

service/s3control/internal/customizations/update_endpoint_test.go

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func TestEndpointWithARN(t *testing.T) {
134134
cases := map[string]struct {
135135
options s3control.Options
136136
bucket string
137+
accessPoint string
137138
expectedErr string
138139
expectedReqURL string
139140
expectedSigningName string
@@ -142,163 +143,163 @@ func TestEndpointWithARN(t *testing.T) {
142143
expectedHeaderForAccountID bool
143144
}{
144145
"Outpost AccessPoint with no S3UseARNRegion flag set": {
145-
bucket: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
146+
accessPoint: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
146147
options: s3control.Options{
147148
Region: "us-west-2",
148149
},
149-
expectedReqURL: "https://s3-outposts.us-west-2.amazonaws.com/v20180820/bucket/myaccesspoint",
150+
expectedReqURL: "https://s3-outposts.us-west-2.amazonaws.com/v20180820/accesspoint/myaccesspoint",
150151
expectedSigningName: "s3-outposts",
151152
expectedSigningRegion: "us-west-2",
152153
expectedHeaderForAccountID: true,
153154
expectedHeaderForOutpostID: "op-01234567890123456",
154155
},
155156
"Outpost AccessPoint Cross-Region Enabled": {
156-
bucket: "arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
157+
accessPoint: "arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
157158
options: s3control.Options{
158159
Region: "us-west-2",
159160
UseARNRegion: true,
160161
},
161-
expectedReqURL: "https://s3-outposts.us-east-1.amazonaws.com/v20180820/bucket/myaccesspoint",
162+
expectedReqURL: "https://s3-outposts.us-east-1.amazonaws.com/v20180820/accesspoint/myaccesspoint",
162163
expectedSigningName: "s3-outposts",
163164
expectedSigningRegion: "us-east-1",
164165
expectedHeaderForAccountID: true,
165166
expectedHeaderForOutpostID: "op-01234567890123456",
166167
},
167168
"Outpost AccessPoint Cross-Region Disabled": {
168-
bucket: "arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
169+
accessPoint: "arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
169170
options: s3control.Options{
170171
Region: "us-west-2",
171172
},
172173
expectedErr: "client region does not match provided ARN region",
173174
},
174175
"Outpost AccessPoint other partition": {
175-
bucket: "arn:aws-cn:s3-outposts:cn-north-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
176+
accessPoint: "arn:aws-cn:s3-outposts:cn-north-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
176177
options: s3control.Options{
177178
Region: "us-west-2",
178179
UseARNRegion: true,
179180
},
180181
expectedErr: "ConfigurationError : client partition does not match provided ARN partition",
181182
},
182183
"Outpost AccessPoint us-gov region": {
183-
bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
184+
accessPoint: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
184185
options: s3control.Options{
185186
Region: "us-gov-east-1",
186187
UseARNRegion: true,
187188
},
188-
expectedReqURL: "https://s3-outposts.us-gov-east-1.amazonaws.com/v20180820/bucket/myaccesspoint",
189+
expectedReqURL: "https://s3-outposts.us-gov-east-1.amazonaws.com/v20180820/accesspoint/myaccesspoint",
189190
expectedSigningName: "s3-outposts",
190191
expectedSigningRegion: "us-gov-east-1",
191192
expectedHeaderForAccountID: true,
192193
expectedHeaderForOutpostID: "op-01234567890123456",
193194
},
194195
"Outpost AccessPoint with client region as FIPS": {
195-
bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
196+
accessPoint: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
196197
options: s3control.Options{
197198
Region: "us-gov-east-1",
198199
EndpointOptions: s3control.EndpointResolverOptions{
199200
UseFIPSEndpoint: aws.FIPSEndpointStateEnabled,
200201
},
201202
},
202-
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/bucket/myaccesspoint",
203+
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/accesspoint/myaccesspoint",
203204
expectedSigningName: "s3-outposts",
204205
expectedSigningRegion: "us-gov-east-1",
205206
expectedHeaderForOutpostID: "op-01234567890123456",
206207
expectedHeaderForAccountID: true,
207208
},
208209
"Outpost AccessPoint with client region as FIPS (ResolvedRegion)": {
209-
bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
210+
accessPoint: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
210211
options: s3control.Options{
211212
Region: "us-gov-east-1-fips",
212213
},
213-
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/bucket/myaccesspoint",
214+
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/accesspoint/myaccesspoint",
214215
expectedSigningName: "s3-outposts",
215216
expectedSigningRegion: "us-gov-east-1",
216217
expectedHeaderForOutpostID: "op-01234567890123456",
217218
expectedHeaderForAccountID: true,
218219
},
219220
"Outpost AccessPoint with client FIPS and use arn region enabled": {
220-
bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
221+
accessPoint: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
221222
options: s3control.Options{
222223
Region: "us-gov-east-1",
223224
EndpointOptions: s3control.EndpointResolverOptions{
224225
UseFIPSEndpoint: aws.FIPSEndpointStateEnabled,
225226
},
226227
UseARNRegion: true,
227228
},
228-
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/bucket/myaccesspoint",
229+
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/accesspoint/myaccesspoint",
229230
expectedSigningName: "s3-outposts",
230231
expectedSigningRegion: "us-gov-east-1",
231232
expectedHeaderForOutpostID: "op-01234567890123456",
232233
expectedHeaderForAccountID: true,
233234
},
234235
"Outpost AccessPoint with client FIPS (ResolvedRegion) and use arn region enabled": {
235-
bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
236+
accessPoint: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
236237
options: s3control.Options{
237238
Region: "us-gov-east-1-fips",
238239
UseARNRegion: true,
239240
},
240-
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/bucket/myaccesspoint",
241+
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/accesspoint/myaccesspoint",
241242
expectedSigningName: "s3-outposts",
242243
expectedSigningRegion: "us-gov-east-1",
243244
expectedHeaderForOutpostID: "op-01234567890123456",
244245
expectedHeaderForAccountID: true,
245246
},
246247
"Outpost AccessPoint client FIPS and cross region ARN": {
247-
bucket: "arn:aws-us-gov:s3-outposts:us-gov-west-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
248+
accessPoint: "arn:aws-us-gov:s3-outposts:us-gov-west-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
248249
options: s3control.Options{
249250
Region: "us-gov-east-1",
250251
UseARNRegion: true,
251252
EndpointOptions: s3control.EndpointResolverOptions{
252253
UseFIPSEndpoint: aws.FIPSEndpointStateEnabled,
253254
},
254255
},
255-
expectedReqURL: "https://s3-outposts-fips.us-gov-west-1.amazonaws.com/v20180820/bucket/myaccesspoint",
256+
expectedReqURL: "https://s3-outposts-fips.us-gov-west-1.amazonaws.com/v20180820/accesspoint/myaccesspoint",
256257
expectedSigningName: "s3-outposts",
257258
expectedSigningRegion: "us-gov-west-1",
258259
expectedHeaderForOutpostID: "op-01234567890123456",
259260
expectedHeaderForAccountID: true,
260261
},
261262
"Outpost AccessPoint client FIPS (ResolvedRegion) and cross region ARN": {
262-
bucket: "arn:aws-us-gov:s3-outposts:us-gov-west-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
263+
accessPoint: "arn:aws-us-gov:s3-outposts:us-gov-west-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
263264
options: s3control.Options{
264265
Region: "us-gov-east-1-fips",
265266
UseARNRegion: true,
266267
},
267-
expectedReqURL: "https://s3-outposts-fips.us-gov-west-1.amazonaws.com/v20180820/bucket/myaccesspoint",
268+
expectedReqURL: "https://s3-outposts-fips.us-gov-west-1.amazonaws.com/v20180820/accesspoint/myaccesspoint",
268269
expectedSigningName: "s3-outposts",
269270
expectedSigningRegion: "us-gov-west-1",
270271
expectedHeaderForOutpostID: "op-01234567890123456",
271272
expectedHeaderForAccountID: true,
272273
},
273274
"Outpost AccessPoint client FIPS with valid ARN region": {
274-
bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
275+
accessPoint: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
275276
options: s3control.Options{
276277
Region: "us-gov-east-1",
277278
EndpointOptions: s3control.EndpointResolverOptions{
278279
UseFIPSEndpoint: aws.FIPSEndpointStateEnabled,
279280
},
280281
UseARNRegion: true,
281282
},
282-
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/bucket/myaccesspoint",
283+
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/accesspoint/myaccesspoint",
283284
expectedSigningName: "s3-outposts",
284285
expectedSigningRegion: "us-gov-east-1",
285286
expectedHeaderForOutpostID: "op-01234567890123456",
286287
expectedHeaderForAccountID: true,
287288
},
288289
"Outpost AccessPoint client FIPS (ResolvedRegion) with valid ARN region": {
289-
bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
290+
accessPoint: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
290291
options: s3control.Options{
291292
Region: "us-gov-east-1-fips",
292293
UseARNRegion: true,
293294
},
294-
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/bucket/myaccesspoint",
295+
expectedReqURL: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/v20180820/accesspoint/myaccesspoint",
295296
expectedSigningName: "s3-outposts",
296297
expectedSigningRegion: "us-gov-east-1",
297298
expectedHeaderForOutpostID: "op-01234567890123456",
298299
expectedHeaderForAccountID: true,
299300
},
300301
"Outpost AccessPoint with DualStack": {
301-
bucket: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
302+
accessPoint: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
302303
options: s3control.Options{
303304
Region: "us-west-2",
304305
UseARNRegion: true,
@@ -321,24 +322,24 @@ func TestEndpointWithARN(t *testing.T) {
321322
expectedErr: "incomplete outpost resource type",
322323
},
323324
"access point": {
324-
bucket: "myaccesspoint",
325+
accessPoint: "myaccesspoint",
325326
options: s3control.Options{
326327
Region: "us-west-2",
327328
},
328-
expectedReqURL: "https://123456789012.s3-control.us-west-2.amazonaws.com/v20180820/bucket/myaccesspoint",
329+
expectedReqURL: "https://123456789012.s3-control.us-west-2.amazonaws.com/v20180820/accesspoint/myaccesspoint",
329330
expectedHeaderForAccountID: true,
330331
expectedSigningRegion: "us-west-2",
331332
expectedSigningName: "s3",
332333
},
333334
"outpost access point with unsupported sub-resource": {
334-
bucket: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:mybucket:object:foo",
335+
accessPoint: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:mybucket:object:foo",
335336
options: s3control.Options{
336337
Region: "us-west-2",
337338
},
338339
expectedErr: "sub resource not supported",
339340
},
340341
"Missing outpost identifiers in outpost access point arn": {
341-
bucket: "arn:aws:s3-outposts:us-west-2:123456789012:accesspoint:myendpoint",
342+
accessPoint: "arn:aws:s3-outposts:us-west-2:123456789012:accesspoint:myendpoint",
342343
options: s3control.Options{
343344
Region: "us-west-2",
344345
},
@@ -510,19 +511,34 @@ func TestEndpointWithARN(t *testing.T) {
510511

511512
ctx := context.Background()
512513

513-
// call an operation
514-
_, err := svc.GetBucket(ctx, &s3control.GetBucketInput{
515-
Bucket: ptr.String(c.bucket),
516-
AccountId: ptr.String("123456789012"),
517-
}, func(options *s3control.Options) {
518-
// append request retriever middleware for request inspection
519-
options.APIOptions = append(options.APIOptions,
520-
func(stack *middleware.Stack) error {
521-
// adds AFTER operation serializer middleware
522-
stack.Serialize.Insert(&fm, "OperationSerializer", middleware.After)
523-
return nil
524-
})
525-
})
514+
var err error
515+
if len(c.accessPoint) > 0 {
516+
_, err = svc.GetAccessPoint(ctx, &s3control.GetAccessPointInput{
517+
Name: ptr.String(c.accessPoint),
518+
AccountId: ptr.String("123456789012"),
519+
}, func(options *s3control.Options) {
520+
// append request retriever middleware for request inspection
521+
options.APIOptions = append(options.APIOptions,
522+
func(stack *middleware.Stack) error {
523+
// adds AFTER operation serializer middleware
524+
stack.Serialize.Insert(&fm, "OperationSerializer", middleware.After)
525+
return nil
526+
})
527+
})
528+
} else {
529+
_, err = svc.GetBucket(ctx, &s3control.GetBucketInput{
530+
Bucket: ptr.String(c.bucket),
531+
AccountId: ptr.String("123456789012"),
532+
}, func(options *s3control.Options) {
533+
// append request retriever middleware for request inspection
534+
options.APIOptions = append(options.APIOptions,
535+
func(stack *middleware.Stack) error {
536+
// adds AFTER operation serializer middleware
537+
stack.Serialize.Insert(&fm, "OperationSerializer", middleware.After)
538+
return nil
539+
})
540+
})
541+
}
526542

527543
// inspect any errors
528544
if len(c.expectedErr) != 0 {

0 commit comments

Comments
 (0)