< Summary

Information
Class: Elsa.ExternalAuthentication.Services.ExternalAuthenticationCallbackUris
Assembly: Elsa.ExternalAuthentication
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Services/ExternalAuthenticationCallbackUris.cs
Line coverage
93%
Covered lines: 15
Uncovered lines: 1
Coverable lines: 16
Total lines: 33
Line coverage: 93.7%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetAuthorizationCallbackUri(...)75%4483.33%
GetLogoutCallbackUri(...)100%11100%
AppendPath(...)50%22100%

File(s)

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

#LineLine coverage
 1using Elsa.ExternalAuthentication.Models;
 2
 3namespace Elsa.ExternalAuthentication.Services;
 4
 5/// <summary>Builds Elsa-owned upstream callback URIs without allowing a configured base path to be discarded.</summary>
 6public static class ExternalAuthenticationCallbackUris
 7{
 8    /// <summary>Returns the provider callback for a normal external sign-in or an administrator preview.</summary>
 1009    public static Uri GetAuthorizationCallbackUri(Uri externalCallbackBaseUri, IdentityProviderConnection connection, Br
 10010    {
 5411        BrokerTransactionPurpose.ExternalSignIn => AppendPath(externalCallbackBaseUri, $"external-authentication/callbac
 4612        BrokerTransactionPurpose.Preview => AppendPath(externalCallbackBaseUri, $"external-authentication/previews/callb
 013        _ => throw new InvalidOperationException($"Broker transaction purpose '{purpose}' cannot initiate an upstream au
 10014    };
 15
 16    /// <summary>Returns the provider callback for a broker-initiated upstream logout.</summary>
 17    public static Uri GetLogoutCallbackUri(Uri externalCallbackBaseUri, string connectionKey) =>
 218        AppendPath(externalCallbackBaseUri, $"external-authentication/logout/callback/{Uri.EscapeDataString(ConnectionRe
 19
 20    private static Uri AppendPath(Uri externalCallbackBaseUri, string relativePath)
 21    {
 10222        ArgumentNullException.ThrowIfNull(externalCallbackBaseUri);
 23
 10224        var builder = new UriBuilder(externalCallbackBaseUri)
 10225        {
 10226            Path = $"{externalCallbackBaseUri.AbsolutePath.TrimEnd('/')}/{relativePath.TrimStart('/')}",
 10227            Query = string.Empty,
 10228            Fragment = string.Empty,
 10229            Port = externalCallbackBaseUri.IsDefaultPort ? -1 : externalCallbackBaseUri.Port
 10230        };
 10231        return builder.Uri;
 32    }
 33}