4242import java .io .IOException ;
4343import java .io .InputStream ;
4444import java .io .OutputStream ;
45+ import java .util .Collections ;
46+ import java .util .List ;
4547import java .net .HttpURLConnection ;
4648import java .net .URL ;
4749import java .nio .charset .StandardCharsets ;
@@ -89,6 +91,11 @@ public interface Harness extends AutoCloseable {
8991
9092 // Returns the KMS key ID for encryption tests (provider-specific)
9193 String getKmsKeyId ();
94+
95+ // Returns list of WireMock extension class names to register (optional)
96+ default List <String > getWiremockExtensions () {
97+ return Collections .emptyList ();
98+ }
9299 }
93100
94101 protected abstract Harness createHarness ();
@@ -103,7 +110,13 @@ public interface Harness extends AutoCloseable {
103110 @ BeforeAll
104111 public void initializeWireMockServer () {
105112 harness = createHarness ();
106- TestsUtil .startWireMockServer ("src/test/resources" , harness .getPort ());
113+ List <String > extensions = harness .getWiremockExtensions ();
114+ if (extensions .isEmpty ()) {
115+ TestsUtil .startWireMockServer ("src/test/resources" , harness .getPort ());
116+ } else {
117+ TestsUtil .startWireMockServer ("src/test/resources" , harness .getPort (),
118+ extensions .toArray (new String [0 ]));
119+ }
107120 }
108121
109122 /**
@@ -347,13 +360,11 @@ public void testUpload_emptyKey() {
347360
348361 @ Test
349362 public void testUpload_emptyContent () {
350- Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
351363 runUploadTests ("testUpload_emptyContent" , "conformance-tests/upload/emptyContent" , new byte []{}, false );
352364 }
353365
354366 @ Test
355367 public void testUpload_happyPath () {
356- Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
357368 runUploadTests ("testUpload_happyPath" , "conformance-tests/upload/happyPath" , "This is test data" .getBytes (), false );
358369 }
359370
@@ -477,6 +488,7 @@ public void testVersionedDownload_happy() throws IOException {
477488
478489 @ Test
479490 public void testVersionedDownload_noVersionId () throws IOException {
491+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
480492 runVersionedDownloadTests ("no versionId download" ,
481493 "conformance-tests/versioned_download_no_versionId" ,
482494 "conformance-tests/versioned_download_no_versionId" ,
@@ -1471,6 +1483,7 @@ public void testListPage() throws IOException {
14711483
14721484 @ Test
14731485 public void testGetMetadata () throws IOException {
1486+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()), "testGetMetadata: GCP metadata etag mismatch in replay mode" );
14741487
14751488 class TestConfig {
14761489 final String testName ;
@@ -1800,7 +1813,7 @@ public void testMultipartUpload_unorderedMultipleParts() throws IOException {
18001813
18011814 @ Test
18021815 public void testMultipartUpload_skippingNumbers () throws IOException {
1803- Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
1816+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()), "testMultipartUpload_skippingNumbers: GCP etag mismatch in replay mode" );
18041817 runMultipartUploadTest (new MultipartUploadTestConfig (
18051818 "skipping numbers" , DEFAULT_MULTIPART_KEY_PREFIX + "skippingNumbers" ,
18061819 Map .of ("456" , "456" ),
@@ -1847,7 +1860,7 @@ public void testMultipartUpload_nonExistentParts() throws IOException {
18471860
18481861 @ Test
18491862 public void testMultipartUpload_badETag () throws IOException {
1850- Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
1863+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
18511864 runMultipartUploadTest (new MultipartUploadTestConfig (
18521865 "bad etag" , DEFAULT_MULTIPART_KEY_PREFIX + "badETag" ,
18531866 Map .of ("789" , "456" ),
@@ -1987,7 +2000,7 @@ public void testMultipartUpload_completeAnAbortedUpload(){
19872000
19882001 @ Test
19892002 public void testMultipartUpload_withKms () throws IOException {
1990- Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
2003+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()), "testMultipartUpload_withKms: GCP multipart list parts issue in replay mode" );
19912004 String kmsKeyId = harness .getKmsKeyId ();
19922005 Assumptions .assumeTrue (kmsKeyId != null && !kmsKeyId .isEmpty (), "KMS key ID not configured" );
19932006
@@ -2006,6 +2019,7 @@ public void testMultipartUpload_withKms() throws IOException {
20062019 @ Test
20072020 @ Disabled
20082021 public void testTagging () throws IOException {
2022+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
20092023
20102024 AbstractBlobStore blobStore = harness .createBlobStore (true , true , false );
20112025 BucketClient bucketClient = new BucketClient (blobStore );
@@ -2057,28 +2071,32 @@ public void testTagging() throws IOException {
20572071 private static final String PRESIGNED_BLOB_UPLOAD_PREFIX = "conformance-tests/presignedUploadUrls/" ;
20582072 private static final String PRESIGNED_BLOB_DOWNLOAD_PREFIX = "conformance-tests/presignedDownloadUrls/" ;
20592073
2060- // @Test
2074+ @ Test
20612075 public void testGeneratePresignedUploadUrl_happyPathWithNoMetadataOrTags () throws IOException {
2076+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
20622077 String key = PRESIGNED_BLOB_UPLOAD_PREFIX + "happyPathWithNoMetadataOrTags" ;
20632078 runPresignedUploadTest (key , Duration .ofHours (10 ), null , null , null , null , null );
20642079 }
20652080
2066- // @Test
2081+ @ Test
20672082 public void testGeneratePresignedUploadUrl_happyPathWithMetadataButWithNoTags () throws IOException {
2083+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
20682084 String key = PRESIGNED_BLOB_UPLOAD_PREFIX + "happyPathWithMetadataButWithNoTags" ;
20692085 Map <String , String > metadata = Map .of ("key1" , "value1" , "key2" , "value2" );
20702086 runPresignedUploadTest (key , Duration .ofHours (10 ), null , metadata , metadata , null , null );
20712087 }
20722088
2073- // @Test
2089+ @ Test
20742090 public void testGeneratePresignedUploadUrl_happyPathWithNoMetadataButWithTags () throws IOException {
2091+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
20752092 String key = PRESIGNED_BLOB_UPLOAD_PREFIX + "happyPathWithNoMetadataButWithTags" ;
20762093 Map <String , String > tags = Map .of ("tag1" , "tagValue1" , "tag2" , "tagValue2" );
20772094 runPresignedUploadTest (key , Duration .ofHours (10 ), null , null , null , tags , tags );
20782095 }
20792096
2080- // @Test
2097+ @ Test
20812098 public void testGeneratePresignedUploadUrl_happyPathWithBothMetadataAndTags () throws IOException {
2099+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
20822100 String key = PRESIGNED_BLOB_UPLOAD_PREFIX + "happyPathWithBothMetadataAndTags" ;
20832101 Map <String , String > metadata = Map .of ("key3" , "value3" , "key4" , "value4" );
20842102 Map <String , String > tags = Map .of ("tag3" , "tagValue3" , "tag4" , "tagValue4" );
@@ -2216,8 +2234,9 @@ private void runPresignedUploadTest(String key,
22162234 }
22172235 }
22182236
2219- // @Test
2237+ @ Test
22202238 void testGeneratePresignedDownloadUrl_happyPath () throws IOException {
2239+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
22212240 String key = PRESIGNED_BLOB_DOWNLOAD_PREFIX + "happyPath" ;
22222241 runPresignedDownloadTest (key , true , Duration .ofHours (6 ), null );
22232242 }
@@ -2438,22 +2457,20 @@ private void safeDeleteBlobs(BucketClient bucketClient, String... keys){
24382457
24392458 @ Test
24402459 public void testUploadWithKmsKey_happyPath () {
2441- Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
24422460 String key = "conformance-tests/kms/upload-happy-path" ;
24432461 String kmsKeyId = harness .getKmsKeyId ();
2462+ Assumptions .assumeTrue (kmsKeyId != null && !kmsKeyId .isEmpty (), "KMS key ID not configured" );
24442463 runUploadWithKmsKeyTest (key , kmsKeyId , "Test data with KMS encryption" .getBytes ());
24452464 }
24462465
24472466 @ Test
24482467 public void testUploadWithKmsKey_nullKmsKeyId () {
2449- Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
24502468 String key = "conformance-tests/kms/upload-null-key" ;
24512469 runUploadWithKmsKeyTest (key , null , "Test data without KMS" .getBytes ());
24522470 }
24532471
24542472 @ Test
24552473 public void testUploadWithKmsKey_emptyKmsKeyId () {
2456- Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
24572474 String key = "conformance-tests/kms/upload-empty-key" ;
24582475 runUploadWithKmsKeyTest (key , "" , "Test data with empty KMS key" .getBytes ());
24592476 }
@@ -2496,9 +2513,9 @@ private void runUploadWithKmsKeyTest(String key, String kmsKeyId, byte[] content
24962513
24972514 @ Test
24982515 public void testDownloadWithKmsKey () throws IOException {
2499- Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
25002516 String key = "conformance-tests/kms/download-happy-path" ;
25012517 String kmsKeyId = harness .getKmsKeyId ();
2518+ Assumptions .assumeTrue (kmsKeyId != null && !kmsKeyId .isEmpty (), "KMS key ID not configured" );
25022519 byte [] content = "Test data for KMS download" .getBytes (StandardCharsets .UTF_8 );
25032520 AbstractBlobStore blobStore = harness .createBlobStore (true , true , false );
25042521 BucketClient bucketClient = new BucketClient (blobStore );
@@ -2534,9 +2551,9 @@ public void testDownloadWithKmsKey() throws IOException {
25342551
25352552 @ Test
25362553 public void testRangedReadWithKmsKey () throws IOException {
2537- Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
25382554 String key = "conformance-tests/kms/ranged-read" ;
25392555 String kmsKeyId = harness .getKmsKeyId ();
2556+ Assumptions .assumeTrue (kmsKeyId != null && !kmsKeyId .isEmpty (), "KMS key ID not configured" );
25402557 runRangedReadWithKmsKeyTest (key , kmsKeyId );
25412558 }
25422559
@@ -2599,7 +2616,7 @@ private void runRangedReadWithKmsKeyTest(String key, String kmsKeyId) throws IOE
25992616
26002617 @ Test
26012618 public void testPresignedUrlWithKmsKey_nullKmsKeyId () throws IOException {
2602- Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()));
2619+ Assumptions .assumeFalse (GCP_PROVIDER_ID .equals (harness .getProviderId ()), "testPresignedUrlWithKmsKey_nullKmsKeyId: GCP signing key issue" );
26032620 String key = "conformance-tests/kms/presigned-url-null-key" ;
26042621 Map <String , String > metadata = Map .of ("key2" , "value2" );
26052622 byte [] content = "Test data for presigned URL without KMS" .getBytes (StandardCharsets .UTF_8 );
0 commit comments