< Summary

Information
Class: Elsa.ExternalAuthentication.Services.IdentityProviderConnectionCloner
Assembly: Elsa.ExternalAuthentication
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Services/IdentityProviderConnectionCloner.cs
Line coverage
97%
Covered lines: 37
Uncovered lines: 1
Coverable lines: 38
Total lines: 51
Line coverage: 97.3%
Branch coverage
64%
Covered branches: 9
Total branches: 14
Branch coverage: 64.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Clone(...)66.66%6696.66%
CloneJson(...)100%22100%
CloneProjection(...)50%66100%

File(s)

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

#LineLine coverage
 1using System.Text.Json;
 2using Elsa.ExternalAuthentication.Models;
 3
 4namespace Elsa.ExternalAuthentication.Services;
 5
 6internal static class IdentityProviderConnectionCloner
 7{
 2638    public static IdentityProviderConnection Clone(IdentityProviderConnection source) => new()
 2639    {
 26310        Id = source.Id,
 26311        TenantId = source.TenantId,
 26312        Key = source.Key,
 26313        AdapterType = source.AdapterType,
 26314        AdapterSettingsVersion = source.AdapterSettingsVersion,
 26315        AdapterSettings = CloneJson(source.AdapterSettings),
 26316        SecretBindings = (source.SecretBindings ?? new Dictionary<string, SecretBinding>())
 6417            .ToDictionary(x => x.Key, x => x.Value with { }, StringComparer.Ordinal),
 26318        DisplayName = source.DisplayName,
 26319        IconId = source.IconId,
 26320        DisplayOrder = source.DisplayOrder,
 26321        IsPreferred = source.IsPreferred,
 26322        IsEnabled = source.IsEnabled,
 26323        OverridesConfigurationConnection = source.OverridesConfigurationConnection,
 26324        ArchivedAt = source.ArchivedAt,
 26325        UnlinkedPolicy = source.UnlinkedPolicy is { } policy
 26326            ? new PolicySelection(policy.Type, policy.SettingsVersion, CloneJson(policy.Settings))
 26327            : null,
 26328        PermissionGrantSources = (source.PermissionGrantSources ?? [])
 029            .Select(x => new GrantSourceSelection(x.Type, x.SettingsVersion, CloneJson(x.Settings), x.Order))
 26330            .ToArray(),
 26331        ClaimProjection = CloneProjection(source.ClaimProjection),
 26332        UpstreamLogoutMode = source.UpstreamLogoutMode,
 26333        Revision = source.Revision,
 26334        MaterialRevision = source.MaterialRevision,
 26335        CreatedAt = source.CreatedAt,
 26336        UpdatedAt = source.UpdatedAt
 26337    };
 38
 30839    public static JsonElement CloneJson(JsonElement value) => value.ValueKind == JsonValueKind.Undefined ? default : val
 40
 41    private static ClaimProjection CloneProjection(ClaimProjection? source)
 42    {
 26343        source ??= ClaimProjection.Empty;
 26344        return new ClaimProjection(
 26345            new HashSet<string>(source.AllowedClaimTypes ?? new HashSet<string>(), StringComparer.Ordinal),
 26346            new HashSet<string>(source.RedactedClaimTypes ?? new HashSet<string>(), StringComparer.Ordinal),
 26347            source.MaximumClaimCount,
 26348            source.MaximumValueLength,
 26349            source.MaximumTotalBytes);
 50    }
 51}