< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Authentication.CookieAuthOptions
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Authentication/CookieAuthOptions.cs
Tag: Kestrun/Kestrun@5f1d2b981c9d7292c11fd448428c6ab6c811c5de
Line coverage
97%
Covered lines: 45
Uncovered lines: 1
Coverable lines: 46
Total lines: 113
Line coverage: 97.8%
Branch coverage
87%
Covered branches: 7
Total branches: 8
Branch coverage: 87.5%
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: 9% (4/44) Branch coverage: 0% (0/8) Total lines: 109 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/21/2025 - 06:07:10 Line coverage: 10.8% (5/46) Branch coverage: 0% (0/8) Total lines: 113 Tag: Kestrun/Kestrun@8cf7f77e55fd1fd046ea4e5413eb9ef96e49fe6a03/26/2026 - 03:54:59 Line coverage: 97.8% (45/46) Branch coverage: 87.5% (7/8) Total lines: 113 Tag: Kestrun/Kestrun@844b5179fb0492dc6b1182bae3ff65fa7365521d 12/12/2025 - 17:27:19 Line coverage: 9% (4/44) Branch coverage: 0% (0/8) Total lines: 109 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/21/2025 - 06:07:10 Line coverage: 10.8% (5/46) Branch coverage: 0% (0/8) Total lines: 113 Tag: Kestrun/Kestrun@8cf7f77e55fd1fd046ea4e5413eb9ef96e49fe6a03/26/2026 - 03:54:59 Line coverage: 97.8% (45/46) Branch coverage: 87.5% (7/8) Total lines: 113 Tag: Kestrun/Kestrun@844b5179fb0492dc6b1182bae3ff65fa7365521d

Coverage delta

Coverage delta 88 -88

Metrics

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

File(s)

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

#LineLine coverage
 1using Kestrun.Hosting;
 2using Microsoft.AspNetCore.Authentication.Cookies;
 3
 4namespace Kestrun.Authentication;
 5
 6/// <summary>
 7/// Options for cookie-based authentication.
 8/// </summary>
 9public class CookieAuthOptions : CookieAuthenticationOptions, IOpenApiAuthenticationOptions, IAuthenticationHostOptions
 10{
 11    /// <summary>
 12    /// If true, allows cookie authentication over insecure HTTP connections.
 13    /// </summary>
 014    public bool AllowInsecureHttp { get; set; }
 15
 16    /// <inheritdoc/>
 617    public string? DisplayName { get; set; }
 18
 19    /// <inheritdoc/>
 820    public bool GlobalScheme { get; set; }
 21
 22    /// <inheritdoc/>
 823    public string? Description { get; set; }
 24
 25    /// <inheritdoc/>
 6526    public string[] DocumentationId { get; set; } = [];
 27
 28    /// <inheritdoc/>
 1029    public KestrunHost Host { get; set; } = default!;
 30
 31    /// <inheritdoc/>
 832    public bool Deprecated { get; set; }
 33
 34    private Serilog.ILogger? _logger;
 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    /// <summary>
 42    /// Helper to copy values from a user-supplied CookieAuthenticationOptions instance to the instance
 43    /// created by the framework inside AddCookie(). Reassigning the local variable (opts = source) would
 44    /// not work because only the local reference changes – the framework keeps the original instance.
 45    /// </summary>
 46    /// <param name="target">The target options to copy to.</param>
 47    /// <exception cref="ArgumentNullException">Thrown when source or target is null.</exception>
 48    /// <remarks>
 49    /// Only copies primitive properties and references. Does not clone complex objects like CookieBuilder.
 50    /// </remarks>
 51    public void ApplyTo(CookieAuthOptions target)
 52    {
 253        ApplyTo((CookieAuthenticationOptions)target);
 254        target.GlobalScheme = GlobalScheme;
 255        target.Description = Description;
 256        target.DocumentationId = DocumentationId;
 257        target.DisplayName = DisplayName;
 258        target.Host = Host;
 259        target.Deprecated = Deprecated;
 260    }
 61
 62    /// <summary>
 63    /// Helper to copy values from this CookieAuthOptions instance to a target CookieAuthenticationOptions instance.
 64    /// </summary>
 65    /// <param name="target">The target CookieAuthenticationOptions instance to copy values to.</param>
 66    public void ApplyTo(CookieAuthenticationOptions target)
 67    {
 68        // Paths & return URL
 469        target.LoginPath = LoginPath;
 470        target.LogoutPath = LogoutPath;
 471        target.AccessDeniedPath = AccessDeniedPath;
 472        target.ReturnUrlParameter = ReturnUrlParameter;
 73
 74        // Expiration & sliding behavior
 475        target.ExpireTimeSpan = ExpireTimeSpan;
 476        target.SlidingExpiration = SlidingExpiration;
 77
 78        // Cookie builder settings
 79        // (Cookie is always non-null; copy primitive settings)
 480        if (Cookie.Name is not null)
 81        {
 382            target.Cookie.Name = Cookie.Name;
 383            target.Cookie.Path = Cookie.Path;
 384            target.Cookie.Domain = Cookie.Domain;
 385            target.Cookie.HttpOnly = Cookie.HttpOnly;
 386            target.Cookie.SameSite = Cookie.SameSite;
 387            target.Cookie.SecurePolicy = Cookie.SecurePolicy;
 388            target.Cookie.IsEssential = Cookie.IsEssential;
 389            target.Cookie.MaxAge = Cookie.MaxAge;
 90        }
 91        // Forwarding
 492        target.ForwardAuthenticate = ForwardAuthenticate;
 493        target.ForwardChallenge = ForwardChallenge;
 494        target.ForwardDefault = ForwardDefault;
 495        target.ForwardDefaultSelector = ForwardDefaultSelector;
 496        target.ForwardForbid = ForwardForbid;
 497        target.ForwardSignIn = ForwardSignIn;
 498        target.ForwardSignOut = ForwardSignOut;
 99
 100        // Data protection / ticket / session
 4101        target.TicketDataFormat = TicketDataFormat;
 4102        target.DataProtectionProvider = DataProtectionProvider;
 4103        target.SessionStore = SessionStore;
 104
 105        // Events & issuer
 4106        if (Events is not null)
 107        {
 4108            target.Events = Events;
 109        }
 4110        target.EventsType = EventsType;
 4111        target.ClaimsIssuer = ClaimsIssuer;
 4112    }
 113}