xunit web server collection

This commit is contained in:
Paul Schneider 2023-01-29 13:04:50 +00:00
commit 3695c17429
38 changed files with 1033 additions and 140 deletions

View file

@ -58,7 +58,7 @@ namespace isnd
.AddDefaultTokenProviders();
services.AddMvc();
services.AddDataProtection();
services.AddAuthorization(options =>
@ -76,16 +76,16 @@ namespace isnd
.AddSingleton<IAuthorizationHandler, ValidApiKeyRequirementHandler>()
.AddSingleton(s =>
{
var config = s.GetRequiredService<IOptions<UnleashClientSettings>>();
if (config.Value==null)
throw new System.Exception("No unleash client settings");
if (config.Value.ApiUrl==null)
throw new System.Exception("No unleash client ApiUrl");
if (config.Value.ClientApiKey==null)
throw new System.Exception("No unleash client ClientApiKey");
return s.GetRequiredService<Microsoft.AspNetCore.Hosting.IHostingEnvironment>().CreateUnleahClient(config.Value);
var config = s.GetRequiredService<IOptions<UnleashClientSettings>>();
if (config.Value == null)
throw new System.Exception("No unleash client settings");
if (config.Value.ApiUrl == null)
throw new System.Exception("No unleash client ApiUrl");
if (config.Value.ClientApiKey == null)
throw new System.Exception("No unleash client ClientApiKey");
return s.GetRequiredService<Microsoft.AspNetCore.Hosting.IHostingEnvironment>().CreateUnleahClient(config.Value);
});
services.AddAuthentication("Bearer")
.AddJwtBearer("Bearer", options =>
@ -98,11 +98,11 @@ namespace isnd
});
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
options.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "ToDo API",
Description = "An ASP.NET Core Web API for managing ToDo items",
Title = "isnd API",
Description = "An ASP.NET Core Web API for managing isnd items",
TermsOfService = new Uri("https://isn.pschneider.fr/terms"),
Contact = new OpenApiContact
{
@ -115,13 +115,13 @@ namespace isnd
Url = new Uri("https://isn.pschneider.fr/license")
}
});
var xmlFilename = $"{typeof(Startup).Assembly.GetName().Name}.xml";
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
var xmlFilename = $"{typeof(Startup).Assembly.GetName().Name}.xml";
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app,
public void Configure(IApplicationBuilder app,
Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
ApplicationDbContext dbContext)
{