< Summary

Information
Class: Elsa.ExternalAuthentication.Services.ExternalAuthenticationRedactor
Assembly: Elsa.ExternalAuthentication
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Services/ExternalAuthenticationRedactor.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 34
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
RedactSecret(...)100%11100%
RedactToken(...)100%11100%
RedactProviderResponseBody(...)100%11100%
RedactRawClaims(...)100%11100%
RedactProjectedClaims(...)100%44100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Services/ExternalAuthenticationRedactor.cs

#LineLine coverage
 1namespace Elsa.ExternalAuthentication.Services;
 2
 3/// <summary>
 4/// Centralizes removal of values that must never leave the external-authentication trust boundary.
 5/// </summary>
 6public static class ExternalAuthenticationRedactor
 7{
 8    public const string RedactedValue = "[REDACTED]";
 9
 210    public static string RedactSecret(string? secret) => RedactedValue;
 11
 212    public static string RedactToken(string? token) => RedactedValue;
 13
 214    public static string RedactProviderResponseBody(string? responseBody) => RedactedValue;
 15
 16    public static IReadOnlyDictionary<string, IReadOnlyCollection<string>> RedactRawClaims(IReadOnlyDictionary<string, I
 17    {
 218        return new Dictionary<string, IReadOnlyCollection<string>>(StringComparer.Ordinal);
 19    }
 20
 21    public static IReadOnlyDictionary<string, IReadOnlyCollection<string>> RedactProjectedClaims(
 22        IReadOnlyDictionary<string, IReadOnlyCollection<string>> claims,
 23        IReadOnlySet<string> redactedClaimTypes)
 24    {
 225        ArgumentNullException.ThrowIfNull(claims);
 226        ArgumentNullException.ThrowIfNull(redactedClaimTypes);
 27
 228        var redactedClaims = new Dictionary<string, IReadOnlyCollection<string>>(claims.Count, StringComparer.Ordinal);
 1229        foreach (var (claimType, values) in claims)
 430            redactedClaims[claimType] = redactedClaimTypes.Contains(claimType) ? [RedactedValue] : values.ToArray();
 31
 232        return redactedClaims;
 33    }
 34}