コード例 #1
0
ファイル: ServiceProperties.cs プロジェクト: EmmaZhu/pshtest
        public static void DefaultServiceVersionClassCleanup()
        {
            ServiceCORSRule.ClearCorsRules(Constants.ServiceType.Blob);
            ServiceCORSRule.ClearCorsRules(Constants.ServiceType.Table);
            ServiceCORSRule.ClearCorsRules(Constants.ServiceType.Queue);
            ServiceCORSRule.ClearCorsRules(Constants.ServiceType.File);

            TestBase.TestClassCleanup();
        }
コード例 #2
0
ファイル: ServiceProperties.cs プロジェクト: EmmaZhu/pshtest
        public void GetServiceProperties_AllService_AllProperties()
        {
            //prepare the service properties to set and get
            PSCorsRule[] corsRules = CORSRuleUtil.GetRandomValidCORSRules(random.Next(1, 5));

            Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties serviceProperties = new Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties();
            serviceProperties.Clean();
            serviceProperties.Cors = new CorsProperties();

            foreach (var rule in corsRules)
            {
                CorsRule corsRule = new CorsRule()
                {
                    AllowedHeaders  = rule.AllowedHeaders,
                    AllowedOrigins  = rule.AllowedOrigins,
                    ExposedHeaders  = rule.ExposedHeaders,
                    MaxAgeInSeconds = rule.MaxAgeInSeconds,
                };
                SetAllowedMethods(corsRule, rule.AllowedMethods);
                serviceProperties.Cors.CorsRules.Add(corsRule);
            }
            serviceProperties.HourMetrics = new MetricsProperties("1.0");
            serviceProperties.HourMetrics.MetricsLevel    = MetricsLevel.ServiceAndApi;
            serviceProperties.HourMetrics.RetentionDays   = 1;
            serviceProperties.MinuteMetrics               = new MetricsProperties("1.0");
            serviceProperties.MinuteMetrics.MetricsLevel  = MetricsLevel.Service;
            serviceProperties.MinuteMetrics.RetentionDays = 3;

            serviceProperties.Logging = new LoggingProperties("1.0");
            serviceProperties.Logging.LoggingOperations = LoggingOperations.All;
            serviceProperties.Logging.RetentionDays     = 5;


            foreach (string servicetype in ValidServiceType)
            {
                Constants.ServiceType service = Constants.ServiceType.Blob;
                Enum.TryParse <Constants.ServiceType>(servicetype, true, out service);
                if (service == Constants.ServiceType.Blob) //only Blob support default service version
                {
                    serviceProperties.DefaultServiceVersion = "2017-04-17";

                    serviceProperties.DeleteRetentionPolicy               = new DeleteRetentionPolicy();
                    serviceProperties.DeleteRetentionPolicy.Enabled       = true;
                    serviceProperties.DeleteRetentionPolicy.RetentionDays = 10;
                }

                //Set Service Properties with XSCL API
                ServiceCORSRule.SetSerivceProperties(service, serviceProperties);

                //Get Service Properties with PowerShell
                PSSeriviceProperties properties = GetServicePropertiesFromPSH(service);

                //Validate Cors, metric, logging
                CORSRuleUtil.ValidateCORSRules(corsRules, properties.Cors);

                if (service != Constants.ServiceType.File) // File service don't support logging
                {
                    ExpectEqual(serviceProperties.Logging.Version, properties.Logging.Version, "Logging version");
                    ExpectEqual(serviceProperties.Logging.LoggingOperations.ToString(), properties.Logging.LoggingOperations.ToString(), "Logging Operations");
                    ExpectEqual(serviceProperties.Logging.RetentionDays.Value, properties.Logging.RetentionDays.Value, "Logging RetentionDays");
                }

                ExpectEqual(serviceProperties.HourMetrics.Version, properties.HourMetrics.Version, "HourMetrics Version");
                ExpectEqual(serviceProperties.HourMetrics.MetricsLevel.ToString(), properties.HourMetrics.MetricsLevel.ToString(), "HourMetrics MetricsLevel");
                ExpectEqual(serviceProperties.HourMetrics.RetentionDays.Value, properties.HourMetrics.RetentionDays.Value, "HourMetrics RetentionDays");

                ExpectEqual(serviceProperties.MinuteMetrics.Version, properties.MinuteMetrics.Version, "MinuteMetrics Version");
                ExpectEqual(serviceProperties.MinuteMetrics.MetricsLevel.ToString(), properties.MinuteMetrics.MetricsLevel.ToString(), "MinuteMetrics MetricsLevel");
                ExpectEqual(serviceProperties.MinuteMetrics.RetentionDays.Value, properties.MinuteMetrics.RetentionDays.Value, "MinuteMetrics RetentionDays");


                if (service == Constants.ServiceType.Blob)
                {
                    ExpectEqual(serviceProperties.DefaultServiceVersion, properties.DefaultServiceVersion, "DefaultServiceVersion");

                    ExpectEqual(serviceProperties.DeleteRetentionPolicy.Enabled.ToString(), properties.DeleteRetentionPolicy.Enabled.ToString(), "DeleteRetentionPolicy Enabled");
                    ExpectEqual(serviceProperties.DeleteRetentionPolicy.RetentionDays.Value, properties.DeleteRetentionPolicy.RetentionDays.Value, "DeleteRetentionPolicy RetentionDays");

                    serviceProperties.DeleteRetentionPolicy = null;
                    serviceProperties.DefaultServiceVersion = null;
                }
            }
        }