< Summary - Heimdall API

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

#LineLine coverage
 1using ArturRios.Util.Http;
 2
 3namespace ArturRios.Heimdall.Shared.Messages;
 4
 5/// <summary>
 6///     Maps each <see cref="ScopeMessages" /> value to the HTTP status code that should accompany it,
 7///     following the UC-01 / UC-02 flows. Passed to the response resolver so it can pick the status
 8///     code from the output's first message (on success) or first error (on failure).
 9/// </summary>
 10public static class ScopeMessageMap
 11{
 412    public static readonly IReadOnlyDictionary<string, int> StatusCodes =
 413        DataAccessMessageMap.CombinedWith(new Dictionary<string, int>
 414        {
 415            // UC-01 main flow — scope created.
 416            [ScopeMessages.ScopeCreatedSuccessfully] = HttpStatusCodes.Created,
 417            // UC-03 main flow — scope updated.
 418            [ScopeMessages.ScopeUpdatedSuccessfully] = HttpStatusCodes.Ok,
 419            // UC-04 main flow (and AF-04b idempotent) — scope deleted.
 420            [ScopeMessages.ScopeDeletedSuccessfully] = HttpStatusCodes.Ok,
 421            // UC-05 main flow — scope hard deleted.
 422            [ScopeMessages.ScopeHardDeletedSuccessfully] = HttpStatusCodes.Ok,
 423            // UC-02 main flow — scope(s) retrieved.
 424            [ScopeMessages.ScopeRetrievedSuccessfully] = HttpStatusCodes.Ok,
 425            [ScopeMessages.ScopesRetrievedSuccessfully] = HttpStatusCodes.Ok,
 426            // AF-02a — scope not found.
 427            [ScopeMessages.ScopeNotFound] = HttpStatusCodes.NotFound,
 428            // AF-02b — caller may not view this scope.
 429            [ScopeMessages.NotAuthorizedToViewScope] = HttpStatusCodes.Forbidden,
 430            [ScopeMessages.NotAuthorizedToListScopes] = HttpStatusCodes.Forbidden,
 431            // AF-01b — invalid input data, or no owner specified.
 432            [ScopeMessages.NameRequired] = HttpStatusCodes.BadRequest,
 433            [ScopeMessages.AtLeastOneOwnerRequired] = HttpStatusCodes.BadRequest,
 434            // AF-01a — scope name already exists.
 435            [ScopeMessages.NameAlreadyExists] = HttpStatusCodes.Conflict,
 436            // AF-01d — an owner is not an existing, non-deleted ScopeAdmin.
 437            [ScopeMessages.OwnerNotValidScopeAdmin] = HttpStatusCodes.BadRequest,
 438            // UC-24 main flow — Google Sign-In enabled or disabled. AF-24a reuses ScopeNotFound (404).
 439            [ScopeMessages.GoogleSignInUpdatedSuccessfully] = HttpStatusCodes.Ok,
 440            // UC-47 toggle main flow — self-registration opened or closed. Shares ScopeNotFound (404),
 441            // NotScopeOwner and EnabledRequired (400) with UC-24.
 442            [ScopeMessages.SelfRegistrationUpdatedSuccessfully] = HttpStatusCodes.Ok,
 443            // Per-scope email links set. Shares ScopeNotFound (404) and NotScopeOwner (403) with UC-24.
 444            [ScopeMessages.EmailLinksUpdatedSuccessfully] = HttpStatusCodes.Ok,
 445            // A scope email link is not an absolute http(s) URL within the column length.
 446            [ScopeMessages.EmailLinkInvalid] = HttpStatusCodes.BadRequest,
 447            // AF-24b — actor is not an owner of the target scope.
 448            [ScopeMessages.NotScopeOwner] = HttpStatusCodes.Forbidden,
 449            // UC-24 (NFR-10) — the request omitted the value to set.
 450            [ScopeMessages.EnabledRequired] = HttpStatusCodes.BadRequest,
 451            // UC-49 main flow and AF-49c — pending registrations listed, an empty page included.
 452            // AF-49a reuses ScopeNotFound (404), AF-49b NotScopeOwner (403), and the page bounds the
 453            // NFR-10 entries below (400).
 454            [ScopeMessages.PendingRegistrationsRetrieved] = HttpStatusCodes.Ok,
 455            // UC-50 main flow — the registration was discarded. AF-50a reuses ScopeNotFound (404) and
 456            // AF-50b NotScopeOwner (403).
 457            [ScopeMessages.PendingRegistrationDiscarded] = HttpStatusCodes.Ok,
 458            // AF-50c — not in this scope, never existed, or already confirmed or purged.
 459            [ScopeMessages.PendingRegistrationNotFound] = HttpStatusCodes.NotFound,
 460            // UC-02 read b (NFR-10) — invalid pagination or an over-length name filter.
 461            [PaginationMessages.InvalidPageNumber] = HttpStatusCodes.BadRequest,
 462            [PaginationMessages.InvalidPageSize] = HttpStatusCodes.BadRequest,
 463            [PaginationMessages.FilterTooLong] = HttpStatusCodes.BadRequest,
 464            // AF-03e/f/g (NFR-23) — the tenant's declared basis or notice URI is not usable.
 465            [ScopeMessages.ConsentBasisNotSupported] = HttpStatusCodes.BadRequest,
 466            [ScopeMessages.PrivacyNoticeUriInvalid] = HttpStatusCodes.BadRequest,
 467            [ScopeMessages.LegalBasisUnknown] = HttpStatusCodes.BadRequest
 468        });
 69}

Methods/Properties

.cctor()