public void CheckUserIsBannedTest() { // arrange var user = new User(); user.BanLoginEnd = DateTime.Now.AddMinutes(1); // act var canLogin = user.CheckCanLogin(); // assert Assert.IsFalse(canLogin, "User should be banned"); }
public void AllowLoginAttemptTest() { // arrange var user = new User { FailedLoginCount = 4, FailedLoginTimerStart = DateTime.Now.AddMinutes(-5) }; user.SetPassword("password"); // act user.AttemptLogin("wrongpassword"); // should reset FailedLoginStart var canLogin = user.CheckCanLogin(); // assert Assert.IsTrue(canLogin, "User should be able to attempt a login."); }
public void SetLoginBanTest() { // arrange var user = new User(); user.SetPassword("password"); // act user.AttemptLogin("wrongpassword"); user.AttemptLogin("wrongpassword"); user.AttemptLogin("wrongpassword"); user.AttemptLogin("wrongpassword"); user.AttemptLogin("wrongpassword"); var canLogin = user.CheckCanLogin(); // assert Assert.IsFalse(canLogin, "User should not be able to login."); }
public void ResetLoginBanTest() { // arrange var password = "******"; var user = new User(); user.BanLoginEnd = DateTime.Now.AddMilliseconds(-1); user.FailedLoginCount = 5; user.FailedLoginTimerStart = DateTime.Now.AddMinutes(-20); user.SetPassword(password); // act var canLogin = user.CheckCanLogin(); user.AttemptLogin(password); // assert Assert.IsTrue(canLogin, "User should be able to login."); Assert.IsNull(user.BanLoginEnd, "Ban clock should be reset."); Assert.IsNull(user.FailedLoginTimerStart, "Failed login timer should be reset."); Assert.AreEqual(0, user.FailedLoginCount, "Failed login count should be reset."); }