final String targetBucket = getContainerName();
try {
assertNull(getApi().getBucketLogging(bucketName));
setupAclForBucketLoggingTarget(targetBucket);
final BucketLogging logging = new BucketLogging(targetBucket, "access_log-",
ImmutableSet.<Grant> of(new Grant(new EmailAddressGrantee(StubS3AsyncClient.TEST_ACL_EMAIL),
Permission.FULL_CONTROL)));
getApi().enableBucketLogging(bucketName, logging);
assertConsistencyAware(new Runnable() {
public void run() {
try {
BucketLogging newLogging = getApi().getBucketLogging(bucketName);
assert newLogging !=null;
AccessControlList acl = new AccessControlList();
for (Grant grant : newLogging.getTargetGrants()) { // TODO: add permission
// checking features to
// bucketlogging
acl.addPermission(grant.getGrantee(), grant.getPermission());
}
// EmailAddressGrantee is replaced by a CanonicalUserGrantee, so we cannot test by
// email addr
assertTrue(acl.hasPermission(StubS3AsyncClient.TEST_ACL_ID, Permission.FULL_CONTROL), acl.toString());
assertEquals(logging.getTargetBucket(), newLogging.getTargetBucket());
assertEquals(logging.getTargetPrefix(), newLogging.getTargetPrefix());
} catch (Exception e) {
Throwables.propagateIfPossible(e);
}
}
});