public void GetCORSRuleWithInvalidCredential() { Constants.ServiceType serviceType = GetRandomServiceType(); Test.Assert(!CommandAgent.GetAzureStorageCORSRules(serviceType), "Get CORS rules with invalid credential should fail."); CheckErrorMessage(); }
public void ChangeCORSRules() { Constants.ServiceType serviceType = GetRandomServiceType(); try { PSCorsRule[] corsRules = CORSRuleUtil.GetRandomValidCORSRules(random.Next(1, 5)); Test.Assert(CommandAgent.SetAzureStorageCORSRules(serviceType, corsRules), "Set cors rule to {0} service should succeed", serviceType); Test.Assert(CommandAgent.GetAzureStorageCORSRules(serviceType), "Get CORS rule of {0} service should succeed.", serviceType); PSCorsRule[] newCorsRules = GetCORSRules(); CORSRuleUtil.ValidateCORSRules(corsRules, newCorsRules); foreach (var corsRule in newCorsRules) { switch (random.Next(0, 5)) { case 0: corsRule.AllowedHeaders = CORSRuleUtil.GetRandomHeaders(); break; case 1: corsRule.AllowedMethods = CORSRuleUtil.GetRandomMethods(); break; case 2: corsRule.AllowedOrigins = CORSRuleUtil.GetRandomOrigins(); break; case 3: corsRule.ExposedHeaders = CORSRuleUtil.GetRandomHeaders(); break; case 4: corsRule.MaxAgeInSeconds = random.Next(1, 1000); break; } } Test.Assert(CommandAgent.SetAzureStorageCORSRules(serviceType, newCorsRules), "Set cors rule to {0} service should succeed", serviceType); Test.Assert(CommandAgent.GetAzureStorageCORSRules(serviceType), "Set cors rule of {0} service should succeed", serviceType); PSCorsRule[] actualCORSRules = GetCORSRules(); CORSRuleUtil.ValidateCORSRules(newCorsRules, actualCORSRules); } finally { ClearCorsRules(serviceType); } }
private void ValidateRemoveCORSRule(Constants.ServiceType serviceType) { Test.Assert(CommandAgent.RemoveAzureStorageCORSRules(serviceType), "Remove CORS rules of {0} service should succeed.", serviceType); Test.Assert(CommandAgent.GetAzureStorageCORSRules(serviceType), "Get CORS rules of {0} service should succeed.", serviceType); PSCorsRule[] actualCORSRule = GetCORSRules(); Test.Assert(0 == actualCORSRule.Length, "There should be 0 CORS rule after removing. Actually there are {0} CORS rule(s)", actualCORSRule.Length); }
public void GetCORSRulesNegativeTest() { if (lang == Language.PowerShell) { Test.Assert(!CommandAgent.GetAzureStorageCORSRules(Constants.ServiceType.InvalidService), "Get CORS rules of invalid service type should fail."); ExpectedContainErrorMessage(string.Format("Unable to match the identifier name {0} to a valid enumerator name. Specify one of the following enumerator names and try again:", Constants.ServiceType.InvalidService.ToString())); } else { Test.Assert(!CommandAgent.GetAzureStorageCORSRules(Constants.ServiceType.InvalidService), "Get CORS rules of invalid service type should fail."); ExpectedContainErrorMessage(string.Format("error: unknown option `--{0}'", Constants.ServiceType.InvalidService.ToString().ToLower())); } }
private void ValidateCORSRuleSetGet(PSCorsRule[] corsRules) { Constants.ServiceType serviceType = GetRandomServiceType(); try { Test.Assert(CommandAgent.SetAzureStorageCORSRules(serviceType, corsRules), "Set cors rule to {0} service should succeed", serviceType); Test.Assert(CommandAgent.GetAzureStorageCORSRules(serviceType), "Get CORS rules of {0} service should succeed", serviceType); CORSRuleUtil.ValidateCORSRules(corsRules, GetCORSRules()); } finally { ClearCorsRules(serviceType); } }
private void OverwriteCORSRules(Action <Constants.ServiceType> setCORSRules, Constants.ServiceType serviceType) { try { setCORSRules(serviceType); PSCorsRule[] newCorsRules = CORSRuleUtil.GetRandomValidCORSRules(random.Next(1, 5)); Test.Assert(CommandAgent.SetAzureStorageCORSRules(serviceType, newCorsRules), "Set cors rule to blob service should succeed"); Test.Assert(CommandAgent.GetAzureStorageCORSRules(serviceType), "Get cors rules of blob service should succeed."); PSCorsRule[] acturalRules = GetCORSRules(); CORSRuleUtil.ValidateCORSRules(newCorsRules, acturalRules); } finally { ClearCorsRules(serviceType); } }