< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Data.EntityMaps.TwoFactorAuthDbMap
Assembly: ArturRios.Heimdall.Data
File(s): /home/ci/agent/workspace/heimdall-api-docs_main/app/src/Infrastructure/ArturRios.Heimdall.Data/EntityMaps/TwoFactorAuthDbMap.cs
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 43
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 1
Fully covered methods: 1
Total methods: 1
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Configure(...)100%11100%

File(s)

/home/ci/agent/workspace/heimdall-api-docs_main/app/src/Infrastructure/ArturRios.Heimdall.Data/EntityMaps/TwoFactorAuthDbMap.cs

#LineLine coverage
 1using ArturRios.Heimdall.Domain.Entities;
 2using Microsoft.EntityFrameworkCore;
 3using Microsoft.EntityFrameworkCore.Metadata.Builders;
 4
 5namespace ArturRios.Heimdall.Data.EntityMaps;
 6
 7internal static class TwoFactorAuthDbMap
 8{
 9    public static void Configure(this EntityTypeBuilder<TwoFactorAuth> twoFactorAuth)
 10    {
 411        twoFactorAuth.ToTable("two_factor_auth");
 12
 13        // Internal bigint Id only; a person's own configuration is reached through their
 14        // authenticated identity, never addressed by ID in a path (§4.0).
 415        twoFactorAuth.HasKey(x => x.Id);
 16
 417        twoFactorAuth.Property(x => x.AppEnabled).HasDefaultValue(false);
 418        twoFactorAuth.Property(x => x.EmailEnabled).HasDefaultValue(false);
 19
 420        twoFactorAuth.Property(x => x.TotpSecretEncrypted);
 21
 422        twoFactorAuth.Property(x => x.IsActive).HasDefaultValue(false);
 23
 424        twoFactorAuth.Property(x => x.EmailCodeReissueCount).HasDefaultValue(0);
 25
 26        // The outstanding challenge (FR-2F-10); null when none is outstanding.
 427        twoFactorAuth.Property(x => x.ChallengeId);
 28
 29        // Guesses at that challenge with an app code or a recovery code; reset with it.
 430        twoFactorAuth.Property(x => x.ChallengeAttempts).HasDefaultValue(0);
 31
 432        twoFactorAuth.Property(x => x.CreatedAt).HasDefaultValueSql("now()");
 433        twoFactorAuth.Property(x => x.UpdatedAt).HasDefaultValueSql("now()");
 34
 35        // At most one configuration per person; hard-deleting the person cascades to it (UC-10).
 436        twoFactorAuth.HasIndex(x => x.PersonId).IsUnique();
 437        twoFactorAuth.HasOne(x => x.Person)
 438            .WithOne(p => p.TwoFactorAuth)
 439            .HasForeignKey<TwoFactorAuth>(x => x.PersonId)
 440            .IsRequired()
 441            .OnDelete(DeleteBehavior.Cascade);
 442    }
 43}