< Summary

Information
Class: Elsa.Permissions.PermissionDescriptor
Assembly: Elsa.Api.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/common/Elsa.Api.Common/Permissions/PermissionDescriptor.cs
Line coverage
70%
Covered lines: 7
Uncovered lines: 3
Coverable lines: 10
Total lines: 34
Line coverage: 70%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Resource()100%11100%
get_SupportedVerbs()100%11100%
get_DisplayName()100%210%
get_Description()100%210%
get_Category()100%210%
get_Verified()100%11100%
get_NonCoreVerbs()100%11100%
Supports(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/common/Elsa.Api.Common/Permissions/PermissionDescriptor.cs

#LineLine coverage
 1namespace Elsa.Permissions;
 2
 3/// <summary>
 4/// Module-contributed metadata for one resource: what it is called, what it means, and which verbs it
 5/// supports. The catalog built from these descriptors is what lets a role editor render without
 6/// hard-coding permission strings, and what the coverage gate validates endpoint declarations against.
 7/// </summary>
 8/// <param name="Resource">The hierarchical resource path, for example <c>workflows/definitions</c>.</param>
 9/// <param name="SupportedVerbs">
 10/// The verbs this resource accepts. A resource declares either <c>create</c> + <c>update</c>, or
 11/// <c>write</c> — never both. The wildcard is deliberately absent: it is not a verb a user selects.
 12/// </param>
 13/// <param name="DisplayName">A human-readable name for a role editor.</param>
 14/// <param name="Description">What granting this resource allows.</param>
 15/// <param name="Category">A grouping for presentation, such as <c>Workflows</c>.</param>
 16/// <param name="Verified">
 17/// <c>false</c> for an implicit descriptor auto-registered because a module declared a permission that
 18/// resolved to no declared descriptor. The module keeps working and the gap stays visible in the catalog.
 19/// </param>
 10020public sealed record PermissionDescriptor(
 33421    string Resource,
 1122    IReadOnlyCollection<string> SupportedVerbs,
 023    string DisplayName,
 024    string Description,
 025    string Category,
 10026    bool Verified = true)
 27{
 28    /// <summary>The verbs this resource supports that fall outside the recommended core set.</summary>
 129    public IReadOnlyCollection<string> NonCoreVerbs { get; } =
 27330        SupportedVerbs.Where(x => !Authorization.CoreVerbs.IsCore(x)).ToArray();
 31
 32    /// <summary>Whether this resource supports <paramref name="verb"/>.</summary>
 833    public bool Supports(string verb) => SupportedVerbs.Contains(verb, StringComparer.Ordinal);
 34}