diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java index d6620b5df3..97f88621dc 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java @@ -37,6 +37,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Supplier; +import com.google.common.hash.HashCode; import com.google.inject.Module; /** @@ -83,11 +84,12 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest { @@ -85,8 +86,9 @@ public abstract class BaseBlobSignerExpectTest extends BaseRestClientExpectTest< @Test public void testSignPutBlob() throws Exception { + HashCode hashCode = HashCode.fromBytes(new byte[16]); BlobStore signPutBlob = requestsSendResponses(init()); - Blob blob = signPutBlob.blobBuilder("name").forSigning().contentLength(2l).contentMD5(new byte[] { 0, 2, 4, 8 }) + Blob blob = signPutBlob.blobBuilder("name").forSigning().contentLength(2l).contentMD5(hashCode) .contentType("text/plain").expires(new Date(1000)).build(); HttpRequest compare = putBlob(); compare.setPayload(blob.getPayload()); diff --git a/core/src/main/java/org/jclouds/io/ContentMetadataBuilder.java b/core/src/main/java/org/jclouds/io/ContentMetadataBuilder.java index 3e17f1c096..84cca64663 100644 --- a/core/src/main/java/org/jclouds/io/ContentMetadataBuilder.java +++ b/core/src/main/java/org/jclouds/io/ContentMetadataBuilder.java @@ -22,6 +22,7 @@ import org.jclouds.io.payloads.BaseImmutableContentMetadata; import org.jclouds.javax.annotation.Nullable; import com.google.common.base.Objects; +import com.google.common.base.Preconditions; import com.google.common.hash.HashCode; public class ContentMetadataBuilder { @@ -51,6 +52,7 @@ public class ContentMetadataBuilder { public ContentMetadataBuilder contentMD5(@Nullable HashCode contentMD5) { if (contentMD5 != null) { + Preconditions.checkArgument(contentMD5.bits() == 128, "MD5 hash must have 128 bits, was: %s", contentMD5.bits()); this.contentMD5 = contentMD5; } return this; diff --git a/drivers/gae/src/test/java/org/jclouds/gae/ConvertToGaeRequestTest.java b/drivers/gae/src/test/java/org/jclouds/gae/ConvertToGaeRequestTest.java index 21d0f3fc42..1f744d8e80 100644 --- a/drivers/gae/src/test/java/org/jclouds/gae/ConvertToGaeRequestTest.java +++ b/drivers/gae/src/test/java/org/jclouds/gae/ConvertToGaeRequestTest.java @@ -157,7 +157,7 @@ public class ConvertToGaeRequestTest { private void testHoot(HttpRequest request) throws IOException { request.getPayload().getContentMetadata().setContentType("text/plain"); - request.getPayload().getContentMetadata().setContentMD5(new byte[] { 1, 2, 3, 4 }); + request.getPayload().getContentMetadata().setContentMD5(new byte[16]); HTTPRequest gaeRequest = req.apply(request); StringBuilder builder = new StringBuilder(); @@ -166,7 +166,10 @@ public class ConvertToGaeRequestTest { } assertEquals(builder.toString(), // note content-length is prohibited in gae - "User-Agent: jclouds/1.0 urlfetch/1.4.3\nExpect: 100-continue\nContent-Type: text/plain\nContent-MD5: AQIDBA==\n"); + "User-Agent: jclouds/1.0 urlfetch/1.4.3\n" + + "Expect: 100-continue\n" + + "Content-Type: text/plain\n" + + "Content-MD5: AAAAAAAAAAAAAAAAAAAAAA==\n"); assertEquals(new String(gaeRequest.getPayload()), "hoot!"); } } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java index 71694bb837..8b436d30d1 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java @@ -63,6 +63,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; import com.google.inject.Module; + // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "unit", testName = "AWSS3AsyncClientTest") @@ -166,11 +167,13 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { Invokable method = method(AWSS3AsyncClient.class, "initiateMultipartUpload", String.class, ObjectMetadata.class, PutObjectOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", ObjectMetadataBuilder.create().key("foo") - .contentMD5(new byte[] { 1, 2, 3, 4 }).build())); + .contentMD5(new byte[16]).build())); assertRequestLineEquals(request, "POST https://bucket." + url + "/foo?uploads HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Content-MD5: AQIDBA==\nContent-Type: binary/octet-stream\nHost: bucket." - + url + "\n"); + assertNonPayloadHeadersEqual(request, + "Content-MD5: AAAAAAAAAAAAAAAAAAAAAA==\n" + + "Content-Type: binary/octet-stream\n" + + "Host: bucket." + url + "\n"); assertPayloadEquals(request, null, null, false); // as this is a payload-related command, but with no payload, be careful @@ -180,8 +183,11 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { assertRequestLineEquals(request, "POST https://bucket." + url + "/foo?uploads HTTP/1.1"); assertNonPayloadHeadersEqual(request, - "Authorization: AWS identity:Sp1FX4svL9P2u2bFJwroaYpSANo=\nContent-MD5: AQIDBA==\n" - + "Content-Type: binary/octet-stream\nDate: 2009-11-08T15:54:08.897Z\nHost: bucket." + url + "\n"); + "Authorization: AWS identity:972m/Bqn2L5FIaB+wWDeY83mGvU=\n" + + "Content-MD5: AAAAAAAAAAAAAAAAAAAAAA==\n" + + "Content-Type: binary/octet-stream\n" + + "Date: 2009-11-08T15:54:08.897Z\n" + + "Host: bucket." + url + "\n"); assertPayloadEquals(request, null, null, false); assertResponseParserClassEquals(method, request, UploadIdFromHttpResponseViaRegex.class); diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/AWSS3BlobSignerExpectTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/AWSS3BlobSignerExpectTest.java index eb9f30681e..60649a22b6 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/AWSS3BlobSignerExpectTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/AWSS3BlobSignerExpectTest.java @@ -82,7 +82,7 @@ public class AWSS3BlobSignerExpectTest extends S3BlobSignerExpectTest { .addHeader("Host", HOST) .addHeader("Expect", "100-continue") .addHeader("Date", "Thu, 05 Jun 2008 16:38:19 GMT") - .addHeader("Authorization", "AWS identity:j9Dy/lmmvlCKjA4lkqZenLxMkR4=").build(); + .addHeader("Authorization", "AWS identity:zM2oT+71KcoOSxv1SU5L12UXnT8=").build(); } @Override diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java index 240a0283ef..96ae9dab40 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java @@ -35,6 +35,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Supplier; +import com.google.common.hash.HashCode; import com.google.inject.Module; /** @@ -80,11 +81,12 @@ public class AzureBlobRequestSignerTest extends BaseAsyncClientTest