< 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@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
57%
Covered lines: 8
Uncovered lines: 6
Coverable lines: 14
Total lines: 60
Line coverage: 57.1%
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 08/26/2025 - 14:53:17 Line coverage: 60% (6/10) Branch coverage: 25% (2/8) Total lines: 33 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743112/12/2025 - 17:27:19 Line coverage: 57.1% (8/14) Branch coverage: 25% (2/8) Total lines: 60 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd 08/26/2025 - 14:53:17 Line coverage: 60% (6/10) Branch coverage: 25% (2/8) Total lines: 33 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743112/12/2025 - 17:27:19 Line coverage: 57.1% (8/14) Branch coverage: 25% (2/8) Total lines: 60 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd

Metrics

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

File(s)

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

#LineLine coverage
 1namespace Kestrun.Claims;
 2
 3/// <summary>Represents one claim must equal rule.</summary>
 4/// <remarks>
 5/// This is used to define authorization policies that require a specific claim type
 6/// with specific allowed values.
 7/// It is typically used in conjunction with <see cref="ClaimPolicyConfig"/> to define
 8/// multiple policies.
 9/// </remarks>
 10public sealed record ClaimRule
 11{
 12    /// <summary>
 13    /// The claim type required by this rule.
 14    /// </summary>
 1715    public string ClaimType { get; }
 16
 17    /// <summary>
 18    /// Description of the claim rule.
 19    /// </summary>
 2720    public string? Description { get; set; }
 21
 22    /// <summary>
 23    /// Allowed values for the claim. Exposed as a read-only sequence.
 24    /// </summary>
 1725    public IReadOnlyList<string> AllowedValues { get; }
 26
 27    /// <summary>
 28    /// Constructs a rule from a claim type and one or more allowed values.
 29    /// </summary>
 30    /// <param name="claimType">The claim type required by this rule.</param>
 31    /// <param name="description">Description of the claim rule.</param>
 32    /// <param name="allowedValues">Allowed values for the claim.</param>
 2733    public ClaimRule(string claimType, string? description, params string[] allowedValues)
 34    {
 2735        ClaimType = claimType ?? throw new ArgumentNullException(nameof(claimType));
 2736        Description = description;
 37        // Make a defensive copy to avoid exposing caller-owned mutable arrays.
 2738        AllowedValues = (allowedValues is null) ? Array.Empty<string>() : Array.AsReadOnly((string[])allowedValues.Clone
 2739    }
 40
 41    /// <summary>
 42    /// Constructs a rule from a claim type and an explicit read-only list of values.
 43    /// </summary>
 44    /// <param name="claimType">The claim type required by this rule.</param>
 45    /// <param name="description">Description of the claim rule.</param>
 46    /// <param name="allowedValues">Allowed values for the claim.</param>
 047    public ClaimRule(string claimType, string? description, IReadOnlyList<string> allowedValues)
 48    {
 049        ClaimType = claimType ?? throw new ArgumentNullException(nameof(claimType));
 050        Description = description;
 051        AllowedValues = allowedValues ?? [];
 052    }
 53    /// <summary>
 54    /// Constructs a rule from a claim type and one or more allowed values without description.
 55    /// </summary>
 56    /// <param name="claimType">The claim type required by this rule.</param>
 57    /// <param name="allowedValues">Allowed values for the claim.</param>
 58    public ClaimRule(string claimType, IReadOnlyList<string> allowedValues)
 059        : this(claimType, null, allowedValues) { }
 60}