< Summary

Information
Class: Elsa.Authorization.EndpointPermissionRegistry
Assembly: Elsa.Api.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/common/Elsa.Api.Common/Authorization/EndpointPermissionRegistry.cs
Line coverage
50%
Covered lines: 2
Uncovered lines: 2
Coverable lines: 4
Total lines: 26
Line coverage: 50%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
Record(...)100%11100%
Find(...)0%620%
get_All()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/common/Elsa.Api.Common/Authorization/EndpointPermissionRegistry.cs

#LineLine coverage
 1using System.Collections.Concurrent;
 2
 3namespace Elsa.Authorization;
 4
 5/// <summary>
 6/// Records the permission each endpoint declares, keyed by endpoint type.
 7/// </summary>
 8/// <remarks>
 9/// The requirement itself is attached as an inline authorization policy, which is not readable back from
 10/// the endpoint definition. Recording it here keeps the declaration introspectable: it is what lets a
 11/// deployment answer "what does this endpoint require" without reading source, and it gives tests a way to
 12/// assert a specific requirement rather than merely that one exists.
 13/// </remarks>
 14public static class EndpointPermissionRegistry
 15{
 116    private static readonly ConcurrentDictionary<Type, Permission> Declared = new();
 17
 18    /// <summary>Records that <paramref name="endpointType"/> requires <paramref name="permission"/>.</summary>
 31219    public static void Record(Type endpointType, Permission permission) => Declared[endpointType] = permission;
 20
 21    /// <summary>The permission <paramref name="endpointType"/> declares, if it declares one.</summary>
 022    public static Permission? Find(Type endpointType) => Declared.TryGetValue(endpointType, out var permission) ? permis
 23
 24    /// <summary>Every recorded declaration.</summary>
 025    public static IReadOnlyDictionary<Type, Permission> All => Declared;
 26}