public void DevMode_HasExpectedExposedHeaders(string expectedMethod) { // arrange var sut = new CorsProvider(true, new string[0]); // act var result = sut.GetCorsPolicy(); // assert Assert.True(result.ExposedHeaders.Contains(expectedMethod)); }
public void ProdMode_AllowsNoOriginsWhenNotProvided() { // arrange var sut = new CorsProvider(false, new string[0]); // act var result = sut.GetCorsPolicy(); // assert Assert.False(result.Origins.Any()); }
public void DevMode_DoesNotSupportsCredentials() { // arrange var sut = new CorsProvider(true, new string[0]); // act var result = sut.GetCorsPolicy(); // assert Assert.False(result.SupportsCredentials); }
public void DevMode_AllowsAnyHeader() { // arrange var sut = new CorsProvider(true, new string[0]); // act var result = sut.GetCorsPolicy(); // assert Assert.True(result.AllowAnyHeader); }
public void ProdMode_HasExpectedMethods(string expectedMethod) { // arrange var sut = new CorsProvider(false, new string[0]); // act var result = sut.GetCorsPolicy(); // assert Assert.True(result.Methods.Contains(expectedMethod)); }
public void DevMode_AllowsLocalHostWhenNotProvided(string expectedOrigin) { // arrange var sut = new CorsProvider(true, new string[0]); // act var result = sut.GetCorsPolicy(); // assert Assert.True(result.Origins.Contains(expectedOrigin)); }
public void DevMode_DisallowsAnyOrigin() { // arrange var sut = new CorsProvider(true, new string[0]); // act var result = sut.GetCorsPolicy(); // assert Assert.False(result.AllowAnyOrigin); }
public void DevMode_GetsPolicy() { // arrange var origins = new[] { "http://www.fusionalliance.com" }; var sut = new CorsProvider(true, origins); // act var result = sut.GetCorsPolicy(); // assert Assert.IsType(typeof(CorsPolicy), result); }
public void DevMode_DisallowsAnyMethod() { // arrange var origins = new[] { "http://www.fusionalliance.com" }; var sut = new CorsProvider(true, origins); // act var result = sut.GetCorsPolicy(); // assert Assert.False(result.AllowAnyMethod); }
public void ProdMode_NotSupportCredentials() { // arrange var origins = new[] { "http://www.fusionalliance.com" }; var sut = new CorsProvider(false, origins); // act var result = sut.GetCorsPolicy(); // assert Assert.False(result.SupportsCredentials); }
public void ProdMode_ExposesTotalCountHeader() { // arrange var origins = new[] { "http://www.fusionalliance.com" }; var sut = new CorsProvider(false, origins); // act var result = sut.GetCorsPolicy(); // assert Assert.True(result.ExposedHeaders.Contains("x-total-count")); }
/// <remarks>Order of methods invocation has matter</remarks> public void Configuration(IAppBuilder app) { GlobalConfiguration.Configure(WebApiConfig.Register); GlobalConfiguration.Configure(DependencyConfig.Register); GlobalConfiguration.Configuration.EnsureInitialized(); app.UseCors(CorsProvider.GetCorsOptions()); UseOAuth(app); app.UseCorrelationIdHeaderRewriterMiddleware(); app.UseWebApi(GlobalConfiguration.Configuration); }
public void ProdMode_SetsPreflightMaxAge() { // arrange var expected = TimeSpan.FromMinutes(10); var origins = new[] { "http://www.fusionalliance.com" }; var sut = new CorsProvider(false, origins); // act var result = sut.GetCorsPolicy(); // assert Assert.Equal(expected, result.PreflightMaxAge); }
/// <remarks>Order of methods invocation has matter</remarks> public void Configuration(IAppBuilder app) { GlobalConfiguration.Configure(WebApiConfig.Register); AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); app.UseCors(CorsProvider.GetCorsOptions()); ConfigureOAuth(app); HttpConfiguration config = new HttpConfiguration(); WebApiConfig.Register(config); app.UseWebApi(config); }
public void ProdMode_SetsOrigins(string data) { // arrange var origins = data.Split(','); var sut = new CorsProvider(false, origins); // act var result = sut.GetCorsPolicy(); // assert foreach (var o in origins) { Assert.True(result.Origins.Contains(o)); } }