public void RuleNameReservedUse() { Assert.Throws <ArgumentException>(() => { var list = new CorsRules(); list.Add(new CorsRule( "b2-123456", new List <string> { "https" }, new List <string> { "b2_download_file_by_id", "b2_download_file_by_name" }, 3600) { AllowedHeaders = new List <string> { "range" }, ExposeHeaders = new List <string> { "x-bz-content-sha1" }, } ); }); }
public void UniqueRuleName() { Assert.Throws <InvalidOperationException>(() => { var list = new CorsRules(); for (int i = 0; i < 2 + 1; i++) { list.Add(new CorsRule( "123456", new List <string> { "https" }, new List <string> { "b2_download_file_by_id", "b2_download_file_by_name" }, 3600) { AllowedHeaders = new List <string> { "range" }, ExposeHeaders = new List <string> { "x-bz-content-sha1" }, } ); } }); }
public void MaximumRulesAllowed() { Assert.Throws <InvalidOperationException>(() => { var list = new CorsRules(); for (int i = 0; i < CorsRules.MaximumRulesAllowed + 1; i++) { list.Add(new CorsRule( Guid.NewGuid().ToString(), new List <string> { "https" }, new List <string> { "b2_download_file_by_id", "b2_download_file_by_name" }, 3600) { AllowedHeaders = new List <string> { "range" }, ExposeHeaders = new List <string> { "x-bz-content-sha1" }, } ); } }); }
public void MaxAgeLength() { Assert.Throws <ArgumentOutOfRangeException>(() => { var list = new CorsRules(); list.Add(new CorsRule( "123456", new List <string> { "https" }, new List <string> { "b2_download_file_by_id", "b2_download_file_by_name" }, CorsRule.MinimumAgeSeconds - 1) { AllowedHeaders = new List <string> { "range" }, ExposeHeaders = new List <string> { "x-bz-content-sha1" }, } ); }); Assert.Throws <ArgumentOutOfRangeException>(() => { var list = new CorsRules(); list.Add(new CorsRule( "123456", new List <string> { "https" }, new List <string> { "b2_download_file_by_id", "b2_download_file_by_name" }, CorsRule.MaximumAgeSeconds + 1) { AllowedHeaders = new List <string> { "range" }, ExposeHeaders = new List <string> { "x-bz-content-sha1" }, } ); }); }
public void RuleNameLength() { Assert.Throws <ArgumentOutOfRangeException>(() => { var list = new CorsRules(); list.Add(new CorsRule( "12345", new List <string> { "https" }, new List <string> { "b2_download_file_by_id", "b2_download_file_by_name" }, 3600) { AllowedHeaders = new List <string> { "range" }, ExposeHeaders = new List <string> { "x-bz-content-sha1" }, } ); }); Assert.Throws <ArgumentOutOfRangeException>(() => { var list = new CorsRules(); list.Add(new CorsRule( "012345678901234567890123456789012345678901234567890", new List <string> { "https" }, new List <string> { "b2_download_file_by_id", "b2_download_file_by_name" }, 3600) { AllowedHeaders = new List <string> { "range" }, ExposeHeaders = new List <string> { "x-bz-content-sha1" }, } ); }); }