@Test public void testSignGetUrlWithTimeExpired() throws InterruptedException, IOException { testSignGetUrlWithTime(-getSignedUrlTimeout()); }
@Test public void testSignPutUrlWithTimeExpired() throws Exception { testSignPutUrlWithTime(-getSignedUrlTimeout()); }
@Test public void testSignPutUrlWithTime() throws Exception { String name = "hello"; String text = "fooooooooooooooooooooooo"; Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build(); String container = getContainerName(); try { HttpRequest request = view.getSigner().signPutBlob(container, blob, getSignedUrlTimeout()); assertEquals(request.getFilters().size(), 0); // Strip Expect: 100-continue to make actual responses visible, since // Java 7+ will throw a ProtocolException instead of setting the response code: // http://www.docjar.com/html/api/sun/net/www/protocol/http/HttpURLConnection.java.html#1021 request = request.toBuilder().removeHeader(EXPECT).build(); Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream()); } finally { returnContainer(container); } }
@Test public void testSignGetUrlWithTime() throws InterruptedException, IOException { String name = "hello"; String text = "fooooooooooooooooooooooo"; Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build(); String container = getContainerName(); try { view.getBlobStore().putBlob(container, blob); assertConsistencyAwareContainerSize(container, 1); HttpRequest request = view.getSigner().signGetBlob(container, name, getSignedUrlTimeout()); assertEquals(request.getFilters().size(), 0); assertEquals(Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream()), text); } finally { returnContainer(container); } }