< 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@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
10%
Covered lines: 5
Uncovered lines: 41
Coverable lines: 46
Total lines: 113
Line coverage: 10.8%
Branch coverage
0%
Covered branches: 0
Total branches: 8
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: 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@8cf7f77e55fd1fd046ea4e5413eb9ef96e49fe6a 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@8cf7f77e55fd1fd046ea4e5413eb9ef96e49fe6a

Metrics

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

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/>
 017    public string? DisplayName { get; set; }
 18
 19    /// <inheritdoc/>
 220    public bool GlobalScheme { get; set; }
 21
 22    /// <inheritdoc/>
 223    public string? Description { get; set; }
 24
 25    /// <inheritdoc/>
 3326    public string[] DocumentationId { get; set; } = [];
 27
 28    /// <inheritdoc/>
 229    public KestrunHost Host { get; set; } = default!;
 30
 31    /// <inheritdoc/>
 232    public bool Deprecated { get; set; }
 33
 34    private Serilog.ILogger? _logger;
 35    /// <inheritdoc/>
 36    public Serilog.ILogger Logger
 37    {
 038        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    {
 053        ApplyTo((CookieAuthenticationOptions)target);
 054        target.GlobalScheme = GlobalScheme;
 055        target.Description = Description;
 056        target.DocumentationId = DocumentationId;
 057        target.DisplayName = DisplayName;
 058        target.Host = Host;
 059        target.Deprecated = Deprecated;
 060    }
 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
 069        target.LoginPath = LoginPath;
 070        target.LogoutPath = LogoutPath;
 071        target.AccessDeniedPath = AccessDeniedPath;
 072        target.ReturnUrlParameter = ReturnUrlParameter;
 73
 74        // Expiration & sliding behavior
 075        target.ExpireTimeSpan = ExpireTimeSpan;
 076        target.SlidingExpiration = SlidingExpiration;
 77
 78        // Cookie builder settings
 79        // (Cookie is always non-null; copy primitive settings)
 080        if (Cookie.Name is not null)
 81        {
 082            target.Cookie.Name = Cookie.Name;
 083            target.Cookie.Path = Cookie.Path;
 084            target.Cookie.Domain = Cookie.Domain;
 085            target.Cookie.HttpOnly = Cookie.HttpOnly;
 086            target.Cookie.SameSite = Cookie.SameSite;
 087            target.Cookie.SecurePolicy = Cookie.SecurePolicy;
 088            target.Cookie.IsEssential = Cookie.IsEssential;
 089            target.Cookie.MaxAge = Cookie.MaxAge;
 90        }
 91        // Forwarding
 092        target.ForwardAuthenticate = ForwardAuthenticate;
 093        target.ForwardChallenge = ForwardChallenge;
 094        target.ForwardDefault = ForwardDefault;
 095        target.ForwardDefaultSelector = ForwardDefaultSelector;
 096        target.ForwardForbid = ForwardForbid;
 097        target.ForwardSignIn = ForwardSignIn;
 098        target.ForwardSignOut = ForwardSignOut;
 99
 100        // Data protection / ticket / session
 0101        target.TicketDataFormat = TicketDataFormat;
 0102        target.DataProtectionProvider = DataProtectionProvider;
 0103        target.SessionStore = SessionStore;
 104
 105        // Events & issuer
 0106        if (Events is not null)
 107        {
 0108            target.Events = Events;
 109        }
 0110        target.EventsType = EventsType;
 0111        target.ClaimsIssuer = ClaimsIssuer;
 0112    }
 113}