< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Command.Services.PersonEmailAuthorization
Assembly: ArturRios.Heimdall.Command
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Application/ArturRios.Heimdall.Command/Services/PersonEmailAuthorization.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 36
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage
100%
Covered methods: 1
Fully covered methods: 1
Total methods: 1
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ActorMayEmailAsync()100%88100%

File(s)

/home/runner/work/heimdall-api/heimdall-api/src/Application/ArturRios.Heimdall.Command/Services/PersonEmailAuthorization.cs

#LineLine coverage
 1using ArturRios.Heimdall.Domain.Entities;
 2using ArturRios.Heimdall.Domain.Enums;
 3using ArturRios.Heimdall.Shared.Services;
 4
 5namespace ArturRios.Heimdall.Command.Services;
 6
 7/// <summary>
 8///     Who may have an account email sent to whom (UC-51, UC-52, AF-51b/AF-52b): a System Admin to any
 9///     person; a Scope Admin only to a <c>User</c> of a scope they own. Shared by both use cases so they
 10///     cannot drift apart.
 11/// </summary>
 12public static class PersonEmailAuthorization
 13{
 14    /// <summary>
 15    ///     Whether the actor may act on <paramref name="person" />. A Scope Admin aiming at anyone but a
 16    ///     <c>User</c> is refused without a database read; for a <c>User</c>, ownership of
 17    ///     <c>Person.ScopeId</c> is asked of <paramref name="scopeOwnership" />.
 18    /// </summary>
 19    public static async Task<bool> ActorMayEmailAsync(
 20        IScopeOwnershipChecker scopeOwnership, int actingRole, Guid actingPersonId, Person person)
 21    {
 4722        if (actingRole == (int)Roles.SystemAdmin)
 23        {
 3524            return true;
 25        }
 26
 1227        if (actingRole != (int)Roles.ScopeAdmin
 1228            || person.RoleId != (long)Roles.User
 1229            || person.ScopeId is not { } scopeId)
 30        {
 331            return false;
 32        }
 33
 934        return await scopeOwnership.ActorMayManageScopeAsync(actingRole, actingPersonId, scopeId);
 4735    }
 36}

Methods/Properties

ActorMayEmailAsync()