Issue 64: eventual consistency acl doesn't always commit immediately

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1844 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-08-09 22:43:07 +00:00
parent 44eed3917f
commit 02d79627bf
1 changed files with 42 additions and 25 deletions

View File

@ -39,6 +39,7 @@ import org.jclouds.aws.s3.domain.S3Object;
import org.jclouds.aws.s3.domain.AccessControlList.GroupGranteeURI; import org.jclouds.aws.s3.domain.AccessControlList.GroupGranteeURI;
import org.jclouds.aws.s3.domain.AccessControlList.Permission; import org.jclouds.aws.s3.domain.AccessControlList.Permission;
import org.jclouds.aws.s3.options.PutObjectOptions; import org.jclouds.aws.s3.options.PutObjectOptions;
import org.jclouds.util.Utils;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -90,21 +91,30 @@ public class GetAccessControlListIntegrationTest extends S3IntegrationTest {
@Test @Test
void testPublicReadOnObject() throws InterruptedException, ExecutionException, TimeoutException, void testPublicReadOnObject() throws InterruptedException, ExecutionException, TimeoutException,
IOException { IOException {
String publicReadObjectKey = "public-read-acl"; final String publicReadObjectKey = "public-read-acl";
String bucketName = getBucketName(); final String bucketName = getBucketName();
try { try {
client.putObject(bucketName, new S3Object(publicReadObjectKey, ""), new PutObjectOptions() client.putObject(bucketName, new S3Object(publicReadObjectKey, ""), new PutObjectOptions()
.withAcl(CannedAccessPolicy.PUBLIC_READ)); .withAcl(CannedAccessPolicy.PUBLIC_READ));
AccessControlList acl = client.getObjectACL(bucketName, publicReadObjectKey).get(10, assertEventually(new Runnable() {
TimeUnit.SECONDS); public void run() {
try {
AccessControlList acl = client.getObjectACL(bucketName, publicReadObjectKey).get(
10, TimeUnit.SECONDS);
assertEquals(acl.getGrants().size(), 2);
assertEquals(acl.getPermissions(GroupGranteeURI.ALL_USERS).size(), 1);
assertTrue(acl.getOwner() != null);
String ownerId = acl.getOwner().getId();
assertTrue(acl.hasPermission(ownerId, Permission.FULL_CONTROL));
assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ));
} catch (Exception e) {
Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e);
}
}
});
assertEquals(acl.getGrants().size(), 2);
assertEquals(acl.getPermissions(GroupGranteeURI.ALL_USERS).size(), 1);
assertTrue(acl.getOwner() != null);
String ownerId = acl.getOwner().getId();
assertTrue(acl.hasPermission(ownerId, Permission.FULL_CONTROL));
assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ));
} finally { } finally {
returnBucket(bucketName); returnBucket(bucketName);
} }
@ -114,26 +124,33 @@ public class GetAccessControlListIntegrationTest extends S3IntegrationTest {
@Test @Test
void testPublicWriteOnObject() throws InterruptedException, ExecutionException, void testPublicWriteOnObject() throws InterruptedException, ExecutionException,
TimeoutException, IOException { TimeoutException, IOException {
String publicReadWriteObjectKey = "public-read-write-acl"; final String publicReadWriteObjectKey = "public-read-write-acl";
String bucketName = getBucketName(); final String bucketName = getBucketName();
try { try {
// Public Read-Write object // Public Read-Write object
client.putObject(bucketName, new S3Object(publicReadWriteObjectKey, ""), client.putObject(bucketName, new S3Object(publicReadWriteObjectKey, ""),
new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ_WRITE)); new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ_WRITE));
AccessControlList acl = client.getObjectACL(bucketName, publicReadWriteObjectKey).get(10, assertEventually(new Runnable() {
TimeUnit.SECONDS); public void run() {
try {
assertEquals(acl.getGrants().size(), 3); AccessControlList acl = client.getObjectACL(bucketName, publicReadWriteObjectKey)
assertEquals(acl.getPermissions(GroupGranteeURI.ALL_USERS).size(), 2); .get(10, TimeUnit.SECONDS);
assertTrue(acl.getOwner() != null); assertEquals(acl.getGrants().size(), 3);
String ownerId = acl.getOwner().getId(); assertEquals(acl.getPermissions(GroupGranteeURI.ALL_USERS).size(), 2);
assertTrue(acl.hasPermission(ownerId, Permission.FULL_CONTROL)); assertTrue(acl.getOwner() != null);
assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ)); String ownerId = acl.getOwner().getId();
assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.WRITE)); assertTrue(acl.hasPermission(ownerId, Permission.FULL_CONTROL));
assertFalse(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ_ACP)); assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ));
assertFalse(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.WRITE_ACP)); assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.WRITE));
assertFalse(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.FULL_CONTROL)); assertFalse(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ_ACP));
assertFalse(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.WRITE_ACP));
assertFalse(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.FULL_CONTROL));
} catch (Exception e) {
Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e);
}
}
});
} finally { } finally {
returnBucket(bucketName); returnBucket(bucketName);
} }