| | | 1 | | using ArturRios.Util.Http; |
| | | 2 | | |
| | | 3 | | namespace ArturRios.Heimdall.Shared.Messages; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Maps each <see cref="ScopePermissionMessages" /> value to its HTTP status code, following the |
| | | 7 | | /// UC-31 – UC-35 flows. Passed to the response resolver. The single <see cref="ScopePermissionMessages.NotScopeOwne |
| | | 8 | | /// message covers the scope-ownership refusal for create, retrieve, update, and delete: a scope |
| | | 9 | | /// permission has no owner of its own, so owning the scope is the only authorization there is. |
| | | 10 | | /// UC-35's only refusals are the framework's: 403 from [RoleRequirement], 401 unauthenticated. |
| | | 11 | | /// </summary> |
| | | 12 | | public static class ScopePermissionMessageMap |
| | | 13 | | { |
| | 4 | 14 | | public static readonly IReadOnlyDictionary<string, int> StatusCodes = |
| | 4 | 15 | | DataAccessMessageMap.CombinedWith(new Dictionary<string, int> |
| | 4 | 16 | | { |
| | 4 | 17 | | // UC-31 main flow — scope permission created. |
| | 4 | 18 | | [ScopePermissionMessages.ScopePermissionCreatedSuccessfully] = HttpStatusCodes.Created, |
| | 4 | 19 | | // AF-31a — scope not found. |
| | 4 | 20 | | [ScopePermissionMessages.ScopeNotFound] = HttpStatusCodes.NotFound, |
| | 4 | 21 | | // AF-31e / AF-32e / AF-33e / AF-34e — acting Scope Admin does not own the target scope. |
| | 4 | 22 | | [ScopePermissionMessages.NotScopeOwner] = HttpStatusCodes.Forbidden, |
| | 4 | 23 | | // AF-31d — invalid input. |
| | 4 | 24 | | [ScopePermissionMessages.NameRequired] = HttpStatusCodes.BadRequest, |
| | 4 | 25 | | [ScopePermissionMessages.NameTooLong] = HttpStatusCodes.BadRequest, |
| | 4 | 26 | | [ScopePermissionMessages.DescriptionTooLong] = HttpStatusCodes.BadRequest, |
| | 4 | 27 | | // UC-32 main flow — scope permission(s) retrieved. |
| | 4 | 28 | | [ScopePermissionMessages.ScopePermissionRetrievedSuccessfully] = HttpStatusCodes.Ok, |
| | 4 | 29 | | [ScopePermissionMessages.ScopePermissionsRetrievedSuccessfully] = HttpStatusCodes.Ok, |
| | 4 | 30 | | // AF-32a — scope permission not found. The listing's own 404 reuses ScopeNotFound above. |
| | 4 | 31 | | [ScopePermissionMessages.ScopePermissionNotFound] = HttpStatusCodes.NotFound, |
| | 4 | 32 | | // UC-33 main flow — scope permission updated. AF-33a reuses ScopePermissionNotFound, and |
| | 4 | 33 | | // UC-33's input validation reuses the UC-31 messages. |
| | 4 | 34 | | [ScopePermissionMessages.ScopePermissionUpdatedSuccessfully] = HttpStatusCodes.Ok, |
| | 4 | 35 | | // UC-34 main flow — scope permission logically deleted. AF-34b answers with the same 200, so |
| | 4 | 36 | | // the response's AlreadyDeleted flag is what tells the two paths apart. AF-34a reuses |
| | 4 | 37 | | // ScopePermissionNotFound, and AF-34e reuses NotScopeOwner. |
| | 4 | 38 | | [ScopePermissionMessages.ScopePermissionDeletedSuccessfully] = HttpStatusCodes.Ok, |
| | 4 | 39 | | // UC-35 main flow — scope permission hard deleted. AF-35a reuses ScopePermissionNotFound, and |
| | 4 | 40 | | // UC-35's only other refusals are the framework's: 403 from [RoleRequirement], 401 |
| | 4 | 41 | | // unauthenticated. |
| | 4 | 42 | | [ScopePermissionMessages.ScopePermissionHardDeletedSuccessfully] = HttpStatusCodes.Ok, |
| | 4 | 43 | | // UC-32 read b (NFR-10) — invalid pagination or an over-length name filter. |
| | 4 | 44 | | [PaginationMessages.InvalidPageNumber] = HttpStatusCodes.BadRequest, |
| | 4 | 45 | | [PaginationMessages.InvalidPageSize] = HttpStatusCodes.BadRequest, |
| | 4 | 46 | | [PaginationMessages.FilterTooLong] = HttpStatusCodes.BadRequest |
| | 4 | 47 | | }); |
| | | 48 | | } |