Examples of BucketLogging


Examples of org.jclouds.s3.domain.BucketLogging

@Test(groups = "unit", testName = "BindBucketLoggingToXmlPayloadTest")
public class BindBucketLoggingToXmlPayloadTest  extends BaseHandlerTest {

   public void testApplyInputStream() throws IOException {
     
      BucketLogging bucketLogging = new BucketLogging("mylogs", "access_log-", ImmutableSet
               .<Grant> of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"),
                        Permission.FULL_CONTROL)));
    
      String expected = Strings2.toStringAndClose(getClass().getResourceAsStream(
               "/bucket_logging.xml"));
View Full Code Here

Examples of org.jclouds.s3.domain.BucketLogging

   }

   public void testEnableBucketLoggingOwner() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(S3AsyncClient.class, "enableBucketLogging", String.class, BucketLogging.class);
      GeneratedHttpRequest request = processor
               .createRequest(method, ImmutableList.<Object> of("bucket", new BucketLogging("mylogs", "access_log-", ImmutableSet
                        .<Grant> of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL)))));

      assertRequestLineEquals(request, "PUT https://bucket." + url + "/?logging HTTP/1.1");
      assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
      assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/bucket_logging.xml")),
View Full Code Here

Examples of org.jclouds.s3.domain.BucketLogging

      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);
               }
            }
         });
View Full Code Here

Examples of org.jclouds.s3.domain.BucketLogging

@Test(groups = "unit", testName = "BucketLoggingHandlerTest")
public class BucketLoggingHandlerTest extends BaseHandlerTest {
   public void testApplyInputStream() {
      InputStream is = getClass().getResourceAsStream("/bucket_logging.xml");

      BucketLogging expected = new BucketLogging("mylogs", "access_log-", ImmutableSet.<Grant> of(new Grant(
            new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL)));
      BucketLoggingHandler handler = injector.getInstance(BucketLoggingHandler.class);
      BucketLogging result = factory.create(handler).parse(is);

      assertEquals(result.getTargetBucket(), expected.getTargetBucket());
      assertEquals(result.getTargetGrants(), expected.getTargetGrants());
      assertEquals(result.getTargetPrefix(), expected.getTargetPrefix());

   }
View Full Code Here

Examples of org.jclouds.s3.domain.BucketLogging

   private StringBuilder currentText = new StringBuilder();

   public BucketLogging getResult() {
      if (targetBucket == null)
         return null;
      return new BucketLogging(targetBucket, targetPrefix, targetGrants);
   }
View Full Code Here

Examples of org.jclouds.s3.domain.BucketLogging

*/
@Singleton
public class BindBucketLoggingToXmlPayload implements Binder {
   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
      BucketLogging from = (BucketLogging) payload;
      Properties outputProperties = new Properties();
      outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
      try {
         String stringPayload = generateBuilder(from).asString(outputProperties);
         request.setPayload(stringPayload);
View Full Code Here

Examples of org.jclouds.s3.domain.BucketLogging

   }

   public void testEnableBucketLoggingOwner() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(S3AsyncClient.class, "enableBucketLogging", String.class, BucketLogging.class);
      GeneratedHttpRequest request = processor
               .createRequest(method, ImmutableList.<Object> of("bucket", new BucketLogging("mylogs", "access_log-", ImmutableSet
                        .<Grant> of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL)))));

      assertRequestLineEquals(request, "PUT https://bucket." + url + "/?logging HTTP/1.1");
      assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
      assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/bucket_logging.xml")),
View Full Code Here

Examples of org.jclouds.s3.domain.BucketLogging

@Test(groups = "unit", testName = "BucketLoggingHandlerTest")
public class BucketLoggingHandlerTest extends BaseHandlerTest {
   public void testApplyInputStream() {
      InputStream is = getClass().getResourceAsStream("/bucket_logging.xml");

      BucketLogging expected = new BucketLogging("mylogs", "access_log-", ImmutableSet.<Grant> of(new Grant(
            new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL)));
      BucketLoggingHandler handler = injector.getInstance(BucketLoggingHandler.class);
      BucketLogging result = factory.create(handler).parse(is);

      assertEquals(result.getTargetBucket(), expected.getTargetBucket());
      assertEquals(result.getTargetGrants(), expected.getTargetGrants());
      assertEquals(result.getTargetPrefix(), expected.getTargetPrefix());

   }
View Full Code Here

Examples of org.jclouds.s3.domain.BucketLogging

   private StringBuilder currentText = new StringBuilder();

   public BucketLogging getResult() {
      if (targetBucket == null)
         return null;
      return new BucketLogging(targetBucket, targetPrefix, targetGrants);
   }
View Full Code Here

Examples of org.jclouds.s3.domain.BucketLogging

      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);
               }
            }
         });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.