mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-03-24 17:13:41 -04:00
34 lines
955 B
C#
34 lines
955 B
C#
using Cleanuparr.Infrastructure.Features.Auth;
|
|
|
|
namespace Cleanuparr.Api.Tests.Features.Auth;
|
|
|
|
/// <summary>
|
|
/// Spy wrapper around <see cref="PasswordService"/> that tracks calls to
|
|
/// <see cref="VerifyPassword"/> for behavioral assertions in timing tests.
|
|
/// </summary>
|
|
public sealed class TrackingPasswordService : IPasswordService
|
|
{
|
|
private readonly PasswordService _inner = new();
|
|
private int _verifyPasswordCallCount;
|
|
|
|
public int VerifyPasswordCallCount => _verifyPasswordCallCount;
|
|
|
|
public string DummyHash => _inner.DummyHash;
|
|
|
|
public string HashPassword(string password)
|
|
{
|
|
return _inner.HashPassword(password);
|
|
}
|
|
|
|
public bool VerifyPassword(string password, string hash)
|
|
{
|
|
Interlocked.Increment(ref _verifyPasswordCallCount);
|
|
return _inner.VerifyPassword(password, hash);
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
Interlocked.Exchange(ref _verifyPasswordCallCount, 0);
|
|
}
|
|
}
|