< Summary

Information
Class: Elsa.ExternalAuthentication.Endpoints.Broker.CompleteCallback
Assembly: Elsa.ExternalAuthentication
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Endpoints/Broker/CompleteCallback.cs
Line coverage
66%
Covered lines: 10
Uncovered lines: 5
Coverable lines: 15
Total lines: 40
Line coverage: 66.6%
Branch coverage
41%
Covered branches: 5
Total branches: 12
Branch coverage: 41.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Configure()100%11100%
HandleAsync()41.66%371244.44%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Endpoints/Broker/CompleteCallback.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.ExternalAuthentication.Constants;
 3using Elsa.ExternalAuthentication.Services;
 4using Microsoft.AspNetCore.Builder;
 5
 6namespace Elsa.ExternalAuthentication.Endpoints.Broker;
 7
 108internal sealed class CompleteCallback(IExternalAuthenticationBroker broker) : ElsaEndpoint<CompleteCallbackRequest>
 9{
 10    public override void Configure()
 11    {
 912        Get("/external-authentication/callback/{connectionKey}");
 913        AllowAnonymous();
 1814        Options(x => x.RequireRateLimiting(ExternalAuthenticationRateLimitPolicyNames.ProviderCallback));
 915    }
 16
 17    public override async Task HandleAsync(CompleteCallbackRequest request, CancellationToken cancellationToken)
 18    {
 919        var parameters = HttpContext.Request.Query.ToDictionary(x => x.Key, x => (IReadOnlyCollection<string>)x.Value.Wh
 120        var result = await broker.CompleteCallbackAsync(Route<string>("connectionKey") ?? request.ConnectionKey ?? strin
 121        if (result.Error is { } error)
 22        {
 023            if (result.RedirectUri is not null)
 24            {
 025                await Send.RedirectAsync(result.RedirectUri.ToString(), false, true);
 026                return;
 27            }
 028            await BrokerEndpointSupport.SendErrorAsync(Send, error, cancellationToken);
 029            return;
 30        }
 31
 132        await Send.RedirectAsync(result.RedirectUri!.ToString(), false, true);
 133    }
 34}
 35
 36internal sealed class CompleteCallbackRequest
 37{
 38    public string? ConnectionKey { get; set; }
 39    public string? State { get; set; }
 40}