Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
import java.util.List;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -154,10 +156,8 @@ public void testInvalidCredentials() {

// And run the tests given the invalid credentialsOverrider
runOperationsThatShouldFail("testInvalidCredentials", bucketClient);
if (!GCP_PROVIDER_ID.equals(harness.getProviderId())) {
runOperationsThatShouldNotFail("testInvalidCredentials", bucketClient);
}
}

private void runOperationsThatShouldFail(String testName, BucketClient bucketClient) {

Expand Down Expand Up @@ -347,13 +347,11 @@ public void testUpload_emptyKey() {

@Test
public void testUpload_emptyContent() {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
runUploadTests("testUpload_emptyContent", "conformance-tests/upload/emptyContent", new byte[]{}, false);
}

@Test
public void testUpload_happyPath() {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
runUploadTests("testUpload_happyPath", "conformance-tests/upload/happyPath", "This is test data".getBytes(), false);
}

Expand Down Expand Up @@ -881,7 +879,7 @@ public void testVersionedDelete_fileDoesNotExist() throws IOException {

@Test
public void testVersionedDelete() throws IOException {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
// Create the BucketClient
AbstractBlobStore blobStore = harness.createBlobStore(true, true, true);
BucketClient bucketClient = new BucketClient(blobStore);
Expand Down Expand Up @@ -1250,7 +1248,7 @@ private void verifyBlobCopy(BucketClient bucketClient, String originalKey, Strin

@Test
public void testList() throws IOException {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
// Create the BucketClient
AbstractBlobStore blobStore = harness.createBlobStore(true, true, false);
BucketClient bucketClient = new BucketClient(blobStore);
Expand Down Expand Up @@ -1800,7 +1798,7 @@ public void testMultipartUpload_unorderedMultipleParts() throws IOException {

@Test
public void testMultipartUpload_skippingNumbers() throws IOException {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
runMultipartUploadTest(new MultipartUploadTestConfig(
"skipping numbers", DEFAULT_MULTIPART_KEY_PREFIX + "skippingNumbers",
Map.of("456", "456"),
Expand Down Expand Up @@ -1847,7 +1845,7 @@ public void testMultipartUpload_nonExistentParts() throws IOException {

@Test
public void testMultipartUpload_badETag() throws IOException {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
runMultipartUploadTest(new MultipartUploadTestConfig(
"bad etag", DEFAULT_MULTIPART_KEY_PREFIX + "badETag",
Map.of("789", "456"),
Expand Down Expand Up @@ -1987,7 +1985,7 @@ public void testMultipartUpload_completeAnAbortedUpload(){

@Test
public void testMultipartUpload_withKms() throws IOException {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
String kmsKeyId = harness.getKmsKeyId();
Assumptions.assumeTrue(kmsKeyId != null && !kmsKeyId.isEmpty(), "KMS key ID not configured");

Expand All @@ -2006,7 +2004,6 @@ public void testMultipartUpload_withKms() throws IOException {
@Test
@Disabled
public void testTagging() throws IOException {

AbstractBlobStore blobStore = harness.createBlobStore(true, true, false);
BucketClient bucketClient = new BucketClient(blobStore);

Expand Down Expand Up @@ -2438,22 +2435,19 @@ private void safeDeleteBlobs(BucketClient bucketClient, String... keys){

@Test
public void testUploadWithKmsKey_happyPath() {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
String key = "conformance-tests/kms/upload-happy-path";
String kmsKeyId = harness.getKmsKeyId();
runUploadWithKmsKeyTest(key, kmsKeyId, "Test data with KMS encryption".getBytes());
}

@Test
public void testUploadWithKmsKey_nullKmsKeyId() {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
String key = "conformance-tests/kms/upload-null-key";
runUploadWithKmsKeyTest(key, null, "Test data without KMS".getBytes());
}

@Test
public void testUploadWithKmsKey_emptyKmsKeyId() {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
String key = "conformance-tests/kms/upload-empty-key";
runUploadWithKmsKeyTest(key, "", "Test data with empty KMS key".getBytes());
}
Expand Down Expand Up @@ -2496,7 +2490,6 @@ private void runUploadWithKmsKeyTest(String key, String kmsKeyId, byte[] content

@Test
public void testDownloadWithKmsKey() throws IOException {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
String key = "conformance-tests/kms/download-happy-path";
String kmsKeyId = harness.getKmsKeyId();
byte[] content = "Test data for KMS download".getBytes(StandardCharsets.UTF_8);
Expand Down Expand Up @@ -2534,7 +2527,6 @@ public void testDownloadWithKmsKey() throws IOException {

@Test
public void testRangedReadWithKmsKey() throws IOException {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
String key = "conformance-tests/kms/ranged-read";
String kmsKeyId = harness.getKmsKeyId();
runRangedReadWithKmsKeyTest(key, kmsKeyId);
Expand Down Expand Up @@ -2599,7 +2591,7 @@ private void runRangedReadWithKmsKeyTest(String key, String kmsKeyId) throws IOE

@Test
public void testPresignedUrlWithKmsKey_nullKmsKeyId() throws IOException {
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
Assumptions.assumeFalse(GCP_PROVIDER_ID.equals(harness.getProviderId()));
String key = "conformance-tests/kms/presigned-url-null-key";
Map<String, String> metadata = Map.of("key2", "value2");
byte[] content = "Test data for presigned URL without KMS".getBytes(StandardCharsets.UTF_8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import com.google.cloud.storage.StorageOptions;
import com.salesforce.multicloudj.blob.client.AbstractBlobStoreIT;
import com.salesforce.multicloudj.blob.driver.AbstractBlobStore;
import com.salesforce.multicloudj.blob.gcp.util.GcpBlobStoreTestUtil;
import com.salesforce.multicloudj.common.gcp.util.MockGoogleCredentialsFactory;
import com.salesforce.multicloudj.common.gcp.util.TestsUtilGcp;
import org.junit.jupiter.api.AfterEach;

import java.io.IOException;
import java.net.URI;
Expand All @@ -28,6 +30,25 @@ protected Harness createHarness() {
return new HarnessImpl();
}

/**
* Override cleanupTestEnvironment to add GCP-specific post-recording transformation.
* This transforms multipart upload URLs with UUIDs to regex patterns after recording.
*
* Post-recording transformation is necessary because WireMock's ScenarioProcessor runs
* after transformers during stopRecording() and tries to parse all URLs as URIs.
* If we transform URLs to regex patterns in a transformer, ScenarioProcessor will fail.
* Therefore, we transform the JSON files directly after recording has completed.
*/
@Override
@AfterEach
public void cleanupTestEnvironment() {
super.cleanupTestEnvironment();

// GCP-specific post-recording transformation for multipart URLs with UUIDs
// This runs after ScenarioProcessor has finished, so it can safely convert URLs to regex patterns
GcpBlobStoreTestUtil.transformMultipartStubFiles();
}

public static class HarnessImpl implements Harness {
int port = ThreadLocalRandom.current().nextInt(1000, 10000);

Expand Down Expand Up @@ -103,7 +124,7 @@ public int getPort() {

@Override
public String getKmsKeyId() {
return "projects/chameleon-jcloud/locations/us/keyRings/chameleon-test/cryptoKeys/chameleon-test";
return "projects/substrate-sdk-gcp-poc1/locations/us/keyRings/chameleon-test/cryptoKeys/chameleon-test";
}

@Override
Expand Down
Loading
Loading