< 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: 43
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.Models;
 4using Elsa.ExternalAuthentication.Services;
 5using FastEndpoints;
 6using Microsoft.AspNetCore.Builder;
 7using Microsoft.AspNetCore.RateLimiting;
 8
 9namespace Elsa.ExternalAuthentication.Endpoints.Broker;
 10
 711internal sealed class CompleteCallback(IExternalAuthenticationBroker broker) : ElsaEndpoint<CompleteCallbackRequest>
 12{
 13    public override void Configure()
 14    {
 615        Get("/external-authentication/callback/{connectionKey}");
 616        AllowAnonymous();
 1217        Options(x => x.RequireRateLimiting(ExternalAuthenticationRateLimitPolicyNames.ProviderCallback));
 618    }
 19
 20    public override async Task HandleAsync(CompleteCallbackRequest request, CancellationToken cancellationToken)
 21    {
 922        var parameters = HttpContext.Request.Query.ToDictionary(x => x.Key, x => (IReadOnlyCollection<string>)x.Value.Wh
 123        var result = await broker.CompleteCallbackAsync(Route<string>("connectionKey") ?? request.ConnectionKey ?? strin
 124        if (result.Error is { } error)
 25        {
 026            if (result.RedirectUri is not null)
 27            {
 028                await Send.RedirectAsync(result.RedirectUri.ToString(), false, true);
 029                return;
 30            }
 031            await BrokerEndpointSupport.SendErrorAsync(Send, error, cancellationToken);
 032            return;
 33        }
 34
 135        await Send.RedirectAsync(result.RedirectUri!.ToString(), false, true);
 136    }
 37}
 38
 39internal sealed class CompleteCallbackRequest
 40{
 41    public string? ConnectionKey { get; set; }
 42    public string? State { get; set; }
 43}