< Summary - Heimdall API

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

#LineLine coverage
 1using ArturRios.Util.Http;
 2
 3namespace ArturRios.Heimdall.Shared.Messages;
 4
 5/// <summary>
 6///     Maps each <see cref="AuthMessages" /> value to its HTTP status code, following the UC-11,
 7///     UC-12, UC-13, UC-14, UC-15, UC-25, and UC-26 flows. Passed to the response resolver.
 8/// </summary>
 9public static class AuthMessageMap
 10{
 411    public static readonly IReadOnlyDictionary<string, int> StatusCodes =
 412        DataAccessMessageMap.CombinedWith(new Dictionary<string, int>
 413        {
 414            // UC-11 main flow — authenticated, token issued.
 415            [AuthMessages.LoginSuccessful] = HttpStatusCodes.Ok,
 416            // AF-11g — password check passed, a UC-38 challenge token was issued instead.
 417            [AuthMessages.TwoFactorRequired] = HttpStatusCodes.Ok,
 418            // UC-11 and UC-25 for a restricted identity (NFR-24) — a subject-rights-only token.
 419            [AuthMessages.SubjectRightsOnlySignIn] = HttpStatusCodes.Ok,
 420            // AF-11a…AF-11e — every rejection answers alike, so none of them is distinguishable.
 421            [AuthMessages.InvalidCredentials] = HttpStatusCodes.Unauthorized,
 422            // AF-11f — malformed request. UC-12's validator reuses the two email messages.
 423            [AuthMessages.EmailRequired] = HttpStatusCodes.BadRequest,
 424            [AuthMessages.EmailInvalid] = HttpStatusCodes.BadRequest,
 425            [AuthMessages.PasswordRequired] = HttpStatusCodes.BadRequest,
 426            // UC-12 main flow and AF-12a — both answer 200 with the same message.
 427            [AuthMessages.PasswordRecoveryRequested] = HttpStatusCodes.Ok,
 428            // UC-13 main flow — the password was changed.
 429            [AuthMessages.PasswordResetSuccessful] = HttpStatusCodes.Ok,
 430            // UC-14 main flow — the address was confirmed.
 431            [AuthMessages.EmailVerifiedSuccessfully] = HttpStatusCodes.Ok,
 432            // UC-15 main flow — a fresh verification link was issued and mailed.
 433            [AuthMessages.VerificationEmailSent] = HttpStatusCodes.Ok,
 434            // AF-15a — the address is already verified, so no link is worth sending.
 435            [AuthMessages.EmailAlreadyVerified] = HttpStatusCodes.BadRequest,
 436            // AF-15b, AF-15c — the person's account-email budget refused the send (FR-PE-16): the
 437            // cooldown, or the day's limit. The status UC-51's AF-51e answers with.
 438            [AuthMessages.EmailSentRecently] = HttpStatusCodes.TooManyRequests,
 439            [AuthMessages.AccountEmailLimitReached] = HttpStatusCodes.TooManyRequests,
 440            // UC-15 — the caller's own token names a person who no longer exists (ClaimsOnly outlives a
 441            // hard deletion). The same answer UC-07 AF-07a gives for the same fact.
 442            [AuthMessages.PersonNotFound] = HttpStatusCodes.NotFound,
 443            // AF-13a…AF-13c, and AF-14a…AF-14c — each token rejection is named, and all of them are bad
 444            // requests. The two use cases specify the same three messages, so they share these entries.
 445            [AuthMessages.TokenInvalid] = HttpStatusCodes.BadRequest,
 446            [AuthMessages.TokenExpired] = HttpStatusCodes.BadRequest,
 447            [AuthMessages.TokenAlreadyUsed] = HttpStatusCodes.BadRequest,
 448            // AF-13d, and UC-14's input validation — malformed request. The password messages are shared
 449            // with AF-11f.
 450            [AuthMessages.TokenRequired] = HttpStatusCodes.BadRequest,
 451            [AuthMessages.PasswordTooShort] = HttpStatusCodes.BadRequest,
 452            // UC-25 main flow — the Google account was signed up or signed in and a token issued.
 453            [AuthMessages.GoogleSignInSuccessful] = HttpStatusCodes.Ok,
 454            // AF-25a and AF-25d — an unverifiable token and a deleted Google User answer alike, as
 455            // UC-11's rejections do. Shared with UC-26 AF-26a, whose refusals are the same fact.
 456            [AuthMessages.GoogleAuthenticationFailed] = HttpStatusCodes.Unauthorized,
 457            // UC-26 main flow — the Google session ended and the client should drop the token.
 458            [AuthMessages.GoogleSignOutSuccessful] = HttpStatusCodes.Ok,
 459            // AF-25b — the scope is missing, deleted, or has the setting off. 403 rather than 404: the
 460            // use case refuses the operation without saying which of the three is the reason.
 461            [AuthMessages.GoogleSignInUnavailable] = HttpStatusCodes.Forbidden,
 462            // AF-25f — a sign-up whose address Google does not vouch for. 403, as AF-25b: the caller
 463            // is who the token says, and is refused the operation.
 464            [AuthMessages.GoogleEmailNotVerified] = HttpStatusCodes.Forbidden,
 465            // AF-25c — the verified address is already taken within the scope.
 466            [AuthMessages.EmailAlreadyExists] = HttpStatusCodes.Conflict,
 467            // UC-47 main flow and AF-47b — queued, answered alike for every address.
 468            [AuthMessages.RegistrationRequested] = HttpStatusCodes.Accepted,
 469            // AF-47a — closed, missing and deleted scopes alike; says nothing about any address.
 470            [AuthMessages.RegistrationUnavailable] = HttpStatusCodes.Forbidden,
 471            // UC-47 confirmation — the link is followed without the sign-up password; nothing was consumed.
 472            [AuthMessages.ConfirmationPasswordRequired] = HttpStatusCodes.UnprocessableEntity,
 473            // UC-47 confirmation — the password is not the one chosen at sign-up; nothing was consumed.
 474            [AuthMessages.ConfirmationPasswordIncorrect] = HttpStatusCodes.Unauthorized,
 475            // AF-47c — malformed request. Email and password messages share their text with the
 476            // AF-11f entries above; the name messages are UC-47's own.
 477            [AuthMessages.ScopeRequired] = HttpStatusCodes.BadRequest,
 478            [PersonMessages.NameRequired] = HttpStatusCodes.BadRequest,
 479            [PersonMessages.NameTooLong] = HttpStatusCodes.BadRequest,
 480            [PersonMessages.EmailRequired] = HttpStatusCodes.BadRequest,
 481            [PersonMessages.EmailInvalid] = HttpStatusCodes.BadRequest,
 482            [PersonMessages.EmailTooLong] = HttpStatusCodes.BadRequest,
 483            [PersonMessages.PasswordRequired] = HttpStatusCodes.BadRequest,
 484            [PersonMessages.PasswordTooShort] = HttpStatusCodes.BadRequest
 485        });
 86}

Methods/Properties

.cctor()