< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Jwt.JwtInspector
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Jwt/JwtInspector.cs
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 47
Line coverage: 100%
Branch coverage
70%
Covered branches: 7
Total branches: 10
Branch coverage: 70%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 09/08/2025 - 20:34:03 Line coverage: 100% (19/19) Branch coverage: 70% (7/10) Total lines: 47 Tag: Kestrun/Kestrun@3790ee5884494a7a2a829344a47743e0bf492e72 09/08/2025 - 20:34:03 Line coverage: 100% (19/19) Branch coverage: 70% (7/10) Total lines: 47 Tag: Kestrun/Kestrun@3790ee5884494a7a2a829344a47743e0bf492e72

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ReadAllParameters(...)70%1010100%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Jwt/JwtInspector.cs

#LineLine coverage
 1using System.IdentityModel.Tokens.Jwt;
 2
 3namespace Kestrun.Jwt;
 4/// <summary>
 5/// Provides methods for inspecting and extracting parameters from JWT tokens.
 6/// </summary>
 7public static class JwtInspector
 8{
 9    /// <summary>
 10    /// Reads out every header field, standard property, and claim from a compact JWT.
 11    /// </summary>
 12    public static JwtParameters ReadAllParameters(string token)
 13    {
 1114        var handler = new JwtSecurityTokenHandler();
 15
 16        // parse without validating signature or lifetime
 1117        var jwt = handler.ReadJwtToken(token);
 18
 1119        var result = new JwtParameters
 1120        {
 1121            Issuer = jwt.Issuer,
 1122            Audiences = jwt.Audiences,
 1123            Subject = jwt.Subject,
 1124            NotBefore = jwt.ValidFrom == DateTime.MinValue ? null : jwt.ValidFrom,
 1125            Expires = jwt.ValidTo == DateTime.MinValue ? null : jwt.ValidTo,
 1126            IssuedAt = jwt.Payload.IssuedAt == DateTime.MinValue ? null : jwt.Payload.IssuedAt,
 1127            Algorithm = jwt.SignatureAlgorithm,
 1128            Type = jwt.Header.Typ,
 1129            KeyId = jwt.Header.Kid
 1130        };
 31
 32        // copy all header entries
 9633        foreach (var kv in jwt.Header)
 34        {
 3735            result.Header[kv.Key] = kv.Value;
 36        }
 37
 38        // copy all payload claims (including custom ones)
 17439        foreach (var claim in jwt.Claims)
 40        {
 41            // if a claim type can appear multiple times, you might want to handle lists
 7642            result.Claims[claim.Type] = claim.Value;
 43        }
 44
 1145        return result;
 46    }
 47}