2019-07-31 09:13:04 +02:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Routing;
|
2018-06-25 11:36:42 +02:00
|
|
|
|
using Microsoft.eShopOnContainers.Services.Ordering.API;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2019-07-31 09:13:04 +02:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2018-06-25 11:36:42 +02:00
|
|
|
|
|
2018-06-27 15:57:37 +02:00
|
|
|
|
namespace Ordering.FunctionalTests
|
2018-06-25 11:36:42 +02:00
|
|
|
|
{
|
|
|
|
|
public class OrderingTestsStartup : Startup
|
|
|
|
|
{
|
|
|
|
|
public OrderingTestsStartup(IConfiguration env) : base(env)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-31 09:13:04 +02:00
|
|
|
|
public override IServiceProvider ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
// Added to avoid the Authorize data annotation in test environment.
|
|
|
|
|
// Property "SuppressCheckForUnhandledSecurityMetadata" in appsettings.json
|
|
|
|
|
services.Configure<RouteOptions>(Configuration);
|
|
|
|
|
return base.ConfigureServices(services);
|
|
|
|
|
}
|
2018-06-25 11:36:42 +02:00
|
|
|
|
protected override void ConfigureAuth(IApplicationBuilder app)
|
|
|
|
|
{
|
|
|
|
|
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
|
|
|
|
{
|
|
|
|
|
app.UseMiddleware<AutoAuthorizeMiddleware>();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
base.ConfigureAuth(app);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|