< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Data.EntityMaps.TwoFactorAuthDbMap
Assembly: ArturRios.Heimdall.Data
File(s): /home/runner/work/heimdall-api/heimdall-api/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/runner/work/heimdall-api/heimdall-api/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    {
 311        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).
 315        twoFactorAuth.HasKey(x => x.Id);
 16
 317        twoFactorAuth.Property(x => x.AppEnabled).HasDefaultValue(false);
 318        twoFactorAuth.Property(x => x.EmailEnabled).HasDefaultValue(false);
 19
 320        twoFactorAuth.Property(x => x.TotpSecretEncrypted);
 21
 322        twoFactorAuth.Property(x => x.IsActive).HasDefaultValue(false);
 23
 324        twoFactorAuth.Property(x => x.EmailCodeReissueCount).HasDefaultValue(0);
 25
 26        // The outstanding challenge (FR-2F-10); null when none is outstanding.
 327        twoFactorAuth.Property(x => x.ChallengeId);
 28
 29        // Guesses at that challenge with an app code or a recovery code; reset with it.
 330        twoFactorAuth.Property(x => x.ChallengeAttempts).HasDefaultValue(0);
 31
 332        twoFactorAuth.Property(x => x.CreatedAt).HasDefaultValueSql("now()");
 333        twoFactorAuth.Property(x => x.UpdatedAt).HasDefaultValueSql("now()");
 34
 35        // At most one configuration per person; hard-deleting the person cascades to it (UC-10).
 336        twoFactorAuth.HasIndex(x => x.PersonId).IsUnique();
 337        twoFactorAuth.HasOne(x => x.Person)
 338            .WithOne(p => p.TwoFactorAuth)
 339            .HasForeignKey<TwoFactorAuth>(x => x.PersonId)
 340            .IsRequired()
 341            .OnDelete(DeleteBehavior.Cascade);
 342    }
 43}