Backend/e-suite.Service.Sentinel/Sentinel.UnitTests/Sentinel/LogBadRequestUnitTests.cs
2026-01-20 21:50:10 +00:00

30 lines
893 B
C#

using NUnit.Framework;
using Sentinel.UnitTests.Helpers;
namespace Sentinel.UnitTests.Sentinel;
[TestFixture]
public class LogBadRequestUnitTests : SentinelTestBase
{
[SetUp]
public override async Task Setup()
{
await base.Setup();
}
[Test]
public async Task LogBadRequest_WhenCalled_PassesCorrectInformationToRepository()
{
//Arrange
FakeController fakeController = FakeController.CreateFakeController();
//Act
await Sentinel.LogBadRequest(fakeController, default);
//Assert
Assert.That(SentinelRepository.FailedAccessAttempts.Count, Is.EqualTo(1));
Assert.That(SentinelRepository.FailedAccessAttempts[0].IPAddress, Is.EqualTo("143.24.20.36"));
Assert.That(SentinelRepository.FailedAccessAttempts[0].AttemptedTime, Is.EqualTo(_fakeClock.GetNow));
}
}