48
48
import static org .apache .hadoop .fs .s3a .Constants .AWS_REGION ;
49
49
import static org .apache .hadoop .fs .s3a .Constants .CENTRAL_ENDPOINT ;
50
50
import static org .apache .hadoop .fs .s3a .Constants .ENDPOINT ;
51
+ import static org .apache .hadoop .fs .s3a .Constants .FIPS_ENDPOINT ;
51
52
import static org .apache .hadoop .fs .s3a .Constants .PATH_STYLE_ACCESS ;
52
53
import static org .apache .hadoop .fs .s3a .DefaultS3ClientFactory .ERROR_ENDPOINT_WITH_FIPS ;
53
54
import static org .apache .hadoop .fs .s3a .S3ATestUtils .removeBaseAndBucketOverrides ;
@@ -156,6 +157,11 @@ public void testCentralEndpoint() throws Throwable {
156
157
S3Client client = createS3Client (conf , CENTRAL_ENDPOINT , null , US_EAST_2 , false );
157
158
158
159
expectInterceptorException (client );
160
+
161
+ client = createS3Client (conf , CENTRAL_ENDPOINT , null ,
162
+ US_EAST_2 , true );
163
+
164
+ expectInterceptorException (client );
159
165
}
160
166
161
167
@ Test
@@ -168,11 +174,21 @@ public void testCentralEndpointWithRegion() throws Throwable {
168
174
169
175
expectInterceptorException (client );
170
176
177
+ client = createS3Client (conf , CENTRAL_ENDPOINT , US_WEST_2 ,
178
+ US_WEST_2 , true );
179
+
180
+ expectInterceptorException (client );
181
+
171
182
client = createS3Client (conf , CENTRAL_ENDPOINT , US_EAST_1 ,
172
183
US_EAST_1 , false );
173
184
174
185
expectInterceptorException (client );
175
186
187
+ client = createS3Client (conf , CENTRAL_ENDPOINT , US_EAST_1 ,
188
+ US_EAST_1 , true );
189
+
190
+ expectInterceptorException (client );
191
+
176
192
}
177
193
178
194
@ Test
@@ -203,7 +219,7 @@ public void testWithFipsAndEndpoint() throws Throwable {
203
219
describe ("Create a client with fips and an endpoint" );
204
220
205
221
intercept (IllegalArgumentException .class , ERROR_ENDPOINT_WITH_FIPS , () ->
206
- createS3Client (getConfiguration (), CENTRAL_ENDPOINT , null , US_EAST_1 , true ));
222
+ createS3Client (getConfiguration (), US_WEST_2 , null , US_EAST_1 , true ));
207
223
}
208
224
209
225
@ Test
@@ -293,28 +309,23 @@ public void testCentralEndpointAndDifferentRegionThanBucket() throws Throwable {
293
309
ENDPOINT ,
294
310
AWS_REGION ,
295
311
ALLOW_REQUESTER_PAYS ,
296
- KEY_REQUESTER_PAYS_FILE );
312
+ KEY_REQUESTER_PAYS_FILE ,
313
+ FIPS_ENDPOINT );
297
314
298
315
removeBaseAndBucketOverrides (
299
316
DEFAULT_REQUESTER_PAYS_BUCKET_NAME ,
300
317
newConf ,
301
318
ENDPOINT ,
302
319
AWS_REGION ,
303
320
ALLOW_REQUESTER_PAYS ,
304
- KEY_REQUESTER_PAYS_FILE );
321
+ KEY_REQUESTER_PAYS_FILE ,
322
+ FIPS_ENDPOINT );
305
323
306
324
newConf .set (ENDPOINT , CENTRAL_ENDPOINT );
307
325
newConf .set (AWS_REGION , EU_WEST_1 );
308
326
newConf .setBoolean (ALLOW_REQUESTER_PAYS , true );
309
327
310
- Path filePath = new Path (PublicDatasetTestUtils
311
- .getRequesterPaysObject (newConf ));
312
- newFS = (S3AFileSystem ) filePath .getFileSystem (newConf );
313
-
314
- Assertions
315
- .assertThat (newFS .exists (filePath ))
316
- .describedAs ("Existence of path: " + filePath )
317
- .isTrue ();
328
+ assertRequesterPaysFileExistence (newConf );
318
329
}
319
330
320
331
@ Test
@@ -329,23 +340,68 @@ public void testCentralEndpointAndSameRegionAsBucket() throws Throwable {
329
340
ENDPOINT ,
330
341
AWS_REGION ,
331
342
ALLOW_REQUESTER_PAYS ,
332
- KEY_REQUESTER_PAYS_FILE );
343
+ KEY_REQUESTER_PAYS_FILE ,
344
+ FIPS_ENDPOINT );
333
345
334
346
removeBaseAndBucketOverrides (
335
347
DEFAULT_REQUESTER_PAYS_BUCKET_NAME ,
336
348
newConf ,
337
349
ENDPOINT ,
338
350
AWS_REGION ,
339
351
ALLOW_REQUESTER_PAYS ,
340
- KEY_REQUESTER_PAYS_FILE );
352
+ KEY_REQUESTER_PAYS_FILE ,
353
+ FIPS_ENDPOINT );
341
354
342
355
newConf .set (ENDPOINT , CENTRAL_ENDPOINT );
343
356
newConf .set (AWS_REGION , US_WEST_2 );
344
357
newConf .setBoolean (ALLOW_REQUESTER_PAYS , true );
345
358
359
+ assertRequesterPaysFileExistence (newConf );
360
+ }
361
+
362
+ @ Test
363
+ public void testCentralEndpointAndFipsForPublicBucket () throws Throwable {
364
+ describe ("Access public bucket using central endpoint and region "
365
+ + "same as that of the public bucket with fips enabled" );
366
+ final Configuration conf = getConfiguration ();
367
+ final Configuration newConf = new Configuration (conf );
368
+
369
+ removeBaseAndBucketOverrides (
370
+ newConf ,
371
+ ENDPOINT ,
372
+ AWS_REGION ,
373
+ ALLOW_REQUESTER_PAYS ,
374
+ KEY_REQUESTER_PAYS_FILE ,
375
+ FIPS_ENDPOINT );
376
+
377
+ removeBaseAndBucketOverrides (
378
+ DEFAULT_REQUESTER_PAYS_BUCKET_NAME ,
379
+ newConf ,
380
+ ENDPOINT ,
381
+ AWS_REGION ,
382
+ ALLOW_REQUESTER_PAYS ,
383
+ KEY_REQUESTER_PAYS_FILE ,
384
+ FIPS_ENDPOINT );
385
+
386
+ newConf .set (ENDPOINT , CENTRAL_ENDPOINT );
387
+ newConf .set (AWS_REGION , US_WEST_2 );
388
+ newConf .setBoolean (ALLOW_REQUESTER_PAYS , true );
389
+ newConf .setBoolean (FIPS_ENDPOINT , true );
390
+
391
+ assertRequesterPaysFileExistence (newConf );
392
+ }
393
+
394
+ /**
395
+ * Assert that the file exists on the requester pays public bucket.
396
+ *
397
+ * @param conf the configuration object.
398
+ * @throws IOException if file system operations encounter errors.
399
+ */
400
+ private void assertRequesterPaysFileExistence (Configuration conf )
401
+ throws IOException {
346
402
Path filePath = new Path (PublicDatasetTestUtils
347
- .getRequesterPaysObject (newConf ));
348
- newFS = (S3AFileSystem ) filePath .getFileSystem (newConf );
403
+ .getRequesterPaysObject (conf ));
404
+ newFS = (S3AFileSystem ) filePath .getFileSystem (conf );
349
405
350
406
Assertions
351
407
.assertThat (newFS .exists (filePath ))
@@ -364,9 +420,33 @@ public void testCentralEndpointAndNullRegionWithCRUD() throws Throwable {
364
420
removeBaseAndBucketOverrides (
365
421
newConf ,
366
422
ENDPOINT ,
367
- AWS_REGION );
423
+ AWS_REGION ,
424
+ FIPS_ENDPOINT );
425
+
426
+ newConf .set (ENDPOINT , CENTRAL_ENDPOINT );
427
+
428
+ newFS = new S3AFileSystem ();
429
+ newFS .initialize (getFileSystem ().getUri (), newConf );
430
+
431
+ assertOpsUsingNewFs ();
432
+ }
433
+
434
+ @ Test
435
+ public void testCentralEndpointAndNullRegionFipsWithCRUD () throws Throwable {
436
+ describe ("Access the test bucket using central endpoint and"
437
+ + " null region and fips enabled, perform file system CRUD operations" );
438
+ final Configuration conf = getConfiguration ();
439
+
440
+ final Configuration newConf = new Configuration (conf );
441
+
442
+ removeBaseAndBucketOverrides (
443
+ newConf ,
444
+ ENDPOINT ,
445
+ AWS_REGION ,
446
+ FIPS_ENDPOINT );
368
447
369
448
newConf .set (ENDPOINT , CENTRAL_ENDPOINT );
449
+ newConf .setBoolean (FIPS_ENDPOINT , true );
370
450
371
451
newFS = new S3AFileSystem ();
372
452
newFS .initialize (getFileSystem ().getUri (), newConf );
0 commit comments