< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Command.Services.PasswordResetOptions
Assembly: ArturRios.Heimdall.Command
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Application/ArturRios.Heimdall.Command/Services/PasswordResetOptions.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 24
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
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
get_TokenLifetime()100%11100%
FromEnvironment()50%22100%

File(s)

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

#LineLine coverage
 1namespace ArturRios.Heimdall.Command.Services;
 2
 3/// <summary>
 4///     Settings for password reset token issuance (UC-12, FR-PR-02). <see cref="TokenLifetime" /> is
 5///     read from the environment (seconds) with a one-hour default — far shorter than the
 6///     verification token's day, since this one is what stands between an intercepted mailbox and a
 7///     changed password.
 8/// </summary>
 9public class PasswordResetOptions
 10{
 11    private const string LifetimeVariable = "HEIMDALL_PASSWORD_RESET_TOKEN_EXPIRATION_IN_SECONDS";
 12    private const double DefaultLifetimeSeconds = 3600;
 13
 195214    public TimeSpan TokenLifetime { get; init; } = TimeSpan.FromSeconds(DefaultLifetimeSeconds);
 15
 16    public static PasswordResetOptions FromEnvironment()
 17    {
 89918        var seconds = double.TryParse(Environment.GetEnvironmentVariable(LifetimeVariable), out var configured)
 89919            ? configured
 89920            : DefaultLifetimeSeconds;
 21
 89922        return new PasswordResetOptions { TokenLifetime = TimeSpan.FromSeconds(seconds) };
 23    }
 24}