@Test public void testSignPutUrlWithTimeExpired() throws Exception { testSignPutUrlWithTime(-getSignedUrlTimeout()); }
@Test public void testSignGetUrlWithTimeExpired() throws InterruptedException, IOException { testSignGetUrlWithTime(-getSignedUrlTimeout()); }
@Override protected Properties setupProperties() { Properties props = super.setupProperties(); setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); return props; }
@Test public void testSignPutUrl() 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); assertEquals(request.getFilters().size(), 0); Strings2.toString(view.utils().http().invoke(request).getPayload()); assertConsistencyAwareContainerSize(container, 1); } 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); } }
@Test public void testSignPutUrlWithTimeExpired() throws Exception { // Intentionally try with a timeout of 0. AWS signature v4 throws an error if // the timeout is negative. super.testSignPutUrlWithTime(/*timeout=*/ 0); } }
@Test public void testSignPutUrl() throws Exception { String name = "hello"; String text = "fooooooooooooooooooooooo"; Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("image/png").build(); String container = getContainerName(); try { HttpRequest request = view.getSigner().signPutBlob(container, blob); assertEquals(request.getFilters().size(), 0); Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream()); blob = view.getBlobStore().getBlob(container, name); assertThat(blob.getMetadata().getContentMetadata().getContentType()).isEqualTo("image/png"); } finally { returnContainer(container); } }
@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 testSignGetUrlWithTimeExpired() throws InterruptedException, IOException { // Intentionally try with a timeout of 0. AWS signature v4 throws an error if // the timeout is negative. super.testSignGetUrlWithTime(/*timeout=*/ 0); }
@Test public void testSignPutUrlWithTimeExpired() throws Exception { try { super.testSignPutUrlWithTimeExpired(); fail(); } catch (UnsupportedOperationException uoe) { throw new SkipException("not supported in Atmos", uoe); } } }
@Test public void testSignGetUrl() throws Exception { 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); assertEquals(request.getFilters().size(), 0); assertEquals(Strings2.toString(view.utils().http().invoke(request).getPayload()), text); } finally { returnContainer(container); } }
@Test public void testSignPutUrlWithTime() throws Exception { try { super.testSignPutUrlWithTime(); fail(); } catch (UnsupportedOperationException uoe) { throw new SkipException("not supported in Atmos", uoe); } }
public void testSignPutUrlWithTime(final long timeout) 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 { HttpRequest request = view.getSigner().signPutBlob(container, blob, 0); 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(); try { Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream()); fail("Temporary URL did not expire as expected"); } catch (AuthorizationException expected) { } } finally { returnContainer(container); } }
@Test public void testSignGetUrlWithTime() throws InterruptedException, IOException { try { super.testSignGetUrlWithTime(); failBecauseExceptionWasNotThrown(UnsupportedOperationException.class); } catch (UnsupportedOperationException uoe) { throw new SkipException("unsupported by B2", uoe); } }
@Test public void testSignPutUrlWithTimeExpired() throws Exception { try { super.testSignPutUrlWithTimeExpired(); failBecauseExceptionWasNotThrown(UnsupportedOperationException.class); } catch (UnsupportedOperationException uoe) { throw new SkipException("unsupported by B2", uoe); } } }
@Test public void testSignGetUrlOptions() throws Exception { 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, range(0, 1)); assertEquals(request.getFilters().size(), 0); assertEquals(Strings2.toString(view.utils().http().invoke(request).getPayload()), "fo"); } finally { returnContainer(container); } }
@Test public void testSignPutUrlWithTime() throws Exception { try { super.testSignPutUrlWithTime(); failBecauseExceptionWasNotThrown(UnsupportedOperationException.class); } catch (UnsupportedOperationException uoe) { throw new SkipException("unsupported by B2", uoe); } }
@Override protected Properties setupProperties() { Properties props = super.setupProperties(); setIfTestSystemPropertyPresent(props, CREDENTIAL_TYPE); return props; } }
@Test public void testSignGetUrl() throws Exception { 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); assertEquals(request.getFilters().size(), 0); assertEquals(Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream()), text); } finally { returnContainer(container); } }
@Test public void testSignRemoveUrl() throws Exception { 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().signRemoveBlob(container, name); assertEquals(request.getFilters().size(), 0); view.utils().http().invoke(request); assert !view.getBlobStore().blobExists(container, name); } finally { returnContainer(container); } } }