< Summary

Information
Line coverage
0%
Covered lines: 0
Uncovered lines: 29
Coverable lines: 29
Total lines: 51
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
<Main>$(...)0%620%

File(s)

/home/runner/work/SEP4/SEP4/backend/microservices/autorisering/WebApi/Program.cs

#LineLine coverage
 1using System.Text;
 2using Microsoft.AspNetCore.Authentication.JwtBearer;
 3using Microsoft.IdentityModel.Tokens;
 4using WebApi.DAO;
 5using WebApi.Services;
 6using SharedObjects.Auth;
 7
 08var builder = WebApplication.CreateBuilder(args);
 9
 10// Add services to the container.
 11// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
 012builder.Services.AddControllers();
 013builder.Services.AddEndpointsApiExplorer();
 014builder.Services.AddSwaggerGen();
 15
 16// Register the MongoDbContext
 017builder.Services.AddSingleton<MongoDbContext>(sp =>
 018    new MongoDbContext(
 019        builder.Configuration.GetConnectionString("MongoDB"),
 020        "auth_db"
 021    )
 022);
 023builder.Services.AddScoped<IUserDAO, UserDAO>();
 024builder.Services.AddScoped<IUserService, UserService>();
 25
 026AuthorizationPolicies.AddAuth(builder);
 27
 028var app = builder.Build();
 29
 30// Configure the HTTP request pipeline.
 031if (app.Environment.IsDevelopment())
 032{
 033    app.UseSwagger();
 034    app.UseSwaggerUI();
 035}
 36
 037app.UseCors(x => x
 038    .AllowAnyMethod()
 039    .AllowAnyHeader()
 040    .SetIsOriginAllowed(origin => true) // allow any origin
 041    .AllowCredentials());
 42
 043app.UseHttpsRedirection();
 44
 045app.UseAuthentication();
 46
 047app.UseAuthorization();
 48
 049app.MapControllers();
 50
 051app.Run();

Methods/Properties

<Main>$(System.String[])