< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Authentication.WindowsAuthOptions
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Authentication/WindowsAuthOptions.cs
Tag: Kestrun/Kestrun@5f1d2b981c9d7292c11fd448428c6ab6c811c5de
Line coverage
96%
Covered lines: 26
Uncovered lines: 1
Coverable lines: 27
Total lines: 82
Line coverage: 96.2%
Branch coverage
66%
Covered branches: 8
Total branches: 12
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 12/12/2025 - 17:27:19 Line coverage: 20% (5/25) Branch coverage: 0% (0/12) Total lines: 76 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/21/2025 - 06:07:10 Line coverage: 22.2% (6/27) Branch coverage: 0% (0/12) Total lines: 82 Tag: Kestrun/Kestrun@8cf7f77e55fd1fd046ea4e5413eb9ef96e49fe6a03/26/2026 - 03:54:59 Line coverage: 96.2% (26/27) Branch coverage: 66.6% (8/12) Total lines: 82 Tag: Kestrun/Kestrun@844b5179fb0492dc6b1182bae3ff65fa7365521d 12/12/2025 - 17:27:19 Line coverage: 20% (5/25) Branch coverage: 0% (0/12) Total lines: 76 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/21/2025 - 06:07:10 Line coverage: 22.2% (6/27) Branch coverage: 0% (0/12) Total lines: 82 Tag: Kestrun/Kestrun@8cf7f77e55fd1fd046ea4e5413eb9ef96e49fe6a03/26/2026 - 03:54:59 Line coverage: 96.2% (26/27) Branch coverage: 66.6% (8/12) Total lines: 82 Tag: Kestrun/Kestrun@844b5179fb0492dc6b1182bae3ff65fa7365521d

Coverage delta

Coverage delta 74 -74

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Host()100%11100%
get_GlobalScheme()100%11100%
get_Description()100%11100%
get_DocumentationId()100%11100%
get_DisplayName()100%11100%
get_Protocol()100%11100%
get_Logger()75%44100%
get_Deprecated()100%11100%
ApplyTo(...)100%11100%
ApplyTo(...)62.5%8890.91%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Authentication/WindowsAuthOptions.cs

#LineLine coverage
 1using System.Reflection;
 2using Kestrun.Hosting;
 3using Microsoft.AspNetCore.Authentication.Negotiate;
 4
 5namespace Kestrun.Authentication;
 6
 7/// <summary>
 8/// Options for Windows Authentication.
 9/// </summary>
 10public class WindowsAuthOptions : NegotiateOptions, IOpenApiAuthenticationOptions, IAuthenticationHostOptions
 11{
 12    /// <inheritdoc/>
 713    public KestrunHost Host { get; set; } = default!;
 14
 15    /// <inheritdoc/>
 516    public bool GlobalScheme { get; set; }
 17
 18    /// <inheritdoc/>
 519    public string? Description { get; set; }
 20
 21    /// <inheritdoc/>
 1322    public string[] DocumentationId { get; set; } = [];
 23
 24    /// <inheritdoc/>
 425    public string? DisplayName { get; set; }
 26
 27    /// <summary>
 28    /// The protocol to use for Windows Authentication.
 29    /// </summary>
 130    public WindowsAuthProtocol Protocol { get; set; } = WindowsAuthProtocol.Negotiate;
 31
 32    /// <inheritdoc/>
 33    private Serilog.ILogger? _logger;
 34
 35    /// <inheritdoc/>
 36    public Serilog.ILogger Logger
 37    {
 338        get => _logger ?? (Host is null ? Serilog.Log.Logger : Host.Logger); set => _logger = value;
 39    }
 40
 41    /// <inheritdoc/>
 542    public bool Deprecated { get; set; }
 43
 44    /// <summary>
 45    /// Helper to copy values from a user-supplied WindowsAuthOptions instance to the instance
 46    /// </summary>
 47    /// <param name="target"></param>
 48    public void ApplyTo(WindowsAuthOptions target)
 49    {
 150        ApplyTo((NegotiateOptions)target);
 151        target.GlobalScheme = GlobalScheme;
 152        target.Description = Description;
 153        target.DocumentationId = DocumentationId;
 154        target.DisplayName = DisplayName;
 155        target.Host = Host;
 156        target.Deprecated = Deprecated;
 157    }
 58
 59    /// <summary>
 60    /// Helper to copy values from a user-supplied WindowsAuthOptions instance to the instance
 61    /// </summary>
 62    /// <param name="target"></param>
 63    public void ApplyTo(NegotiateOptions target)
 64    {
 265        target.PersistKerberosCredentials = PersistKerberosCredentials;
 266        target.PersistNtlmCredentials = PersistNtlmCredentials;
 67
 268        var ldapSettingsProp = typeof(NegotiateOptions)
 269            .GetProperty("LdapSettings", BindingFlags.Instance | BindingFlags.NonPublic);
 70
 271        if (ldapSettingsProp?.GetValue(target) is object ldapSettings)
 72        {
 273            var domainProp = ldapSettings.GetType()
 274                .GetProperty("Domain", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
 275            var domain = domainProp?.GetValue(ldapSettings) as string;
 276            if (!string.IsNullOrEmpty(domain))
 77            {
 078                target.EnableLdap(domain);
 79            }
 80        }
 281    }
 82}