< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Data.Configuration.AppDbContext
Assembly: ArturRios.Heimdall.Data
File(s): /home/ci/agent/workspace/heimdall-api-docs_main/app/src/Infrastructure/ArturRios.Heimdall.Data/Configuration/AppDbContext.cs
Line coverage
100%
Covered lines: 50
Uncovered lines: 0
Coverable lines: 50
Total lines: 87
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 24
Fully covered methods: 24
Total methods: 24
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_ScopeOwnerInvitations()100%11100%
get_GoogleIdTokenUses()100%11100%
get_DataProtectionKeys()100%11100%
OnConfiguring(...)100%11100%
OnModelCreating(...)100%11100%

File(s)

/home/ci/agent/workspace/heimdall-api-docs_main/app/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,
 790313    DbContextDiagnosticsOptions diagnostics) : BaseDbContext(options), IDataProtectionKeyContext
 14{
 15    private const string Schema = "heimdall";
 16
 1095617    public DbSet<Person> Persons { get; init; }
 874718    public DbSet<Scope> Scopes { get; init; }
 888419    public DbSet<Role> Roles { get; init; }
 810320    public DbSet<Application> Applications { get; init; }
 800921    public DbSet<ApplicationCredential> ApplicationCredentials { get; init; }
 809022    public DbSet<GoogleUser> GoogleUsers { get; init; }
 828023    public DbSet<ScopeOwner> ScopeOwners { get; init; }
 813824    public DbSet<ScopeUser> ScopeUsers { get; init; }
 798425    public DbSet<ScopePermission> ScopePermissions { get; init; }
 800426    public DbSet<PasswordResetToken> PasswordResetTokens { get; init; }
 798927    public DbSet<EmailVerificationToken> EmailVerificationTokens { get; init; }
 799228    public DbSet<PendingRegistration> PendingRegistrations { get; init; }
 816729    public DbSet<TwoFactorAuth> TwoFactorAuths { get; init; }
 797230    public DbSet<TwoFactorEmailCode> TwoFactorEmailCodes { get; init; }
 799131    public DbSet<TwoFactorRecoveryCode> TwoFactorRecoveryCodes { get; init; }
 797332    public DbSet<AuditLog> AuditLogs { get; init; }
 792233    public DbSet<ErasedSubject> ErasedSubjects { get; init; }
 791234    public DbSet<AttemptNoticeBudget> AttemptNoticeBudgets { get; init; }
 808635    public DbSet<ScopeOwnerInvitation> ScopeOwnerInvitations { get; init; }
 790836    public DbSet<GoogleIdTokenUse> GoogleIdTokenUses { get; init; }
 37
 38    /// <summary>
 39    ///     ASP.NET Core's Data Protection key ring, kept in the database rather than on a local
 40    ///     filesystem (<see cref="IDataProtectionKeyContext" />).
 41    /// </summary>
 42    /// <remarks>
 43    ///     Not a domain table, and the only one here that no entity map configures — its shape
 44    ///     belongs to Data Protection. It is in this context because the keys have to outlive the
 45    ///     container and be reachable from every instance: the TOTP secrets of UC-36 are encrypted
 46    ///     with them (NFR-16), and a key ring that is lost or not shared makes every one of those
 47    ///     secrets undecryptable, which silently stops the authenticator-app factor from ever
 48    ///     verifying again. The default is a directory on the local filesystem, which the image does
 49    ///     not persist and two instances do not share.
 50    /// </remarks>
 887551    public DbSet<DataProtectionKey> DataProtectionKeys { get; init; }
 52
 53    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 54    {
 730855        optionsBuilder
 730856            .UseLoggerFactory(loggerFactory)
 730857            .UseSnakeCaseNamingConvention()
 730858            .EnableDetailedErrors(diagnostics.DetailedErrors)
 730859            .EnableSensitiveDataLogging(diagnostics.SensitiveDataLogging);
 730860    }
 61
 62    protected override void OnModelCreating(ModelBuilder modelBuilder)
 63    {
 464        modelBuilder.HasDefaultSchema(Schema);
 65
 466        modelBuilder.Entity<Person>().Configure();
 467        modelBuilder.Entity<Scope>().Configure();
 468        modelBuilder.Entity<Role>().Configure();
 469        modelBuilder.Entity<Application>().Configure();
 470        modelBuilder.Entity<ApplicationCredential>().Configure();
 471        modelBuilder.Entity<GoogleUser>().Configure();
 472        modelBuilder.Entity<ScopePermission>().Configure();
 473        modelBuilder.Entity<ScopeOwner>().Configure();
 474        modelBuilder.Entity<ScopeUser>().Configure();
 475        modelBuilder.Entity<PasswordResetToken>().Configure();
 476        modelBuilder.Entity<EmailVerificationToken>().Configure();
 477        modelBuilder.Entity<PendingRegistration>().Configure();
 478        modelBuilder.Entity<TwoFactorAuth>().Configure();
 479        modelBuilder.Entity<TwoFactorEmailCode>().Configure();
 480        modelBuilder.Entity<TwoFactorRecoveryCode>().Configure();
 481        modelBuilder.Entity<AuditLog>().Configure();
 482        modelBuilder.Entity<ErasedSubject>().Configure();
 483        modelBuilder.Entity<AttemptNoticeBudget>().Configure();
 484        modelBuilder.Entity<ScopeOwnerInvitation>().Configure();
 485        modelBuilder.Entity<GoogleIdTokenUse>().Configure();
 486    }
 87}