< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Command.Input.Validation.EnableTwoFactorAuthCommandValidator
Assembly: ArturRios.Heimdall.Command
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Application/ArturRios.Heimdall.Command/Input/Validation/EnableTwoFactorAuthCommandValidator.cs
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 23
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage
100%
Covered methods: 2
Fully covered methods: 2
Total methods: 2
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor()100%44100%

File(s)

/home/runner/work/heimdall-api/heimdall-api/src/Application/ArturRios.Heimdall.Command/Input/Validation/EnableTwoFactorAuthCommandValidator.cs

#LineLine coverage
 1using ArturRios.Heimdall.Shared.Messages;
 2using FluentValidation;
 3
 4namespace ArturRios.Heimdall.Command.Input.Validation;
 5
 6/// <summary>
 7///     Shape validation for <see cref="EnableTwoFactorAuthCommand" /> (UC-36, AF-36c): at least one
 8///     of <c>"App"</c>/<c>"Email"</c> must be selected, and nothing else. Eligibility (AF-36b) and
 9///     the already-active check (AF-36a) are enforced by the handler, since both need a database
 10///     read the validator has no business making.
 11/// </summary>
 12public class EnableTwoFactorAuthCommandValidator : AbstractValidator<EnableTwoFactorAuthCommand>
 13{
 214    private static readonly string[] KnownMethods = ["App", "Email"];
 15
 5116    public EnableTwoFactorAuthCommandValidator()
 17    {
 5118        RuleFor(command => command.Methods)
 5119            .Must(methods => methods is { Count: > 0 } &&
 10820                              methods.All(method => KnownMethods.Contains(method, StringComparer.OrdinalIgnoreCase)))
 5121            .WithMessage(TwoFactorMessages.NoMethodSelected);
 5122    }
 23}

Methods/Properties

.cctor()
.ctor()