mirror of https://github.com/apache/jclouds.git
added md5 test
This commit is contained in:
parent
a3a9bc3948
commit
e4b85db4b5
|
@ -77,6 +77,8 @@ public class TransientBlobRequestSignerTest extends RestClientTest<TransientAsyn
|
||||||
Blob blob = blobFactory.get().name("name").forSigning().contentLength(2l).contentMD5(new byte[] { 0, 2, 4, 8 })
|
Blob blob = blobFactory.get().name("name").forSigning().contentLength(2l).contentMD5(new byte[] { 0, 2, 4, 8 })
|
||||||
.contentType("text/plain").build();
|
.contentType("text/plain").build();
|
||||||
|
|
||||||
|
assertEquals(blob.getPayload().getContentMetadata().getContentMD5(), new byte[] { 0, 2, 4, 8 });
|
||||||
|
|
||||||
HttpRequest request = signer.signPutBlob("container", blob);
|
HttpRequest request = signer.signPutBlob("container", blob);
|
||||||
|
|
||||||
assertRequestLineEquals(request, "PUT http://localhost/container/name HTTP/1.1");
|
assertRequestLineEquals(request, "PUT http://localhost/container/name HTTP/1.1");
|
||||||
|
@ -88,6 +90,25 @@ public class TransientBlobRequestSignerTest extends RestClientTest<TransientAsyn
|
||||||
assertEquals(request.getFilters().size(), 0);
|
assertEquals(request.getFilters().size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSignPutBlobWithGenerate() throws ArrayIndexOutOfBoundsException, SecurityException,
|
||||||
|
IllegalArgumentException, NoSuchMethodException, IOException {
|
||||||
|
Blob blob = blobFactory.get().name("name").payload("foo").calculateMD5().contentType("text/plain").build();
|
||||||
|
|
||||||
|
assertEquals(blob.getPayload().getContentMetadata().getContentMD5(), new byte[] { -84, -67, 24, -37, 76, -62, -8,
|
||||||
|
92, -19, -17, 101, 79, -52, -60, -92, -40 });
|
||||||
|
|
||||||
|
HttpRequest request = signer.signPutBlob("container", blob);
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "PUT http://localhost/container/name HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(
|
||||||
|
request,
|
||||||
|
"Authorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\nContent-Length: 3\nContent-MD5: rL0Y20zC+Fzt72VPzMSk2A==\nContent-Type: text/plain\n");
|
||||||
|
assertContentHeadersEqual(request, "text/plain", null, null, null, (long) 3l, new byte[] { -84, -67, 24, -37, 76,
|
||||||
|
-62, -8, 92, -19, -17, 101, 79, -52, -60, -92, -40 });
|
||||||
|
|
||||||
|
assertEquals(request.getFilters().size(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
protected void setupFactory() throws IOException {
|
protected void setupFactory() throws IOException {
|
||||||
super.setupFactory();
|
super.setupFactory();
|
||||||
|
|
Loading…
Reference in New Issue