< Summary

Information
Class: Elsa.Identity.Endpoints.Roles.Delete.RoleDeletionDependencyResponse
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: 18
Coverable lines: 18
Total lines: 59
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
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_Source()100%210%
get_OwnerId()100%210%
get_OwnerKey()100%210%
get_PolicyBranch()100%210%
get_Ownership()100%210%
get_ConfigurationPath()100%210%
get_Revision()100%210%
get_RemovesLastDefaultRole()100%210%
From(...)0%620%

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}
 12
 13internal sealed record RoleDeletionErrorResponse(string Error, string Message, object? Details = null);
 14
 15internal sealed record RoleDeletionImpactResponse(
 16    string RoleId,
 17    string DependencyVersion,
 18    string ExecutionMode,
 19    bool CanDelete,
 20    bool CanRemediate,
 21    IReadOnlyCollection<RoleDeletionDependencyResponse> ConfigurationReferences,
 22    IReadOnlyCollection<RoleDeletionDependencyResponse> EditableReferences,
 23    IReadOnlyCollection<string> Warnings)
 24{
 25    public static RoleDeletionImpactResponse From(RoleDeletionImpact impact)
 26    {
 27        var references = impact.Dependencies.Select(RoleDeletionDependencyResponse.From).ToArray();
 28        return new RoleDeletionImpactResponse(
 29            impact.RoleId,
 30            impact.DependencyVersion,
 31            impact.ExecutionMode == RoleDeletionExecutionMode.Atomic ? "atomic" : "bestEffort",
 32            impact.CanDelete,
 33            impact.CanRemediate,
 34            references.Where(x => x.Ownership == "configuration").ToArray(),
 35            references.Where(x => x.Ownership == "database").ToArray(),
 36            impact.Dependencies.Any(x => x.RemovesLastDefaultRole) ? ["removes_last_default_role"] : []);
 37    }
 38}
 39
 040internal sealed record RoleDeletionDependencyResponse(
 041    string Source,
 042    string OwnerId,
 043    string OwnerKey,
 044    string PolicyBranch,
 045    string Ownership,
 046    string? ConfigurationPath,
 047    long? Revision,
 048    bool RemovesLastDefaultRole)
 49{
 050    public static RoleDeletionDependencyResponse From(RoleDeletionDependency dependency) => new(
 051        dependency.Source,
 052        dependency.OwnerId,
 053        dependency.OwnerKey,
 054        dependency.PolicyBranch,
 055        dependency.Ownership == RoleDeletionDependencyOwnership.Configuration ? "configuration" : "database",
 056        dependency.ConfigurationPath,
 057        dependency.ExpectedRevision,
 058        dependency.RemovesLastDefaultRole);
 59}