< 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@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
20%
Covered lines: 5
Uncovered lines: 20
Coverable lines: 25
Total lines: 76
Line coverage: 20%
Branch coverage
0%
Covered branches: 0
Total branches: 12
Branch coverage: 0%
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@826bf9dcf9db118c5de4c78a3259bce9549f0dcd 12/12/2025 - 17:27:19 Line coverage: 20% (5/25) Branch coverage: 0% (0/12) Total lines: 76 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd

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%210%
get_Protocol()100%11100%
get_Logger()0%2040%
ApplyTo(...)100%210%
ApplyTo(...)0%7280%

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/>
 113    public KestrunHost Host { get; set; } = default!;
 14
 15    /// <inheritdoc/>
 116    public bool GlobalScheme { get; set; }
 17
 18    /// <inheritdoc/>
 119    public string? Description { get; set; }
 20
 21    /// <inheritdoc/>
 522    public string[] DocumentationId { get; set; } = [];
 23
 24    /// <inheritdoc/>
 025    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    private Serilog.ILogger? _logger;
 33    /// <inheritdoc/>
 34    public Serilog.ILogger Logger
 35    {
 036        get => _logger ?? (Host is null ? Serilog.Log.Logger : Host.Logger); set => _logger = value;
 37    }
 38
 39    /// <summary>
 40    /// Helper to copy values from a user-supplied WindowsAuthOptions instance to the instance
 41    /// </summary>
 42    /// <param name="target"></param>
 43    public void ApplyTo(WindowsAuthOptions target)
 44    {
 045        ApplyTo((NegotiateOptions)target);
 046        target.GlobalScheme = GlobalScheme;
 047        target.Description = Description;
 048        target.DocumentationId = DocumentationId;
 049        target.DisplayName = DisplayName;
 050        target.Host = Host;
 051    }
 52
 53    /// <summary>
 54    /// Helper to copy values from a user-supplied WindowsAuthOptions instance to the instance
 55    /// </summary>
 56    /// <param name="target"></param>
 57    public void ApplyTo(NegotiateOptions target)
 58    {
 059        target.PersistKerberosCredentials = PersistKerberosCredentials;
 060        target.PersistNtlmCredentials = PersistNtlmCredentials;
 61
 062        var ldapSettingsProp = typeof(NegotiateOptions)
 063            .GetProperty("LdapSettings", BindingFlags.Instance | BindingFlags.NonPublic);
 64
 065        if (ldapSettingsProp?.GetValue(target) is object ldapSettings)
 66        {
 067            var domainProp = ldapSettings.GetType()
 068                .GetProperty("Domain", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
 069            var domain = domainProp?.GetValue(ldapSettings) as string;
 070            if (!string.IsNullOrEmpty(domain))
 71            {
 072                target.EnableLdap(domain);
 73            }
 74        }
 075    }
 76}