< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Data.Configuration.AppDbContext
Assembly: ArturRios.Heimdall.Data
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Infrastructure/ArturRios.Heimdall.Data/Configuration/AppDbContext.cs
Line coverage
100%
Covered lines: 46
Uncovered lines: 0
Coverable lines: 46
Total lines: 83
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 22
Fully covered methods: 22
Total methods: 22
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Persons()100%11100%
get_Scopes()100%11100%
get_Roles()100%11100%
get_Applications()100%11100%
get_ApplicationCredentials()100%11100%
get_GoogleUsers()100%11100%
get_ScopeOwners()100%11100%
get_ScopeUsers()100%11100%
get_ScopePermissions()100%11100%
get_PasswordResetTokens()100%11100%
get_EmailVerificationTokens()100%11100%
get_PendingRegistrations()100%11100%
get_TwoFactorAuths()100%11100%
get_TwoFactorEmailCodes()100%11100%
get_TwoFactorRecoveryCodes()100%11100%
get_AuditLogs()100%11100%
get_ErasedSubjects()100%11100%
get_AttemptNoticeBudgets()100%11100%
get_DataProtectionKeys()100%11100%
OnConfiguring(...)100%11100%
OnModelCreating(...)100%11100%

File(s)

/home/runner/work/heimdall-api/heimdall-api/src/Infrastructure/ArturRios.Heimdall.Data/Configuration/AppDbContext.cs

#LineLine coverage
 1using ArturRios.Data.Relational.Core.Configuration;
 2using ArturRios.Heimdall.Data.EntityMaps;
 3using ArturRios.Heimdall.Domain.Entities;
 4using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore;
 5using Microsoft.EntityFrameworkCore;
 6using Microsoft.Extensions.Logging;
 7
 8namespace ArturRios.Heimdall.Data.Configuration;
 9
 10public class AppDbContext(
 11    DbContextOptions options,
 12    ILoggerFactory loggerFactory,
 695613    DbContextDiagnosticsOptions diagnostics) : BaseDbContext(options), IDataProtectionKeyContext
 14{
 15    private const string Schema = "heimdall";
 16
 947717    public DbSet<Person> Persons { get; init; }
 760118    public DbSet<Scope> Scopes { get; init; }
 786219    public DbSet<Role> Roles { get; init; }
 713320    public DbSet<Application> Applications { get; init; }
 706221    public DbSet<ApplicationCredential> ApplicationCredentials { get; init; }
 707722    public DbSet<GoogleUser> GoogleUsers { get; init; }
 726223    public DbSet<ScopeOwner> ScopeOwners { get; init; }
 715224    public DbSet<ScopeUser> ScopeUsers { get; init; }
 703725    public DbSet<ScopePermission> ScopePermissions { get; init; }
 704426    public DbSet<PasswordResetToken> PasswordResetTokens { get; init; }
 703127    public DbSet<EmailVerificationToken> EmailVerificationTokens { get; init; }
 702728    public DbSet<PendingRegistration> PendingRegistrations { get; init; }
 720229    public DbSet<TwoFactorAuth> TwoFactorAuths { get; init; }
 701930    public DbSet<TwoFactorEmailCode> TwoFactorEmailCodes { get; init; }
 704231    public DbSet<TwoFactorRecoveryCode> TwoFactorRecoveryCodes { get; init; }
 698832    public DbSet<AuditLog> AuditLogs { get; init; }
 697133    public DbSet<ErasedSubject> ErasedSubjects { get; init; }
 696534    public DbSet<AttemptNoticeBudget> AttemptNoticeBudgets { get; init; }
 35
 36    /// <summary>
 37    ///     ASP.NET Core's Data Protection key ring, kept in the database rather than on a local
 38    ///     filesystem (<see cref="IDataProtectionKeyContext" />).
 39    /// </summary>
 40    /// <remarks>
 41    ///     Not a domain table, and the only one here that no entity map configures — its shape
 42    ///     belongs to Data Protection. It is in this context because the keys have to outlive the
 43    ///     container and be reachable from every instance: the TOTP secrets of UC-36 are encrypted
 44    ///     with them (NFR-16), and a key ring that is lost or not shared makes every one of those
 45    ///     secrets undecryptable, which silently stops the authenticator-app factor from ever
 46    ///     verifying again. The default is a directory on the local filesystem, which the image does
 47    ///     not persist and two instances do not share.
 48    /// </remarks>
 786149    public DbSet<DataProtectionKey> DataProtectionKeys { get; init; }
 50
 51    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 52    {
 639553        optionsBuilder
 639554            .UseLoggerFactory(loggerFactory)
 639555            .UseSnakeCaseNamingConvention()
 639556            .EnableDetailedErrors(diagnostics.DetailedErrors)
 639557            .EnableSensitiveDataLogging(diagnostics.SensitiveDataLogging);
 639558    }
 59
 60    protected override void OnModelCreating(ModelBuilder modelBuilder)
 61    {
 362        modelBuilder.HasDefaultSchema(Schema);
 63
 364        modelBuilder.Entity<Person>().Configure();
 365        modelBuilder.Entity<Scope>().Configure();
 366        modelBuilder.Entity<Role>().Configure();
 367        modelBuilder.Entity<Application>().Configure();
 368        modelBuilder.Entity<ApplicationCredential>().Configure();
 369        modelBuilder.Entity<GoogleUser>().Configure();
 370        modelBuilder.Entity<ScopePermission>().Configure();
 371        modelBuilder.Entity<ScopeOwner>().Configure();
 372        modelBuilder.Entity<ScopeUser>().Configure();
 373        modelBuilder.Entity<PasswordResetToken>().Configure();
 374        modelBuilder.Entity<EmailVerificationToken>().Configure();
 375        modelBuilder.Entity<PendingRegistration>().Configure();
 376        modelBuilder.Entity<TwoFactorAuth>().Configure();
 377        modelBuilder.Entity<TwoFactorEmailCode>().Configure();
 378        modelBuilder.Entity<TwoFactorRecoveryCode>().Configure();
 379        modelBuilder.Entity<AuditLog>().Configure();
 380        modelBuilder.Entity<ErasedSubject>().Configure();
 381        modelBuilder.Entity<AttemptNoticeBudget>().Configure();
 382    }
 83}