< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Shared.Messages.TwoFactorMessageMap
Assembly: ArturRios.Heimdall.Shared
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Application/ArturRios.Heimdall.Shared/Messages/TwoFactorMessageMap.cs
Line coverage
100%
Covered lines: 47
Uncovered lines: 0
Coverable lines: 47
Total lines: 58
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
.cctor()100%11100%

File(s)

/home/runner/work/heimdall-api/heimdall-api/src/Application/ArturRios.Heimdall.Shared/Messages/TwoFactorMessageMap.cs

#LineLine coverage
 1using ArturRios.Util.Http;
 2
 3namespace ArturRios.Heimdall.Shared.Messages;
 4
 5/// <summary>
 6///     Maps each <see cref="TwoFactorMessages" /> value to its HTTP status code, following UC-36's
 7///     and UC-37's flows. Passed to the response resolver.
 8/// </summary>
 9public static class TwoFactorMessageMap
 10{
 411    public static readonly IReadOnlyDictionary<string, int> StatusCodes =
 412        DataAccessMessageMap.CombinedWith(new Dictionary<string, int>
 413        {
 414            // UC-36 main flow and AF-36d — setup initiated or a pending setup overwritten.
 415            [TwoFactorMessages.SetupInitiated] = HttpStatusCodes.Ok,
 416            // AF-36a and AF-37d — already active.
 417            [TwoFactorMessages.AlreadyActive] = HttpStatusCodes.Conflict,
 418            // AF-36b — caller is not eligible (Google User, or no live person named by the token).
 419            [TwoFactorMessages.NotEligible] = HttpStatusCodes.Forbidden,
 420            // AF-36c — neither method selected.
 421            [TwoFactorMessages.NoMethodSelected] = HttpStatusCodes.BadRequest,
 422            // AF-36f, AF-36g — the person's account-email budget refused the setup code (FR-2F-19), as
 423            // AF-15b and AF-15c.
 424            [AuthMessages.EmailSentRecently] = HttpStatusCodes.TooManyRequests,
 425            [AuthMessages.AccountEmailLimitReached] = HttpStatusCodes.TooManyRequests,
 426            // UC-37 main flow — setup confirmed, recovery codes issued.
 427            [TwoFactorMessages.SetupConfirmed] = HttpStatusCodes.Ok,
 428            // AF-37a — no pending setup exists for the caller.
 429            [TwoFactorMessages.NoPendingSetup] = HttpStatusCodes.NotFound,
 430            // AF-36e, AF-37b, AF-37c, AF-39b, AF-39c and AF-40b (FR-AU-13) — a password or code checked
 431            // under a bearer token was wrong, missing or already used, or the account's
 432            // re-authentication budget is paused: one message, and the status the password refusal
 433            // has always had.
 434            [AuthMessages.PasswordOrCodeIncorrect] = HttpStatusCodes.Unauthorized,
 435            // UC-38 main flow — challenge redeemed, full token issued.
 436            [TwoFactorMessages.VerificationSuccessful] = HttpStatusCodes.Ok,
 437            // UC-38 for a restricted person (NFR-24) — a subject-rights-only token.
 438            [AuthMessages.SubjectRightsOnlySignIn] = HttpStatusCodes.Ok,
 439            // AF-38a — challenge token missing, invalid, or expired.
 440            [TwoFactorMessages.ChallengeTokenInvalid] = HttpStatusCodes.Unauthorized,
 441            // UC-46 — the one answer every flow gives, main and alternative alike (FR-2F-16).
 442            [TwoFactorMessages.ChallengeCodeResent] = HttpStatusCodes.Ok,
 443            // UC-38 step 5 — the second factor checked out but scope eligibility no longer holds.
 444            [TwoFactorMessages.ScopeNoLongerEligible] = HttpStatusCodes.Unauthorized,
 445            // AF-38b and AF-38c — collapsed to the same 401 so a wrong code, a reused recovery code and
 446            // a locked second factor (FR-AU-12) cannot be told apart.
 447            [TwoFactorMessages.FactorInvalid] = HttpStatusCodes.Unauthorized,
 448            // UC-39 main flow — the configuration and its recovery codes were removed.
 449            [TwoFactorMessages.Disabled] = HttpStatusCodes.Ok,
 450            // AF-39a — two-factor authentication is not active for the caller. Also UC-40's AF-40a: the
 451            // same "not active" refusal, reused rather than duplicated.
 452            [TwoFactorMessages.NotActive] = HttpStatusCodes.NotFound,
 453            // UC-40 main flow — every existing recovery code was replaced with ten new ones.
 454            [TwoFactorMessages.RecoveryCodesRegenerated] = HttpStatusCodes.Ok,
 455            // FR-2F-15 main flow — status read, including the all-false "never enabled" state.
 456            [TwoFactorMessages.StatusRetrieved] = HttpStatusCodes.Ok
 457        });
 58}

Methods/Properties

.cctor()