< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Claims.ClaimPolicyPostConfigurer
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Claims/ClaimPolicyPostConfigurer.cs
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 34
Line coverage: 100%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
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
.ctor(...)100%11100%
PostConfigure(...)75%44100%

File(s)

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

#LineLine coverage
 1using Kestrun.Authentication;
 2using Microsoft.AspNetCore.Authorization;
 3using Microsoft.Extensions.Options;
 4
 5namespace Kestrun.Claims;
 6
 7/// <summary>
 8/// Copies <see cref="ClaimPolicyConfig"/> into <see cref="AuthorizationOptions"/> after configuration.
 9/// </summary>
 10/// <remarks>
 11/// Initializes a new instance of the <see cref="ClaimPolicyPostConfigurer"/> class.
 12/// </remarks>
 13/// <param name="scheme">The authentication scheme name.</param>
 14/// <param name="basics">The options monitor for <see cref="BasicAuthenticationOptions"/>.</param>
 815public sealed class ClaimPolicyPostConfigurer(
 816    string scheme,
 817    IOptionsMonitor<IClaimsCommonOptions> basics)
 18        : IPostConfigureOptions<AuthorizationOptions>
 19{
 820    private readonly string _scheme = scheme;
 821    private readonly IOptionsMonitor<IClaimsCommonOptions> _basics = basics;
 22
 23    /// <summary>
 24    /// Applies the <see cref="ClaimPolicyConfig"/> to the specified <see cref="AuthorizationOptions"/> after configurat
 25    /// </summary>
 26    /// <param name="name">The name of the options instance being configured. May be null.</param>
 27    /// <param name="authz">The <see cref="AuthorizationOptions"/> instance to configure.</param>
 28    public void PostConfigure(string? name, AuthorizationOptions authz)
 29    {
 30        // Only run once for the default options instance
 831        var claimCfg = _basics.Get(_scheme).ClaimPolicyConfig;
 832        claimCfg?.ToAuthzDelegate()?.Invoke(authz);
 833    }
 34}