< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Domain.Entities.TwoFactorRecoveryCode
Assembly: ArturRios.Heimdall.Domain
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Domain/ArturRios.Heimdall.Domain/Entities/TwoFactorRecoveryCode.cs
Line coverage
66%
Covered lines: 4
Uncovered lines: 2
Coverable lines: 6
Total lines: 42
Line coverage: 66.6%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
66%
Covered methods: 4
Fully covered methods: 4
Total methods: 6
Method coverage: 66.6%
Full method coverage: 66.6%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_TwoFactorAuthId()100%11100%
get_CodeHash()100%11100%
get_Used()100%11100%
get_UsedAt()100%11100%
get_CreatedAt()100%210%
get_TwoFactorAuth()100%210%

File(s)

/home/runner/work/heimdall-api/heimdall-api/src/Domain/ArturRios.Heimdall.Domain/Entities/TwoFactorRecoveryCode.cs

#LineLine coverage
 1using ArturRios.Data.Relational.Core.Entities;
 2
 3namespace ArturRios.Heimdall.Domain.Entities;
 4
 5/// <summary>
 6///     A single-use recovery code for a person's two-factor authentication configuration (UC-37 step
 7///     4, FR-2F-05). Ten rows are created together when setup is confirmed, and again — replacing the
 8///     previous ten — when UC-40 regenerates them. The plaintext code is returned to the caller
 9///     exactly once, in the confirmation (or regeneration) response; only its hash is ever persisted
 10///     (see §4.10 of the System Requirements Document). Never addressed by ID; reached through the
 11///     owning <see cref="TwoFactorAuth" /> configuration.
 12/// </summary>
 13public class TwoFactorRecoveryCode : Entity<long>
 14{
 15    /// <summary>
 16    ///     Foreign key to the owning <see cref="TwoFactorAuth" /> configuration (internal Id).
 17    ///     Required.
 18    /// </summary>
 45219    public long TwoFactorAuthId { get; set; }
 20
 21    /// <summary>
 22    ///     Hash of the recovery code. §4.10 documents no per-code salt column — unlike
 23    ///     <see cref="TwoFactorEmailCode" />, these are high-entropy random strings rather than
 24    ///     user-chosen secrets, so a keyed/plain one-way hash is enough to keep the plaintext
 25    ///     unrecoverable at rest.
 26    /// </summary>
 120527    public byte[] CodeHash { get; set; } = [];
 28
 29    /// <summary>Whether the code has already been consumed (UC-38).</summary>
 43530    public bool Used { get; set; }
 31
 32    /// <summary>Timestamp the code was consumed; null until then.</summary>
 4133    public DateTime? UsedAt { get; set; }
 34
 35    /// <summary>Creation timestamp.</summary>
 036    public DateTime CreatedAt { get; set; }
 37
 38    // Navigation properties
 39
 40    /// <summary>The two-factor configuration this code was issued for.</summary>
 041    public TwoFactorAuth TwoFactorAuth { get; set; } = null!;
 42}