private async Task TestCorsRulesAsync(CloudBlobClient client, OperationContext context, IList <CorsRule> corsProps)
        {
            props.Cors.CorsRules.Clear();

            foreach (CorsRule rule in corsProps)
            {
                props.Cors.CorsRules.Add(rule);
            }

            await client.SetServicePropertiesAsync(props, null, context);

            TestHelper.AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync());
        }
Beispiel #2
0
        public async Task CloudBlobClientServerTimeoutAsync()
        {
            CloudBlobClient client = GenerateCloudBlobClient();

            string           timeout = null;
            OperationContext context = new OperationContext();

            context.SendingRequest += (sender, e) =>
            {
                IDictionary <string, string> query = HttpWebUtility.ParseQueryString(e.RequestUri.Query);
                if (!query.TryGetValue("timeout", out timeout))
                {
                    timeout = null;
                }
            };

            BlobRequestOptions options = new BlobRequestOptions();
            await client.GetServicePropertiesAsync(null, context);

            Assert.IsNull(timeout);
            await client.GetServicePropertiesAsync(options, context);

            Assert.IsNull(timeout);

            options.ServerTimeout = TimeSpan.FromSeconds(100);
            await client.GetServicePropertiesAsync(options, context);

            Assert.AreEqual("100", timeout);

            client.DefaultRequestOptions.ServerTimeout = TimeSpan.FromSeconds(90);
            await client.GetServicePropertiesAsync(null, context);

            Assert.AreEqual("90", timeout);
            await client.GetServicePropertiesAsync(options, context);

            Assert.AreEqual("100", timeout);

            options.ServerTimeout = null;
            await client.GetServicePropertiesAsync(options, context);

            Assert.AreEqual("90", timeout);

            options.ServerTimeout = TimeSpan.Zero;
            await client.GetServicePropertiesAsync(options, context);

            Assert.IsNull(timeout);
        }
 public static void MyClassInitialize(TestContext testContext)
 {
     client          = GenerateCloudBlobClient();
     startProperties = client.GetServicePropertiesAsync().Result;
 }
        public async Task CloudBlobTestAnalyticsRoundTripAsync()
        {
            props.Logging.LoggingOperations = LoggingOperations.Read | LoggingOperations.Write;
            props.Logging.RetentionDays     = 5;
            props.Logging.Version           = "1.0";

            props.HourMetrics.MetricsLevel  = MetricsLevel.Service;
            props.HourMetrics.RetentionDays = 6;
            props.HourMetrics.Version       = "1.0";

            props.MinuteMetrics.MetricsLevel  = MetricsLevel.Service;
            props.MinuteMetrics.RetentionDays = 6;
            props.MinuteMetrics.Version       = "1.0";

            props.DeleteRetentionPolicy.Enabled       = true;
            props.DeleteRetentionPolicy.RetentionDays = 8;

            props.Cors.CorsRules.Add(
                new CorsRule()
            {
                AllowedOrigins = new List <string>()
                {
                    "www.ab.com", "www.bc.com"
                },
                AllowedMethods  = CorsHttpMethods.Get | CorsHttpMethods.Put,
                MaxAgeInSeconds = 500,
                ExposedHeaders  =
                    new List <string>()
                {
                    "x-ms-meta-data*",
                    "x-ms-meta-source*",
                    "x-ms-meta-abc",
                    "x-ms-meta-bcd"
                },
                AllowedHeaders =
                    new List <string>()
                {
                    "x-ms-meta-data*",
                    "x-ms-meta-target*",
                    "x-ms-meta-xyz",
                    "x-ms-meta-foo"
                }
            });

            props.StaticWebsite.Enabled              = true;
            props.StaticWebsite.IndexDocument        = "myindex.html";
            props.StaticWebsite.ErrorDocument404Path = "errors/error/404error.html";

            await client.SetServicePropertiesAsync(props);

            TestHelper.AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync());
        }