< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Claims.ClaimRule
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Claims/ClaimRule.cs
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
60%
Covered lines: 6
Uncovered lines: 4
Coverable lines: 10
Total lines: 33
Line coverage: 60%
Branch coverage
25%
Covered branches: 2
Total branches: 8
Branch coverage: 25%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ClaimType()100%11100%
get_AllowedValues()100%11100%
.ctor(...)50%44100%
.ctor(...)0%2040%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Claims/ClaimRule.cs

#LineLine coverage
 1namespace Kestrun.Claims;
 2
 3
 4/// <summary>Represents one claim must equal rule.</summary>
 5/// <remarks>
 6/// This is used to define authorization policies that require a specific claim type
 7/// with specific allowed values.
 8/// It is typically used in conjunction with <see cref="ClaimPolicyConfig"/> to define
 9/// multiple policies.
 10/// </remarks>
 11public sealed record ClaimRule
 12{
 13    /// <summary>The claim type required by this rule.</summary>
 1714    public string ClaimType { get; }
 15
 16    /// <summary>Allowed values for the claim. Exposed as a read-only sequence.</summary>
 1717    public IReadOnlyList<string> AllowedValues { get; }
 18
 19    /// <summary>Constructs a rule from a claim type and one or more allowed values.</summary>
 2120    public ClaimRule(string claimType, params string[] allowedValues)
 21    {
 2122        ClaimType = claimType ?? throw new ArgumentNullException(nameof(claimType));
 23        // Make a defensive copy to avoid exposing caller-owned mutable arrays.
 2124        AllowedValues = (allowedValues is null) ? Array.Empty<string>() : Array.AsReadOnly((string[])allowedValues.Clone
 2125    }
 26
 27    /// <summary>Constructs a rule from a claim type and an explicit read-only list of values.</summary>
 028    public ClaimRule(string claimType, IReadOnlyList<string> allowedValues)
 29    {
 030        ClaimType = claimType ?? throw new ArgumentNullException(nameof(claimType));
 031        AllowedValues = allowedValues ?? [];
 032    }
 33}