public void testSignGetBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { HttpRequest request = signer.signGetBlob("container", "name"); assertRequestLineEquals(request, "GET http://storageUrl/container/name HTTP/1.1"); assertNonPayloadHeadersEqual(request, "X-Auth-Token: testtoken\n"); assertPayloadEquals(request, null, null, false); assertEquals(request.getFilters().size(), 0); }
public void testSignGetBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { HttpRequest request = signer.signGetBlob("container", "name"); assertRequestLineEquals( request, "GET https://accesspoint.atmosonline.com/rest/namespace/container/name HTTP/1.1"); assertNonPayloadHeadersEqual( request, "Accept: */*\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nx-emc-signature: Mhe5tqaKv04BlMvEjreNKkHHxzk=\nx-emc-uid: identity\n"); assertPayloadEquals(request, null, null, false); assertEquals(request.getFilters().size(), 0); }
/** Test that BlobRequestSigner creates expected URIs. */ public void testBlobRequestSigner() throws Exception { String containerName = "container"; String blobName = "blob"; URI endPoint = new URI( "http", "localhost", String.format("/transient/%s/%s", containerName, blobName), /*fragment=*/ null); BlobRequestSigner signer = context.getSigner(); HttpRequest request; HttpRequest expected; request = signer.signGetBlob(containerName, blobName); expected = HttpRequest.builder() .method("GET") .endpoint(endPoint) .headers(request.getHeaders()) .build(); assertEquals(expected, request); request = signer.signRemoveBlob(containerName, blobName); expected = HttpRequest.builder() .method("DELETE") .endpoint(endPoint) .headers(request.getHeaders()) .build(); assertEquals(expected, request); Blob blob = blobStore.blobBuilder(blobName).forSigning().build(); request = signer.signPutBlob(containerName, blob); expected = HttpRequest.builder() .method("PUT") .endpoint(endPoint) .headers(request.getHeaders()) .payload(new PhantomPayload()) .build(); assertEquals(expected, request); }