< Summary

Information
Class: Elsa.Identity.Endpoints.Roles.Delete.RoleDeletionImpactResponse
Assembly: Elsa.Identity
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Endpoints/Roles/Delete/Models.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 19
Coverable lines: 19
Total lines: 61
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
get_RoleId()100%210%
get_DependencyVersion()100%210%
get_ExecutionMode()100%210%
get_CanDelete()100%210%
get_CanRemediate()100%210%
get_ConfigurationReferences()100%210%
get_EditableReferences()100%210%
get_Warnings()100%210%
From(...)0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Endpoints/Roles/Delete/Models.cs

#LineLine coverage
 1using Elsa.Identity.Models;
 2
 3namespace Elsa.Identity.Endpoints.Roles.Delete;
 4
 5internal sealed class RemediateRoleDeletionRequest
 6{
 7    public string? ExpectedDependencyVersion { get; set; }
 8    public bool ConfirmRemoveFromEditableJitPolicies { get; set; }
 9    public bool ConfirmEmptyDefaultRoles { get; set; }
 10    public bool ConfirmBestEffort { get; set; }
 11    public IReadOnlyCollection<RoleDeletionReferenceSelection>? SelectedReferences { get; set; }
 12    public string? ReplacementRoleId { get; set; }
 13}
 14
 15internal sealed record RoleDeletionErrorResponse(string Error, string Message, object? Details = null);
 16
 017internal sealed record RoleDeletionImpactResponse(
 018    string RoleId,
 019    string DependencyVersion,
 020    string ExecutionMode,
 021    bool CanDelete,
 022    bool CanRemediate,
 023    IReadOnlyCollection<RoleDeletionDependencyResponse> ConfigurationReferences,
 024    IReadOnlyCollection<RoleDeletionDependencyResponse> EditableReferences,
 025    IReadOnlyCollection<string> Warnings)
 26{
 27    public static RoleDeletionImpactResponse From(RoleDeletionImpact impact)
 28    {
 029        var references = impact.Dependencies.Select(RoleDeletionDependencyResponse.From).ToArray();
 030        return new RoleDeletionImpactResponse(
 031            impact.RoleId,
 032            impact.DependencyVersion,
 033            impact.ExecutionMode == RoleDeletionExecutionMode.Atomic ? "atomic" : "bestEffort",
 034            impact.CanDelete,
 035            impact.CanRemediate,
 036            references.Where(x => x.Ownership == "configuration").ToArray(),
 037            references.Where(x => x.Ownership == "database").ToArray(),
 038            impact.Dependencies.Any(x => x.RemovesLastDefaultRole) ? ["removes_last_default_role"] : []);
 39    }
 40}
 41
 42internal sealed record RoleDeletionDependencyResponse(
 43    string Source,
 44    string OwnerId,
 45    string OwnerKey,
 46    string PolicyBranch,
 47    string Ownership,
 48    string? ConfigurationPath,
 49    long? Revision,
 50    bool RemovesLastDefaultRole)
 51{
 52    public static RoleDeletionDependencyResponse From(RoleDeletionDependency dependency) => new(
 53        dependency.Source,
 54        dependency.OwnerId,
 55        dependency.OwnerKey,
 56        dependency.PolicyBranch,
 57        dependency.Ownership == RoleDeletionDependencyOwnership.Configuration ? "configuration" : "database",
 58        dependency.ConfigurationPath,
 59        dependency.ExpectedRevision,
 60        dependency.RemovesLastDefaultRole);
 61}