public void EnableLoggingInvalidTargetBucketNameTest()
 {
     foreach (var invalidBucketName in OssTestUtils.InvalidBucketNamesList)
     {
         try
         {
             var sblRequest = new SetBucketLoggingRequest(_bucketName, invalidBucketName, LogPrefix);
             _ossClient.SetBucketLogging(sblRequest);
             Assert.Fail("Set Bucket logging should not pass with invalid target bucket name");
         }
         catch (ArgumentException)
         {
             Assert.IsTrue(true);
         }
         finally
         {
             _ossClient.DeleteBucketLogging(_bucketName);
         }
     }
 }
 public void EnableLoggingInvalidPrefixNameTest()
 {
     Parallel.ForEach(OssTestUtils.InvalidLoggingPrefixNamesList, invalidPrefix =>
     {
         try
         {
             var sblRequest = new SetBucketLoggingRequest(_bucketName, _bucketName, invalidPrefix);
             _ossClient.SetBucketLogging(sblRequest);
             Assert.Fail("Set Bucket logging should not pass with invalid logging prefix {0}", invalidPrefix);
         }
         catch (ArgumentException)
         {
             Assert.IsTrue(true);
         }
         finally
         {
             _ossClient.DeleteBucketLogging(_bucketName);
         }
     });
 }
 public void EnableLoggingTest()
 {
     var sblRequest = new SetBucketLoggingRequest(_bucketName, _bucketName, LogPrefix);
     try
     {
         _ossClient.SetBucketLogging(sblRequest);
         OssTestUtils.WaitForCacheExpire();
         var blResponse = _ossClient.GetBucketLogging(_bucketName);
         Assert.AreEqual(_bucketName, blResponse.TargetBucket);
         Assert.AreEqual(LogPrefix, blResponse.TargetPrefix);
     }
     catch (OssException e)
     {
         Assert.Fail(e.Message);
     }
     finally
     {
         _ossClient.DeleteBucketLogging(_bucketName);
         _ossClient.GetBucketLogging(_bucketName);
     }
 }
        public void EnableLoggingNonExistTargetBucketNameTest()
        {
            //generate the target bucket name
            var targetBucketName = OssTestUtils.GetBucketName(_className);
            //target bucket should not exist
            Assert.IsFalse(OssTestUtils.BucketExists(_ossClient, targetBucketName));

            var sblRequest = new SetBucketLoggingRequest(_bucketName, targetBucketName, LogPrefix);
            try
            {
                _ossClient.SetBucketLogging(sblRequest);
                Assert.Fail("Set Bucket logging should not pass with non exist target bucket name");

            }
            catch (OssException e)
            {
                Assert.AreEqual(OssErrorCode.InvalidTargetBucketForLogging, e.ErrorCode);
            }
            finally
            {
                _ossClient.DeleteBucketLogging(_bucketName);
            }
        }
 public static Task SetBucketLoggingAsync(this IOss client, SetBucketLoggingRequest setBucketLoggingRequest)
 {
     return(Task.Factory.StartNew(() => client.SetBucketLogging(setBucketLoggingRequest)));
 }