Disable ETag checking for Google Cloud Storage

Google Cloud Storage ETag is opaque and not an MD5 hash.
pull/106/merge
Andrew Gaul 2015-12-12 17:45:41 +08:00
rodzic c45dde3cbe
commit e237ee9ebb
1 zmienionych plików z 9 dodań i 3 usunięć

Wyświetl plik

@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HostnameVerifier;
@ -58,6 +59,7 @@ import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.UploadPartRequest; import com.amazonaws.services.s3.model.UploadPartRequest;
import com.amazonaws.services.s3.model.UploadPartResult; import com.amazonaws.services.s3.model.UploadPartResult;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.ByteSource; import com.google.common.io.ByteSource;
import org.assertj.core.api.Fail; import org.assertj.core.api.Fail;
@ -79,6 +81,11 @@ public final class S3AwsSdkTest {
disableSslVerification(); disableSslVerification();
} }
/** Blobstores with opaque ETags. */
private static final Set<String> BLOBSTORE_OPAQUE_ETAG = ImmutableSet.of(
"azureblob",
"google-cloud-storage"
);
private static final ByteSource BYTE_SOURCE = ByteSource.wrap(new byte[1]); private static final ByteSource BYTE_SOURCE = ByteSource.wrap(new byte[1]);
private URI s3Endpoint; private URI s3Endpoint;
@ -100,9 +107,8 @@ public final class S3AwsSdkTest {
info.getBlobStore().createContainerInLocation(null, containerName); info.getBlobStore().createContainerInLocation(null, containerName);
String blobStoreType = context.unwrap().getProviderMetadata().getId(); String blobStoreType = context.unwrap().getProviderMetadata().getId();
if (blobStoreType.equals("azureblob")) { if (BLOBSTORE_OPAQUE_ETAG.contains(blobStoreType)) {
// AWK SDK checks that ETag matches Content-MD5 during PUT but // AWK SDK checks that ETag matches Content-MD5 during PUT
// Azure returns an opaque ETag.
System.setProperty( System.setProperty(
"com.amazonaws.services.s3.disablePutObjectMD5Validation", "com.amazonaws.services.s3.disablePutObjectMD5Validation",
"true"); "true");