@Override protected Properties setupProperties() { Properties props = super.setupProperties(); setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); return props; }
@Test(groups = "live", dependsOnMethods = "testPublicAccess") public void testPublicAccessInNonDefaultLocation() throws InterruptedException, MalformedURLException, IOException { Location nonDefault = findNonDefaultLocationOrSkip(view.getBlobStore(), defaultLocation); String payload = "my data"; runCreateContainerInLocation(payload, nonDefault); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testPublicAccess() throws MalformedURLException, InterruptedException, IOException { super.testPublicAccess(); } }
private void runCreateContainerInLocation(String payload, Location nonDefault) throws InterruptedException, IOException { String blobName = "hello"; BlobStore blobStore = view.getBlobStore(); final String containerName = getScratchContainerName(); try { Logger.getAnonymousLogger().info( String.format("creating public container %s in location %s", containerName, nonDefault.getId())); blobStore.createContainerInLocation(nonDefault, containerName, publicRead()); assertConsistencyAwareContainerExists(containerName); assertConsistencyAwareContainerInLocation(containerName, nonDefault); blobStore.putBlob(containerName, blobStore.blobBuilder(blobName).payload(payload).build()); assertConsistencyAwareContainerSize(containerName, 1); BlobMetadata metadata = view.getBlobStore().blobMetadata(containerName, blobName); assertEquals(Strings2.toStringAndClose(view.utils().http().get(metadata.getPublicUri())), payload); assertConsistencyAwareBlobInLocation(containerName, blobName, nonDefault); } finally { // this container is now public, so we can't reuse it directly recycleContainer(containerName); } }
private void runCreateContainerInLocation(String payload, Location nonDefault) throws InterruptedException, IOException { String blobName = "hello"; BlobStore blobStore = view.getBlobStore(); final String containerName = getScratchContainerName(); try { Logger.getAnonymousLogger().info( String.format("creating public container %s in location %s", containerName, nonDefault.getId())); blobStore.createContainerInLocation(nonDefault, containerName, publicRead()); assertConsistencyAwareContainerExists(containerName); assertConsistencyAwareContainerInLocation(containerName, nonDefault); blobStore.putBlob(containerName, blobStore.blobBuilder(blobName).payload(payload).build()); assertConsistencyAwareContainerSize(containerName, 1); BlobMetadata metadata = view.getBlobStore().blobMetadata(containerName, blobName); assertEquals(Strings2.toStringAndClose(view.utils().http().get(metadata.getPublicUri())), payload); assertConsistencyAwareBlobInLocation(containerName, blobName, nonDefault); } finally { // this container is now public, so we can't reuse it directly recycleContainerAndAddToPool(containerName); } } }
@Test(groups = "live") public void testPublicAccess() throws InterruptedException, MalformedURLException, IOException { final String containerName = getScratchContainerName(); try { view.getBlobStore().createContainerInLocation(null, containerName, publicRead()); assertConsistencyAwareContainerExists(containerName); defaultLocation = Iterables.find(view.getBlobStore().list(), new Predicate<StorageMetadata>() { @Override public boolean apply(@Nullable StorageMetadata input) { return input.getName().equals(containerName); } }).getLocation(); view.getBlobStore().putBlob(containerName, view.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build()); assertConsistencyAwareContainerSize(containerName, 1); BlobMetadata metadata = view.getBlobStore().blobMetadata(containerName, "hello"); assertNotNull(metadata.getPublicUri(), metadata.toString()); SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class); Predicate<HostAndPort> socketTester = retry(socketOpen, 60, 5, SECONDS); int port = metadata.getPublicUri().getPort(); HostAndPort hostAndPort = HostAndPort.fromParts(metadata.getPublicUri().getHost(), port != -1 ? port : 80); assertTrue(socketTester.apply(hostAndPort), metadata.getPublicUri().toString()); assertEquals(Strings2.toStringAndClose(view.utils().http().get(metadata.getPublicUri())), TEST_STRING); } finally { // this container is now public, so we can't reuse it directly recycleContainerAndAddToPool(containerName); } }
@Test(groups = "live") public void testPublicAccess() throws InterruptedException, MalformedURLException, IOException { final String containerName = getScratchContainerName(); try { view.getBlobStore().createContainerInLocation(null, containerName, publicRead()); assertConsistencyAwareContainerExists(containerName); defaultLocation = Iterables.find(view.getBlobStore().list(), new Predicate<StorageMetadata>() { @Override public boolean apply(@Nullable StorageMetadata input) { return input.getName().equals(containerName); } }).getLocation(); view.getBlobStore().putBlob(containerName, view.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build()); assertConsistencyAwareContainerSize(containerName, 1); BlobMetadata metadata = view.getBlobStore().blobMetadata(containerName, "hello"); assert metadata.getPublicUri() != null : metadata; assertEquals(Strings2.toStringAndClose(view.utils().http().get(metadata.getPublicUri())), TEST_STRING); } finally { // this container is now public, so we can't reuse it directly recycleContainer(containerName); } }
@Test(groups = "live", dependsOnMethods = "testPublicAccess") public void testPublicAccessInNonDefaultLocationWithBigBlob() throws InterruptedException, MalformedURLException, IOException { Location nonDefault = findNonDefaultLocationOrSkip(view.getBlobStore(), defaultLocation); String payload = Strings.repeat("a", 1024 * 1024); // 1MB runCreateContainerInLocation(payload, nonDefault); }
@Override protected Properties setupProperties() { Properties props = super.setupProperties(); setIfTestSystemPropertyPresent(props, CREDENTIAL_TYPE); return props; } }
@Override @Test(groups = {"live", "fails-on-s3proxy"}) public void testPublicAccess() throws InterruptedException, MalformedURLException, IOException { super.testPublicAccess(); }
@Test(groups = "live", dependsOnMethods = "testPublicAccess") public void testPublicAccessInNonDefaultLocation() throws InterruptedException, MalformedURLException, IOException { Location nonDefault = findNonDefaultLocationOrSkip(view.getBlobStore(), defaultLocation); String payload = "my data"; runCreateContainerInLocation(payload, nonDefault); }
@Override protected Properties setupProperties() { TestProperties.setGoogleCredentialsFromJson(provider); return TestProperties.apply(provider, super.setupProperties()); } }
@Test(groups = "live", dependsOnMethods = "testPublicAccess") public void testPublicAccessInNonDefaultLocationWithBigBlob() throws InterruptedException, MalformedURLException, IOException { Location nonDefault = findNonDefaultLocationOrSkip(view.getBlobStore(), defaultLocation); String payload = Strings.repeat("a", 1024 * 1024); // 1MB runCreateContainerInLocation(payload, nonDefault); }