}
}
public void testACLManagementViaRestHeaders() throws Exception {
RestStorageService service = getStorageService(getCredentials());
StorageBucket bucket = createBucketForTest("testACLManagementViaRestHeaders");
AccessControlList publicHeaderAcl = null;
if (service instanceof GoogleStorageService) {
publicHeaderAcl = GSAccessControlList.REST_CANNED_PUBLIC_READ;
} else {
publicHeaderAcl = AccessControlList.REST_CANNED_PUBLIC_READ;
}
try {
// Try to create public object using HTTP header ACL settings.
String publicKey = "PublicObject";
StorageObject object = new StorageObject(publicKey);
object.setAcl(publicHeaderAcl);
object.setOwner(bucket.getOwner());
try {
service.putObject(bucket.getName(), object);
URL url = new URL("https://" + service.getEndpoint()
+ "/" + bucket.getName() + "/" + publicKey);
assertEquals("Expected public access (200)",
200, ((HttpURLConnection)url.openConnection()).getResponseCode());
} finally {
service.deleteObject(bucket.getName(), object.getKey());
}
} finally {
cleanupBucketForTest("testACLManagementViaRestHeaders");
}
}